Replace pin by gpio (#631)

* replace _PIN by _GPIO

* add mention about the goal of -all binaries

* [breaking] change json key from "pin" to "gpio" for actuatorONOFF
This commit is contained in:
Florian authored and GitHub committed 2020-06-13 20:04:36 -05:00
1 parent c9de14e51a
commit c9e6de1a1c
37 files changed
+198 -197

No files matched your search

+3 -3
View File
@@ -240,11 +240,11 @@ uint8_t wifiProtocol = 0; // default mode, automatic selection
# endif
#endif
#ifndef TRIGGER_PIN
#ifndef TRIGGER_GPIO
# ifdef ESP8266
# define TRIGGER_PIN 14 // pin D5 as full reset button (long press >10s)
# define TRIGGER_GPIO 14 // pin D5 as full reset button (long press >10s)
# elif ESP32
# define TRIGGER_PIN 0 // boot button as full reset button (long press >10s)
# define TRIGGER_GPIO 0 // boot button as full reset button (long press >10s)
# endif
#endif
+2 -2
View File
@@ -42,10 +42,10 @@ const long fireUpdate = 10;
CRGBPalette16 gPal;
void setupFASTLED() {
Log.notice(F("FASTLED_DATA_PIN: %d" CR), FASTLED_DATA_PIN);
Log.notice(F("FASTLED_DATA_GPIO: %d" CR), FASTLED_DATA_GPIO);
Log.notice(F("FASTLED_NUM_LEDS: %d" CR), FASTLED_NUM_LEDS);
Log.trace(F("ZactuatorFASTLED setup done " CR));
FastLED.addLeds<FASTLED_TYPE, FASTLED_DATA_PIN>(leds, FASTLED_NUM_LEDS);
FastLED.addLeds<FASTLED_TYPE, FASTLED_DATA_GPIO>(leds, FASTLED_NUM_LEDS);
}
//returns the current step of the animation
+9 -9
View File
@@ -4,7 +4,7 @@
Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
Send and receiving command by MQTT
Output pin defined to High or Low
Output GPIO defined to High or Low
Copyright: (c)Florian ROBERT
@@ -35,12 +35,12 @@ void MQTTtoONOFF(char* topicOri, JsonObject& ONOFFdata) {
if (cmpToMainTopic(topicOri, subjectMQTTtoONOFF)) {
Log.trace(F("MQTTtoONOFF json data analysis" CR));
int boolSWITCHTYPE = ONOFFdata["cmd"] | 99;
int pin = ONOFFdata["pin"] | ACTUATOR_ONOFF_PIN;
int gpio = ONOFFdata["gpio"] | ACTUATOR_ONOFF_GPIO;
if (boolSWITCHTYPE != 99) {
Log.notice(F("MQTTtoONOFF boolSWITCHTYPE ok: %d" CR), boolSWITCHTYPE);
Log.notice(F("Pin number: %d" CR), pin);
pinMode(pin, OUTPUT);
digitalWrite(pin, boolSWITCHTYPE);
Log.notice(F("GPIO number: %d" CR), gpio);
pinMode(gpio, OUTPUT);
digitalWrite(gpio, boolSWITCHTYPE);
// we acknowledge the sending by publishing the value to an acknowledgement topic
pub(subjectGTWONOFFtoMQTT, ONOFFdata);
} else {
@@ -54,9 +54,9 @@ void MQTTtoONOFF(char* topicOri, JsonObject& ONOFFdata) {
void MQTTtoONOFF(char* topicOri, char* datacallback) {
if ((cmpToMainTopic(topicOri, subjectMQTTtoONOFF))) {
Log.trace(F("MQTTtoONOFF" CR));
int pin = strtol(datacallback, NULL, 10); // we will not be able to pass values > 4294967295
Log.notice(F("Pin number: %d" CR), pin);
pinMode(pin, OUTPUT);
int gpio = strtol(datacallback, NULL, 10); // we will not be able to pass values > 4294967295
Log.notice(F("GPIO number: %d" CR), gpio);
pinMode(gpio, OUTPUT);
bool ON = false;
if (strstr(topicOri, ONKey) != NULL)
@@ -64,7 +64,7 @@ void MQTTtoONOFF(char* topicOri, char* datacallback) {
if (strstr(topicOri, OFFKey) != NULL)
ON = false;
digitalWrite(pin, ON);
digitalWrite(gpio, ON);
// we acknowledge the sending by publishing the value to an acknowledgement topic
char b = ON;
pub(subjectGTWONOFFtoMQTT, &b);
+5 -5
View File
@@ -33,24 +33,24 @@
# include <ArduinoJson.h>
// Instantiate the library with TxPin, RxPin.
A6lib A6l(_2G_TX_PIN, _2G_RX_PIN); //D6 to A6 RX, D7 to A6 TX
A6lib A6l(_2G_TX_GPIO, _2G_RX_GPIO); //D6 to A6 RX, D7 to A6 TX
int unreadSMSLocs[50] = {0};
int unreadSMSNum = 0;
SMSmessage sms;
void setup2G() {
Log.notice(F("_2G_TX_PIN: %d " CR), _2G_TX_PIN);
Log.notice(F("_2G_RX_PIN: %d " CR), _2G_RX_PIN);
Log.notice(F("_2G_TX_GPIO: %d " CR), _2G_TX_GPIO);
Log.notice(F("_2G_RX_GPIO: %d " CR), _2G_RX_GPIO);
setupGSM(false);
Log.trace(F("Zgateway2G setup done " CR));
}
void setupGSM(bool deleteSMS) {
Log.trace(F("Init 2G module: %d" CR), _2G_PWR_PIN);
Log.trace(F("Init 2G module: %d" CR), _2G_PWR_GPIO);
delay(1000);
// Power-cycle the module to reset it.
A6l.powerCycle(_2G_PWR_PIN);
A6l.powerCycle(_2G_PWR_GPIO);
Log.notice(F("waiting for network connection at bd: %d" CR), _2G_MODULE_BAUDRATE);
A6l.blockUntilReady(_2G_MODULE_BAUDRATE);
Log.notice(F("A6/A7 gsm ready" CR));
+6 -6
View File
@@ -35,14 +35,14 @@
# include <IRsend.h> // Needed if you want to send IR commands.
# include <IRutils.h>
# ifdef DumpMode // in dump mode we increase the size of the buffer to catch big codes
IRrecv irrecv(IR_RECEIVER_PIN, 1024, 15U, true);
IRrecv irrecv(IR_RECEIVER_GPIO, 1024, 15U, true);
# else
IRrecv irrecv(IR_RECEIVER_PIN);
IRrecv irrecv(IR_RECEIVER_GPIO);
# endif
IRsend irsend(IR_EMITTER_PIN);
IRsend irsend(IR_EMITTER_GPIO);
# else
# include <IRremote.h>
IRrecv irrecv(IR_RECEIVER_PIN);
IRrecv irrecv(IR_RECEIVER_GPIO);
IRsend irsend; //connect IR emitter pin to D9 on arduino, you need to comment #define IR_USE_TIMER2 and uncomment #define IR_USE_TIMER1 on library IRremote.h so as to free pin D3 for RF RECEIVER PIN
# endif
@@ -102,8 +102,8 @@ void setupIR() {
irrecv.enableIRIn(); // Start the receiver
Log.notice(F("IR_EMITTER_PIN: %d " CR), IR_EMITTER_PIN);
Log.notice(F("IR_RECEIVER_PIN: %d " CR), IR_RECEIVER_PIN);
Log.notice(F("IR_EMITTER_GPIO: %d " CR), IR_EMITTER_GPIO);
Log.notice(F("IR_RECEIVER_GPIO: %d " CR), IR_RECEIVER_GPIO);
Log.trace(F("ZgatewayIR setup done " CR));
}
+5 -5
View File
@@ -34,7 +34,7 @@
# endif
# include <ESPiLight.h>
ESPiLight rf(RF_EMITTER_PIN); // use -1 to disable transmitter
ESPiLight rf(RF_EMITTER_GPIO); // use -1 to disable transmitter
void pilightCallback(const String& protocol, const String& message, int status,
size_t repeats, const String& deviceID) {
@@ -66,10 +66,10 @@ void setupPilight() {
rf.enableReceiver();
# endif
rf.setCallback(pilightCallback);
rf.initReceiver(RF_RECEIVER_PIN);
pinMode(RF_EMITTER_PIN, OUTPUT); // Set this here, because if this is the RX pin it was reset to INPUT by Serial.end();
Log.notice(F("RF_EMITTER_PIN: %d " CR), RF_EMITTER_PIN);
Log.notice(F("RF_RECEIVER_PIN: %d " CR), RF_RECEIVER_PIN);
rf.initReceiver(RF_RECEIVER_GPIO);
pinMode(RF_EMITTER_GPIO, OUTPUT); // Set this here, because if this is the RX pin it was reset to INPUT by Serial.end();
Log.notice(F("RF_EMITTER_GPIO: %d " CR), RF_EMITTER_GPIO);
Log.notice(F("RF_RECEIVER_GPIO: %d " CR), RF_RECEIVER_GPIO);
Log.trace(F("ZgatewayPilight setup done " CR));
# else
Log.trace(F("ZgatewayPilight setup cannot be done, comment first ZgatewayRF && ZgatewayRF2" CR));
+8 -8
View File
@@ -56,16 +56,16 @@ void RFtoMQTTdiscovery(unsigned long MQTTvalue) { //on the fly switch creation f
void setupRF() {
//RF init parameters
Log.notice(F("RF_EMITTER_PIN: %d " CR), RF_EMITTER_PIN);
Log.notice(F("RF_RECEIVER_PIN: %d " CR), RF_RECEIVER_PIN);
Log.notice(F("RF_EMITTER_GPIO: %d " CR), RF_EMITTER_GPIO);
Log.notice(F("RF_RECEIVER_GPIO: %d " CR), RF_RECEIVER_GPIO);
# ifdef ZradioCC1101 //receiving with CC1101
ELECHOUSE_cc1101.Init();
ELECHOUSE_cc1101.setMHZ(CC1101_FREQUENCY);
ELECHOUSE_cc1101.SetRx(CC1101_FREQUENCY);
# endif
mySwitch.enableTransmit(RF_EMITTER_PIN);
mySwitch.enableTransmit(RF_EMITTER_GPIO);
mySwitch.setRepeatTransmit(RF_EMITTER_REPEAT);
mySwitch.enableReceive(RF_RECEIVER_PIN);
mySwitch.enableReceive(RF_RECEIVER_GPIO);
Log.trace(F("ZgatewayRF setup done" CR));
}
@@ -105,7 +105,7 @@ void MQTTtoRF(char* topicOri, char* datacallback) {
# ifdef ZradioCC1101 // set Receive off and Transmitt on
ELECHOUSE_cc1101.SetTx(CC1101_FREQUENCY);
mySwitch.disableReceive();
mySwitch.enableTransmit(RF_EMITTER_PIN);
mySwitch.enableTransmit(RF_EMITTER_GPIO);
# endif
unsigned long data = strtoul(datacallback, NULL, 10); // we will not be able to pass values > 4294967295
@@ -157,7 +157,7 @@ void MQTTtoRF(char* topicOri, char* datacallback) {
# ifdef ZradioCC1101 // set Receive on and Transmitt off
ELECHOUSE_cc1101.SetRx(CC1101_FREQUENCY);
mySwitch.disableTransmit();
mySwitch.enableReceive(RF_RECEIVER_PIN);
mySwitch.enableReceive(RF_RECEIVER_GPIO);
# endif
}
# endif
@@ -167,7 +167,7 @@ void MQTTtoRF(char* topicOri, JsonObject& RFdata) { // json object decoding
# ifdef ZradioCC1101 // set Receive off and Transmitt on
ELECHOUSE_cc1101.SetTx(CC1101_FREQUENCY);
mySwitch.disableReceive();
mySwitch.enableTransmit(RF_EMITTER_PIN);
mySwitch.enableTransmit(RF_EMITTER_GPIO);
# endif
if (cmpToMainTopic(topicOri, subjectMQTTtoRF)) {
Log.trace(F("MQTTtoRF json" CR));
@@ -193,7 +193,7 @@ void MQTTtoRF(char* topicOri, JsonObject& RFdata) { // json object decoding
# ifdef ZradioCC1101 // set Receive on and Transmitt off
ELECHOUSE_cc1101.SetRx(CC1101_FREQUENCY);
mySwitch.disableTransmit();
mySwitch.enableReceive(RF_RECEIVER_PIN);
mySwitch.enableReceive(RF_RECEIVER_GPIO);
# endif
}
# endif
+7 -7
View File
@@ -62,13 +62,13 @@ void setupRF2() {
ELECHOUSE_cc1101.setMHZ(CC1101_FREQUENCY);
ELECHOUSE_cc1101.SetRx(CC1101_FREQUENCY);
# endif
NewRemoteReceiver::init(RF_RECEIVER_PIN, 2, rf2Callback);
Log.notice(F("RF_EMITTER_PIN: %d " CR), RF_EMITTER_PIN);
Log.notice(F("RF_RECEIVER_PIN: %d " CR), RF_RECEIVER_PIN);
NewRemoteReceiver::init(RF_RECEIVER_GPIO, 2, rf2Callback);
Log.notice(F("RF_EMITTER_GPIO: %d " CR), RF_EMITTER_GPIO);
Log.notice(F("RF_RECEIVER_GPIO: %d " CR), RF_RECEIVER_GPIO);
Log.trace(F("ZgatewayRF2 setup done " CR));
# endif
pinMode(RF_EMITTER_PIN, OUTPUT);
digitalWrite(RF_EMITTER_PIN, LOW);
pinMode(RF_EMITTER_GPIO, OUTPUT);
digitalWrite(RF_EMITTER_GPIO, LOW);
}
void RF2toMQTT() {
@@ -161,7 +161,7 @@ void MQTTtoRF2(char* topicOri, char* datacallback) {
valuePERIOD = 272;
NewRemoteReceiver::disable();
Log.trace(F("Creating transmitter" CR));
NewRemoteTransmitter transmitter(valueCODE, RF_EMITTER_PIN, valuePERIOD);
NewRemoteTransmitter transmitter(valueCODE, RF_EMITTER_GPIO, valuePERIOD);
Log.trace(F("Sending data" CR));
if (valueGROUP) {
if (isDimCommand) {
@@ -237,7 +237,7 @@ void MQTTtoRF2(char* topicOri, JsonObject& RF2data) { // json object decoding
if (valuePERIOD == 0)
valuePERIOD = 272;
NewRemoteReceiver::disable();
NewRemoteTransmitter transmitter(valueCODE, RF_EMITTER_PIN, valuePERIOD);
NewRemoteTransmitter transmitter(valueCODE, RF_EMITTER_GPIO, valuePERIOD);
Log.trace(F("Sending" CR));
if (valueGROUP) {
if (isDimCommand) {
+2 -2
View File
@@ -27,7 +27,7 @@
#ifdef ZgatewayWeatherStation
# include <WeatherStationDataRx.h>
WeatherStationDataRx wsdr(RF_WS_RECEIVER_PIN, true);
WeatherStationDataRx wsdr(RF_WS_RECEIVER_GPIO, true);
void PairedDeviceAdded(byte newID) {
# if defined(ESP8266) || defined(ESP32)
@@ -46,7 +46,7 @@ void PairedDeviceAdded(byte newID) {
}
void setupWeatherStation() {
Log.notice(F("RF_WS_RECEIVER_PIN %d" CR), RF_WS_RECEIVER_PIN);
Log.notice(F("RF_WS_RECEIVER_GPIO %d" CR), RF_WS_RECEIVER_GPIO);
wsdr.begin();
wsdr.pair(NULL, PairedDeviceAdded);
Log.trace(F("ZgatewayWeatherStation setup done " CR));
+3 -3
View File
@@ -4,7 +4,7 @@
Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
Send and receiving command by MQTT
Analog pin reading Addon
Analog GPIO reading Addon
Copyright: (c)Florian ROBERT
@@ -38,7 +38,7 @@ ADC_MODE(ADC_TOUT);
unsigned long timeadc = 0;
void setupADC() {
Log.notice(F("Reading ADC on pin: %d" CR), ADC_PIN);
Log.notice(F("ADC_GPIO: %d" CR), ADC_GPIO);
}
void MeasureADC() {
@@ -48,7 +48,7 @@ void MeasureADC() {
# endif
timeadc = millis();
static int persistedadc;
int val = analogRead(ADC_PIN);
int val = analogRead(ADC_GPIO);
if (isnan(val)) {
Log.error(F("Failed to read from ADC !" CR));
} else {
+2 -2
View File
@@ -33,13 +33,13 @@
# include <DHT.h>
# include <DHT_U.h>
DHT dht(DHT_RECEIVER_PIN, DHT_SENSOR_TYPE);
DHT dht(DHT_RECEIVER_GPIO, DHT_SENSOR_TYPE);
//Time used to wait for an interval before resending temp and hum
unsigned long timedht = 0;
void setupDHT() {
Log.notice(F("Reading DHT on pin: %d" CR), DHT_RECEIVER_PIN);
Log.notice(F("Reading DHT on pin: %d" CR), DHT_RECEIVER_GPIO);
}
void MeasureTempAndHum() {
+3 -3
View File
@@ -29,7 +29,7 @@
# include <DallasTemperature.h>
# include <OneWire.h>
OneWire owbus(DS1820_OWBUS_PIN);
OneWire owbus(DS1820_OWBUS_GPIO);
DallasTemperature ds1820(&owbus);
DeviceAddress ds1820_address, ds1820_devices[OW_MAX_SENSORS];
@@ -39,7 +39,7 @@ static String ds1820_type[OW_MAX_SENSORS];
static String ds1820_addr[OW_MAX_SENSORS];
void setupZsensorDS1820() {
Log.trace(F("DS1820: configured pin: %d for 1-wire bus" CR), DS1820_OWBUS_PIN);
Log.trace(F("DS1820: configured pin: %d for 1-wire bus" CR), DS1820_OWBUS_GPIO);
ds1820.begin();
// Search the OneWire bus for all devices
@@ -89,7 +89,7 @@ void setupZsensorDS1820() {
}
if (ds1820.getDS18Count() == 0) {
Log.error(F("DS1820: Failed to enumerate sensors on 1-wire bus. Check your pin assignment!" CR));
Log.error(F("DS1820: Failed to enumerate sensors on 1-wire bus. Check your GPIO assignment!" CR));
}
// make requestTemperatures() non-blocking
+3 -3
View File
@@ -35,12 +35,12 @@ int InputState = 3; // Set to 3 so that it reads on startup
int lastInputState = 3;
void setupGPIOInput() {
Log.notice(F("Reading GPIO at pin: %d" CR), GPIOInput_PIN);
pinMode(GPIOInput_PIN, INPUT_PULLUP); // declare GPIOInput pin as input_pullup to prevent floating. Pin will be high when not connected to ground
Log.notice(F("Reading GPIO at pin: %d" CR), INPUT_GPIO);
pinMode(INPUT_GPIO, INPUT_PULLUP); // declare GPIOInput pin as input_pullup to prevent floating. Pin will be high when not connected to ground
}
void MeasureGPIOInput() {
int reading = digitalRead(GPIOInput_PIN);
int reading = digitalRead(INPUT_GPIO);
// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited long enough
+8 -8
View File
@@ -32,15 +32,15 @@ int lastInputStateGPIOKeyCode = 0x0f;
int lastLatchStateGPIOKeyCode = 0;
void setupGPIOKeyCode() {
pinMode(GPIOKeyCode_LATCH_PIN, INPUT_PULLUP); //
pinMode(GPIOKeyCode_D0_PIN, INPUT_PULLUP); //
pinMode(GPIOKeyCode_D1_PIN, INPUT_PULLUP); //
pinMode(GPIOKeyCode_D2_PIN, INPUT_PULLUP); //
//pinMode(GPIOKeyCode_D3_PIN, INPUT_PULLUP); //
pinMode(GPIOKeyCode_LATCH_GPIO, INPUT_PULLUP); //
pinMode(GPIOKeyCode_D0_GPIO, INPUT_PULLUP); //
pinMode(GPIOKeyCode_D1_GPIO, INPUT_PULLUP); //
pinMode(GPIOKeyCode_D2_GPIO, INPUT_PULLUP); //
//pinMode(GPIOKeyCode_D3_GPIO, INPUT_PULLUP); //
}
void MeasureGPIOKeyCode() {
int latch = digitalRead(GPIOKeyCode_LATCH_PIN);
int latch = digitalRead(GPIOKeyCode_LATCH_GPIO);
// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited long enough
@@ -54,8 +54,8 @@ void MeasureGPIOKeyCode() {
# endif
// if the Input state has changed:
if (latch > 0 && lastLatchStateGPIOKeyCode != latch) {
int reading = digitalRead(GPIOKeyCode_D0_PIN) | (digitalRead(GPIOKeyCode_D1_PIN) << 1) | (digitalRead(GPIOKeyCode_D2_PIN) << 2);
//| digitalRead(GPIOKeyCode_D3_PIN) << 3;
int reading = digitalRead(GPIOKeyCode_D0_GPIO) | (digitalRead(GPIOKeyCode_D1_GPIO) << 1) | (digitalRead(GPIOKeyCode_D2_GPIO) << 2);
//| digitalRead(GPIOKeyCode_D3_GPIO) << 3;
char hex[3];
+8 -8
View File
@@ -34,10 +34,10 @@
unsigned long timeHCSR04 = 0;
void setupHCSR04() {
Log.notice(F("HCSR04 trigger pin: %d" CR), HCSR04_TRI_PIN);
Log.notice(F("HCSR04 echo pin: %d" CR), HCSR04_ECH_PIN);
pinMode(HCSR04_TRI_PIN, OUTPUT); // declare HC SR-04 trigger pin as output
pinMode(HCSR04_ECH_PIN, INPUT); // declare HC SR-04 echo pin as input
Log.notice(F("HCSR04 trigger pin: %d" CR), HCSR04_TRI_GPIO);
Log.notice(F("HCSR04 echo pin: %d" CR), HCSR04_ECH_GPIO);
pinMode(HCSR04_TRI_GPIO, OUTPUT); // declare HC SR-04 trigger GPIO as output
pinMode(HCSR04_ECH_GPIO, INPUT); // declare HC SR-04 echo GPIO as input
}
void MeasureDistance() {
@@ -46,12 +46,12 @@ void MeasureDistance() {
Log.trace(F("Creating HCSR04 buffer" CR));
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
JsonObject& HCSR04data = jsonBuffer.createObject();
digitalWrite(HCSR04_TRI_PIN, LOW);
digitalWrite(HCSR04_TRI_GPIO, LOW);
delayMicroseconds(2);
digitalWrite(HCSR04_TRI_PIN, HIGH);
digitalWrite(HCSR04_TRI_GPIO, HIGH);
delayMicroseconds(10);
digitalWrite(HCSR04_TRI_PIN, LOW);
unsigned long duration = pulseIn(HCSR04_ECH_PIN, HIGH);
digitalWrite(HCSR04_TRI_GPIO, LOW);
unsigned long duration = pulseIn(HCSR04_ECH_GPIO, HIGH);
if (isnan(duration)) {
Log.error(F("Failed to read from HC SR04 sensor!" CR));
} else {
+3 -3
View File
@@ -31,8 +31,8 @@
#ifdef ZsensorHCSR501
void setupHCSR501() {
Log.notice(F("HCSR501 pin: %d" CR), HCSR501_PIN);
pinMode(HCSR501_PIN, INPUT); // declare HC SR-501 pin as input
Log.notice(F("HCSR501 pin: %d" CR), HCSR501_GPIO);
pinMode(HCSR501_GPIO, INPUT); // declare HC SR-501 GPIO as input
}
void MeasureHCSR501() {
@@ -41,7 +41,7 @@ void MeasureHCSR501() {
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
JsonObject& HCSR501data = jsonBuffer.createObject();
static int pirState = LOW;
int PresenceValue = digitalRead(HCSR501_PIN);
int PresenceValue = digitalRead(HCSR501_GPIO);
# if defined(ESP8266) || defined(ESP32)
yield();
# endif
+10 -10
View File
@@ -42,19 +42,19 @@ extern void MQTTto2G(char* topicOri, JsonObject& SMSdata);
#define _2G_MAX_SIGNAL 1000
/*-------------------PIN DEFINITIONS----------------------*/
#if !defined(_2G_TX_PIN) || !defined(_2G_RX_PIN) || !defined(_2G_PWR_PIN)
#if !defined(_2G_TX_GPIO) || !defined(_2G_RX_GPIO) || !defined(_2G_PWR_GPIO)
# ifdef ESP8266
# define _2G_TX_PIN D6 //D6 to A6 RX,
# define _2G_RX_PIN D7 //D7 to A6 TX
# define _2G_PWR_PIN D5 // connect a MOSFET to power on and off your A6/7 module
# define _2G_TX_GPIO D6 //D6 to A6 RX,
# define _2G_RX_GPIO D7 //D7 to A6 TX
# define _2G_PWR_GPIO D5 // connect a MOSFET to power on and off your A6/7 module
# elif defined(ESP32)
# define _2G_TX_PIN 16 //D16 to A6 RX,
# define _2G_RX_PIN 17 //D17 to A6 TX
# define _2G_PWR_PIN 5 // connect a MOSFET to power on and off your A6/7 module
# define _2G_TX_GPIO 16 //D16 to A6 RX,
# define _2G_RX_GPIO 17 //D17 to A6 TX
# define _2G_PWR_GPIO 5 // connect a MOSFET to power on and off your A6/7 module
# else
# define _2G_TX_PIN 6 //D6 to A6 RX,
# define _2G_RX_PIN 7 //D7 to A6 TX
# define _2G_PWR_PIN 5 // connect a MOSFET to power on and off your A6/7 module
# define _2G_TX_GPIO 6 //D6 to A6 RX,
# define _2G_RX_GPIO 7 //D7 to A6 TX
# define _2G_PWR_GPIO 5 // connect a MOSFET to power on and off your A6/7 module
# endif
#endif
+2 -2
View File
@@ -41,8 +41,8 @@ extern void ADCtoMQTT();
#endif
/*-------------------PIN DEFINITIONS----------------------*/
#if defined(ESP8266) || !defined(ADC_PIN)
# define ADC_PIN A0 //on nodeMCU this is D3 GPIO0
#if defined(ESP8266) || !defined(ADC_GPIO)
# define ADC_GPIO A0 //on nodeMCU this is D3 pin
#endif
#endif
+4 -4
View File
@@ -38,13 +38,13 @@ extern void DHTtoMQTT();
//#define DHT_SENSOR_TYPE DHT21 //uncomment for DHT21 Sensor
#define DHT_SENSOR_TYPE DHT22 //uncomment for DHT22 Sensor (default for backwards compatibility)
/*-------------------PIN DEFINITIONS----------------------*/
#ifndef DHT_RECEIVER_PIN
#ifndef DHT_RECEIVER_GPIO
# if defined(ESP8266)
# define DHT_RECEIVER_PIN 5 //5 = D1 you can put 14 = D5 if you don't use HCSR501 sensor and the RFM69
# define DHT_RECEIVER_GPIO 5 //5 = D1 you can put 14 = D5 if you don't use HCSR501 sensor and the RFM69
# elif defined(ESP32)
# define DHT_RECEIVER_PIN 16
# define DHT_RECEIVER_GPIO 16
# else
# define DHT_RECEIVER_PIN 8
# define DHT_RECEIVER_GPIO 8
# endif
#endif
+4 -4
View File
@@ -43,13 +43,13 @@ extern void pubOneWire_HADiscovery();
#define DS1820_CONV_TIME 2000 // trigger conversion before requesting temperature readings (ms)
/*-------------------PIN DEFINITIONS----------------------*/
#ifndef DS1820_OWBUS_PIN
#ifndef DS1820_OWBUS_GPIO
# if defined(ESP8266)
# define DS1820_OWBUS_PIN 2
# define DS1820_OWBUS_GPIO 2
# elif defined(ESP32)
# define DS1820_OWBUS_PIN 2
# define DS1820_OWBUS_GPIO 2
# else
# define DS1820_OWBUS_PIN 2
# define DS1820_OWBUS_GPIO 2
# endif
#endif
+19 -19
View File
@@ -56,31 +56,31 @@
//#define FASTLED_TYPE APA102, RGB>(leds, NUM_LEDS);
//#define FASTLED_TYPE DOTSTAR, RGB>(leds, NUM_LEDS);
//#define FASTLED_TYPE WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
//#define FASTLED_TYPE SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
//#define FASTLED_TYPE LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
//#define FASTLED_TYPE P9813, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
//#define FASTLED_TYPE APA102, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
//#define FASTLED_TYPE DOTSTAR, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
//#define FASTLED_TYPE WS2801, DATA_GPIO, CLOCK_GPIO, RGB>(leds, NUM_LEDS);
//#define FASTLED_TYPE SM16716, DATA_GPIO, CLOCK_GPIO, RGB>(leds, NUM_LEDS);
//#define FASTLED_TYPE LPD8806, DATA_GPIO, CLOCK_GPIO, RGB>(leds, NUM_LEDS);
//#define FASTLED_TYPE P9813, DATA_GPIO, CLOCK_GPIO, RGB>(leds, NUM_LEDS);
//#define FASTLED_TYPE APA102, DATA_GPIO, CLOCK_GPIO, RGB>(leds, NUM_LEDS);
//#define FASTLED_TYPE DOTSTAR, DATA_GPIO, CLOCK_GPIO, RGB>(leds, NUM_LEDS);
// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
//#define DATA_PIN 3
//#define CLOCK_PIN 13
// need to define DATA_GPIO. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_GPIO and CLOCK_GPIO
//#define DATA_GPIO 3
//#define CLOCK_GPIO 13
#ifdef ESP8266
//#define FASTLED_ESP8266_RAW_PIN_ORDER
//#define FASTLED_ESP8266_NODEMCU_PIN_ORDER
# define FASTLED_ESP8266_D1_PIN_ORDER
# define FASTLED_DATA_PIN D2 // only D2 works by me
//#define FASTLED_CLOCK_PIN 13
//#define FASTLED_ESP8266_RAW_GPIO_ORDER
//#define FASTLED_ESP8266_NODEMCU_GPIO_ORDER
# define FASTLED_ESP8266_D1_GPIO_ORDER
# define FASTLED_DATA_GPIO D2 // only D2 works by me
//#define FASTLED_CLOCK_GPIO 13
#elif ESP32
# define FASTLED_DATA_PIN 16
# define FASTLED_CLOCK_PIN 13
# define FASTLED_DATA_GPIO 16
# define FASTLED_CLOCK_GPIO 13
#else
# define FASTLED_DATA_PIN 10
# define FASTLED_CLOCK_PIN 13
# define FASTLED_DATA_GPIO 10
# define FASTLED_CLOCK_GPIO 13
#endif
#endif
+3 -3
View File
@@ -34,11 +34,11 @@ extern void GPIOInputtoMQTT();
#define GPIOInputDebounceDelay 60 //debounce time, increase if there are issues
/*-------------------PIN DEFINITIONS----------------------*/
#ifndef GPIOInput_PIN
#ifndef INPUT_GPIO
# if defined(ESP8266) || defined(ESP32)
# define GPIOInput_PIN 13
# define INPUT_GPIO 13
# else
# define GPIOInput_PIN 7
# define INPUT_GPIO 7
# endif
#endif
+10 -10
View File
@@ -37,20 +37,20 @@ extern void GPIOKeyCodetoMQTT();
/*-------------------PIN DEFINITIONS----------------------*/
#if defined(ESP8266) || defined(ESP32)
# ifndef GPIOKeyCode_LATCH_PIN
# define GPIOKeyCode_LATCH_PIN 12 //D6
# ifndef GPIOKeyCode_LATCH_GPIO
# define GPIOKeyCode_LATCH_GPIO 12 //D6
# endif
# ifndef GPIOKeyCode_D0_PIN
# define GPIOKeyCode_D0_PIN 14 //D5
# ifndef GPIOKeyCode_D0_GPIO
# define GPIOKeyCode_D0_GPIO 14 //D5
# endif
# ifndef GPIOKeyCode_D1_PIN
# define GPIOKeyCode_D1_PIN 5 //D1
# ifndef GPIOKeyCode_D1_GPIO
# define GPIOKeyCode_D1_GPIO 5 //D1
# endif
# ifndef GPIOKeyCode_D2_PIN
# define GPIOKeyCode_D2_PIN 13 //D7
# ifndef GPIOKeyCode_D2_GPIO
# define GPIOKeyCode_D2_GPIO 13 //D7
# endif
# ifndef GPIOKeyCode_D3_PIN
# define GPIOKeyCode_D3_PIN XX //??
# ifndef GPIOKeyCode_D3_GPIO
# define GPIOKeyCode_D3_GPIO XX //??
# endif
#else
// must define !!!
+6 -6
View File
@@ -49,14 +49,14 @@ extern void MeasureDistance();
/*-------------------PIN DEFINITIONS----------------------*/
#if defined(ESP8266)
# define HCSR04_TRI_PIN D6
# define HCSR04_ECH_PIN D7
# define HCSR04_TRI_GPIO D6
# define HCSR04_ECH_GPIO D7
#elif defined(ESP32)
# define HCSR04_TRI_PIN 16 // NOT TESTED
# define HCSR04_ECH_PIN 17 // NOT TESTED
# define HCSR04_TRI_GPIO 16 // NOT TESTED
# define HCSR04_ECH_GPIO 17 // NOT TESTED
#else
# define HCSR04_TRI_PIN 6 // NOT TESTED
# define HCSR04_ECH_PIN 5 // NOT TESTED
# define HCSR04_TRI_GPIO 6 // NOT TESTED
# define HCSR04_ECH_GPIO 5 // NOT TESTED
#endif
#endif
+4 -4
View File
@@ -37,13 +37,13 @@ extern void HCSR501toMQTT();
#endif
/*-------------------PIN DEFINITIONS----------------------*/
#ifndef HCSR501_PIN
#ifndef HCSR501_GPIO
# if defined(ESP8266)
# define HCSR501_PIN D5
# define HCSR501_GPIO D5
# elif defined(ESP32)
# define HCSR501_PIN 5
# define HCSR501_GPIO 5
# else
# define HCSR501_PIN 7
# define HCSR501_GPIO 7
# endif
#endif
+10 -10
View File
@@ -145,27 +145,27 @@ extern void MQTTtoIR(char* topicOri, JsonObject& RFdata);
#endif
/*-------------------PIN DEFINITIONS----------------------*/
#ifndef IR_RECEIVER_PIN
#ifndef IR_RECEIVER_GPIO
# ifdef ESP8266
# define IR_RECEIVER_PIN 2 //D4 /replace by 4 with sonoff rf bridge
# define IR_RECEIVER_GPIO 2 //D4 /replace by 4 with sonoff rf bridge
# elif ESP32
# define IR_RECEIVER_PIN 26
# define IR_RECEIVER_GPIO 26
# elif __AVR_ATmega2560__
# define IR_RECEIVER_PIN 2 // 2 = D2 on arduino mega
# define IR_RECEIVER_GPIO 2 // 2 = D2 on arduino mega
# else
# define IR_RECEIVER_PIN 0 // 0 = D2 on arduino UNO
# define IR_RECEIVER_GPIO 0 // 0 = D2 on arduino UNO
# endif
#endif
#ifndef IR_EMITTER_PIN
#ifndef IR_EMITTER_GPIO
# ifdef ESP8266
# define IR_EMITTER_PIN 16 //D0/ replace by 0 (D3) if you use IR LOLIN controller shield /replace by 5 with sonoff rf bridge
# define IR_EMITTER_GPIO 16 //D0/ replace by 0 (D3) if you use IR LOLIN controller shield /replace by 5 with sonoff rf bridge
# elif ESP32
# define IR_EMITTER_PIN 14
# define IR_EMITTER_GPIO 14
# elif __AVR_ATmega2560__
# define IR_EMITTER_PIN 9
# define IR_EMITTER_GPIO 9
# else
# define IR_EMITTER_PIN 9
# define IR_EMITTER_GPIO 9
# endif
#endif
+4 -4
View File
@@ -39,13 +39,13 @@ extern void MQTTtoONOFF(char* topicOri, JsonObject& RFdata);
/*-------------------PIN DEFINITIONS----------------------*/
// default pin, if not set into the MQTT json
#ifndef ACTUATOR_ONOFF_PIN
#ifndef ACTUATOR_ONOFF_GPIO
# ifdef ESP8266
# define ACTUATOR_ONOFF_PIN 15 //12 for sonoff basic relay
# define ACTUATOR_ONOFF_GPIO 15 //12 for sonoff basic relay
# elif ESP32
# define ACTUATOR_ONOFF_PIN 15
# define ACTUATOR_ONOFF_GPIO 15
# else
# define ACTUATOR_ONOFF_PIN 13
# define ACTUATOR_ONOFF_GPIO 13
# endif
#endif
+10 -10
View File
@@ -85,29 +85,29 @@ extern void MQTTtoPilight(char* topicOri, JsonObject& RFdata);
#define CC1101_FREQUENCY 433.92
/*-------------------PIN DEFINITIONS----------------------*/
#ifndef RF_RECEIVER_PIN
#ifndef RF_RECEIVER_GPIO
# ifdef ESP8266
# define RF_RECEIVER_PIN 0 // D3 on nodemcu // put 4 with rf bridge direct mod
# define RF_RECEIVER_GPIO 0 // D3 on nodemcu // put 4 with rf bridge direct mod
# elif ESP32
# define RF_RECEIVER_PIN 27 // D27 on DOIT ESP32
# define RF_RECEIVER_GPIO 27 // D27 on DOIT ESP32
# elif __AVR_ATmega2560__
# define RF_RECEIVER_PIN 1 //1 = D3 on mega
# define RF_RECEIVER_GPIO 1 //1 = D3 on mega
# else
# define RF_RECEIVER_PIN 1 //1 = D3 on arduino
# define RF_RECEIVER_GPIO 1 //1 = D3 on arduino
# endif
#endif
#ifndef RF_EMITTER_PIN
#ifndef RF_EMITTER_GPIO
# ifdef ESP8266
# define RF_EMITTER_PIN 3 // RX on nodemcu if it doesn't work with 3, try with 4 (D2) // put 5 with rf bridge direct mod
# define RF_EMITTER_GPIO 3 // RX on nodemcu if it doesn't work with 3, try with 4 (D2) // put 5 with rf bridge direct mod
# elif ESP32
# define RF_EMITTER_PIN 12 // D12 on DOIT ESP32
# define RF_EMITTER_GPIO 12 // D12 on DOIT ESP32
# elif __AVR_ATmega2560__
# define RF_EMITTER_PIN 4
# define RF_EMITTER_GPIO 4
# else
//IMPORTANT NOTE: On arduino UNO connect IR emitter pin to D9 , comment #define IR_USE_TIMER2 and uncomment #define IR_USE_TIMER1 on library <library>IRremote/boarddefs.h so as to free pin D3 for RF RECEIVER PIN
//RF PIN definition
# define RF_EMITTER_PIN 4 //4 = D4 on arduino
# define RF_EMITTER_GPIO 4 //4 = D4 on arduino
# endif
#endif
+5 -5
View File
@@ -36,15 +36,15 @@ extern void ZgatewayWeatherStationtoMQTT();
#define subjectRFtoMQTT "/433toMQTT"
/*-------------------PIN DEFINITIONS----------------------*/
#ifndef RF_WS_RECEIVER_PIN
#ifndef RF_WS_RECEIVER_GPIO
# ifdef ESP8266
# define RF_WS_RECEIVER_PIN 0 // D3 on nodemcu // put 4 with rf bridge direct mod
# define RF_WS_RECEIVER_GPIO 0 // D3 on nodemcu // put 4 with rf bridge direct mod
# elif ESP32
# define RF_WS_RECEIVER_PIN 27 // D27 on DOIT ESP32
# define RF_WS_RECEIVER_GPIO 27 // D27 on DOIT ESP32
# elif __AVR_ATmega2560__
# define RF_WS_RECEIVER_PIN 1 //1 = D3 on mega
# define RF_WS_RECEIVER_GPIO 1 //1 = D3 on mega
# else
# define RF_WS_RECEIVER_PIN 1 //1 = D3 on arduino
# define RF_WS_RECEIVER_GPIO 1 //1 = D3 on arduino
# endif
#endif
+5 -5
View File
@@ -467,7 +467,7 @@ void setup() {
#if defined(ESP8266) || defined(ESP32)
# ifdef ESP8266
# ifndef ZgatewaySRFB // if we are not in sonoff rf bridge case we apply the ESP8266 pin optimization
# ifndef ZgatewaySRFB // if we are not in sonoff rf bridge case we apply the ESP8266 GPIO optimization
Serial.end();
Serial.begin(SERIAL_BAUD, SERIAL_8N1, SERIAL_TX_ONLY); // enable on ESP8266 to free some pin
# endif
@@ -777,14 +777,14 @@ void saveConfigCallback() {
void checkButton() { // code from tzapu/wifimanager examples
// check for button press
if (digitalRead(TRIGGER_PIN) == LOW) {
if (digitalRead(TRIGGER_GPIO) == LOW) {
// poor mans debounce/press-hold, code not ideal for production
delay(50);
if (digitalRead(TRIGGER_PIN) == LOW) {
if (digitalRead(TRIGGER_GPIO) == LOW) {
Log.trace(F("Trigger button Pressed" CR));
// still holding button for 3000 ms, reset settings, code not ideaa for production
delay(3000); // reset delay hold
if (digitalRead(TRIGGER_PIN) == LOW) {
if (digitalRead(TRIGGER_GPIO) == LOW) {
Log.trace(F("Button Held" CR));
Log.notice(F("Erasing ESP Config, restarting" CR));
setup_wifimanager(true);
@@ -812,7 +812,7 @@ void eraseAndRestart() {
}
void setup_wifimanager(bool reset_settings) {
pinMode(TRIGGER_PIN, INPUT_PULLUP);
pinMode(TRIGGER_GPIO, INPUT_PULLUP);
delay(10);
WiFi.mode(WIFI_STA);