diff --git a/OpenMQTTGateway.ino b/OpenMQTTGateway.ino index 3878778..24fe45a 100644 --- a/OpenMQTTGateway.ino +++ b/OpenMQTTGateway.ino @@ -264,7 +264,7 @@ void loop() boolean resultRFM69 = RFM69toMQTT(); if(resultRFM69) trc(F("RFM69toMQTT OK")); - #endif + #endif } } diff --git a/User_config.h b/User_config.h index c6fcd96..6e96087 100644 --- a/User_config.h +++ b/User_config.h @@ -32,8 +32,8 @@ /*----------------------------USER PARAMETERS-----------------------------*/ #define SERIAL_BAUD 115200 /*-------------DEFINE YOUR WIRING TYPE BELOW----------------*/ -// Choose between "I2C_Wiring" OR "Classic_Wiring" -// Please Note: I2C Wiring and Classic Wiring uses two complete different Pins for all Modules, see PIN definitions at the end of this file +// Choose between "I2C_Wiring" OR "Classic_Wiring" OR "RFM69_Wiring" +// Please Note: I2C Wiring,Classic Wiring and RFM69_Wiring uses different Pins for all Modules, see PIN definitions into the wiki //#define I2C_Wiring // With Support for I2C Modules and the associated libraries BH1750 and BME280 //#define RFM69_Wiring // following file img/OpenMQTTGateway_IR_RF_RFM69.png #define Classic_Wiring // following file img/OpenMQTTGateway_IR_RF_BT.png @@ -71,257 +71,52 @@ const byte subnet[] = { 255, 255, 255, 0 }; //ip adress #define ota_port 8266 /*-------------DEFINE THE MODULES YOU WANT BELOW----------------*/ -//Addons and module management, comment the line if you don't use +//Addons and module management, comment the Z line and the config file if you don't use #ifdef ESP8266 // for nodemcu, weemos and esp8266 - //#define ZsensorDHT + #define ZsensorDHT + #include "config_DHT.h" #define ZgatewayRF + #include "config_RF.h" #define ZgatewayRF2 #ifdef RFM69_Wiring #define ZgatewayRFM69 + #include "config_RFM69.h" #endif #define ZgatewayIR - //#define ZgatewayBT + #include "config_IR.h" + #define ZgatewayBT + #include "config_BT.h" #ifdef I2C_Wiring // to use the sensor below the gateway should wired with I2CWiring, see PIN DEFINITIONS below #define ZsensorBH1750 + #include "config_BH1750.h" #define ZsensorBME280 + #include "config_BME280.h" #endif #else // for arduino + W5100 #define ZgatewayRF + #include "config_RF.h" #define ZgatewayRF2 #ifdef RFM69_Wiring //#define ZgatewayRFM69 not tested + //#include "config_RFM69.h" #endif #define ZgatewayIR + #include "config_IR.h" #define ZgatewayBT + #include "config_BT.h" //#define ZsensorDHT + //#include "config_DHT.h" //#define ZsensorBH1750 + //#include "config_BH1750.h" //#define ZsensorBME280 + //#include "config_BME280.h" + #endif/*----------------------------OTHER PARAMETERS-----------------------------*/ /*-------------------CHANGING THEM IS NOT COMPULSORY-----------------------*/ -//variables to avoid duplicates for RF -#define time_avoid_duplicate 3000 // if you want to avoid duplicate mqtt message received set this to > 0, the value is the time in milliseconds during which we don't publish duplicates - /*--------------MQTT general topics-----------------*/ // global MQTT subject listened by the gateway to execute commands (send RF, IR or others) #define subjectMQTTtoX "home/commands/#" #define subjectMultiGTWKey "toMQTT" -/*-------------------RF topics & parameters----------------------*/ -//433Mhz MQTT Subjects and keys -#define subjectMQTTtoRF "home/commands/MQTTto433" -#define subjectRFtoMQTT "home/433toMQTT" -#define subjectGTWRFtoMQTT "home/433toMQTT" -#define subjectRFtoMQTTprotocol "home/433toMQTT/protocol" -#define subjectRFtoMQTTbits "home/433toMQTT/bits" -#define subjectRFtoMQTTlength "home/433toMQTT/length" -#define RFprotocolKey "433_" // protocol will be defined if a subject contains RFprotocolKey followed by a value of 1 digit -#define RFbitsKey "RFBITS_" // bits will be defined if a subject contains RFbitsKey followed by a value of 2 digits -#define repeatRFwMQTT false // do we repeat a received signal by using mqtt -/* -RF supported protocols -433_1 -433_2 -433_3 -433_4 -433_5 -433_6 -*/ -#define RFpulselengthKey "PLSL_" // pulselength will be defined if a subject contains RFprotocolKey followed by a value of 3 digits -// subject monitored to listen traffic processed by other gateways to store data and avoid ntuple -#define subjectMultiGTWRF "+/433toMQTT" -//RF number of signal repetition -#define RF_EMITTER_REPEAT 20 - -/*-------------------RF2 topics & parameters----------------------*/ -//433Mhz newremoteswitch MQTT Subjects and keys -#define subjectMQTTtoRF2 "home/commands/MQTTtoRF2" -#define RF2codeKey "CODE_" // code will be defined if a subject contains RF2codeKeyrotocolKey followed by a value of 7 digits -#define RF2periodKey "PERIOD_" // period will be defined if a subject contains RF2periodKey followed by a value of 3 digits -#define RF2unitKey "UNIT_" // number of your unit value will be defined if a subject contains RF2unitKey followed by a value of 1 digit - -/*-------------------IR topics & parameters----------------------*/ -//IR MQTT Subjects -#define subjectGTWIRtoMQTT "home/IRtoMQTT" -#define subjectIRtoMQTT "home/IRtoMQTT" -#define subjectMQTTtoIR "home/commands/MQTTtoIR" -#define subjectIRtoMQTTprotocol "home/IRtoMQTT/protocol" -#define subjectIRtoMQTTbits "home/IRtoMQTT/bits" -#define subjectIRtoMQTTRaw "home/IRtoMQTT/raw" -// subject monitored to listen traffic processed by other gateways to store data and avoid ntuple -#define subjectMultiGTWIR "+/IRtoMQTT" -#define IRbitsKey "IRBITS_" // bits will be defined if a subject contains IRbitsKey followed by a value of 2 digits -#define IRRptKey "RPT_" // repeats will be defined if a subject contains IRRptKey followed by a value of 1 digit -#define repeatIRwMQTT false // do we repeat a received signal by using mqtt - -#define pubIRunknownPrtcl false // key to avoid mqtt publication of unknown IR protocol (set to true if you want to publish unknown protocol) -#define PanasonicAddress 0x4004 // Panasonic address (Pre data) - -#ifdef ESP8266 //IR supported protocols on ESP8266, all supported per default - #define IR_GC - #define IR_Raw - #define IR_COOLIX - #define IR_Whynter - #define IR_LG - #define IR_Sony - #define IR_DISH - #define IR_RC5 - #define IR_Sharp - #define IR_SAMSUNG - #define IR_PANASONIC - #define IR_RCMM -#else //IR supported protocols on arduino uncomment if you want to send with this protocol, NEC protocol is available per default - //#define IR_COOLIX - //#define IR_Whynter - //#define IR_LG - //#define IR_Sony - //#define IR_DISH - //#define IR_RC5 - //#define IR_Sharp - //#define IR_SAMSUNG - //#define IR_Raw - //#define IR_PANASONIC -#endif - -/*----------------------BT topics & parameters-------------------------*/ -#define subjectBTtoMQTT "home/BTtoMQTT/" -#define HM-10 -//#define HM-11 // uncomment this line if you use HM-11 and comment the line above - -/*----------------------RFM69 topics & parameters -------------------------*/ -#define subjectRFM69toMQTT "home/RFM69toMQTT" -#define subjectRFM69toMQTTrssi "home/RFM69toMQTT/rssi" -#define subjectRFM69toMQTTsender "home/RFM69toMQTT/sender" -#define subjectMQTTtoRFM69 "home/commands/MQTTtoRFM69" -#define RFM69receiverKey "RCV_" // receiver id will be defined if a subject contains RFM69receiverKey followed by a value of 3 digits -#define subjectGTWRFM69toMQTT "home/RFM69toMQTT" -#define defaultRFM69ReceiverId 99 - -// Default values -const char PROGMEM ENCRYPTKEY[] = "sampleEncryptKey"; -const char PROGMEM MDNS_NAME[] = "rfm69gw1"; -const char PROGMEM MQTT_BROKER[] = "raspi2"; -const char PROGMEM RFM69AP_NAME[] = "RFM69-AP"; -#define NETWORKID 200 //the same on all nodes that talk to each other -#define NODEID 10 - -//Match frequency to the hardware version of the radio -#define FREQUENCY RF69_433MHZ -//#define FREQUENCY RF69_868MHZ -//#define FREQUENCY RF69_915MHZ -#define IS_RFM69HCW true // set to 'true' if you are using an RFM69HCW module -#define POWER_LEVEL 31 - -/*----------------------RFM69 topics & parameters -------------------------*/ -#define subjectRFM69toMQTT "home/RFM69toMQTT" -#define subjectRFM69toMQTTrssi "home/RFM69toMQTT/rssi" -#define subjectRFM69toMQTTsender "home/RFM69toMQTT/sender" -#define subjectMQTTtoRFM69 "home/commands/MQTTtoRFM69" -#define RFM69receiverKey "RCV_" // receiver id will be defined if a subject contains RFM69receiverKey followed by a value of 3 digits -#define subjectGTWRFM69toMQTT "home/RFM69toMQTT" -#define defaultRFM69ReceiverId 99 - -// Default values -const char PROGMEM ENCRYPTKEY[] = "sampleEncryptKey"; -const char PROGMEM MDNS_NAME[] = "rfm69gw1"; -const char PROGMEM MQTT_BROKER[] = "raspi2"; -const char PROGMEM RFM69AP_NAME[] = "RFM69-AP"; -#define NETWORKID 200 //the same on all nodes that talk to each other -#define NODEID 10 - -//Match frequency to the hardware version of the radio -#define FREQUENCY RF69_433MHZ -//#define FREQUENCY RF69_868MHZ -//#define FREQUENCY RF69_915MHZ -#define IS_RFM69HCW true // set to 'true' if you are using an RFM69HCW module -#define POWER_LEVEL 31 - -/*-------------------PIN DEFINITIONS----------------------*/ -#ifdef I2C_Wiring // With Support for I2C Modules - #define DHT_RECEIVER_PIN 14 //on nodeMCU this is D5 GPIO14 - #define IR_RECEIVER_PIN 2 // put 2 = D4 on nodemcu, 2 = D2 on arduino - #define RF_EMITTER_PIN 15 //put 15 = D8 on nodemcu - - #ifdef ESP8266 - #define IR_EMITTER_PIN 16 // 16 = D0 on nodemcu #define only usefull for ESP8266 - //RF PIN definition - #define RF_RECEIVER_PIN 0 // 0 = D3 on nodemcu - #define BT_RX D7 //ESP8266 RX connect HM-10 or 11 TX - #define BT_TX D6 //ESP8266 TX connect HM-10 or 11 RX - #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 IRremote/IRremoteInt.h so as to free pin D3 for RF RECEIVER PIN - //RF PIN definition - #define RF_RECEIVER_PIN 1 // 1 = D3 on arduino - #define BT_RX 5 //arduino RX connect HM-10 or 11 TX - #define BT_TX 6 //arduino TX connect HM-10 or 11 RX - #endif -#endif - -#ifdef Classic_Wiring // Without Support for I2C Modules - #define DHT_RECEIVER_PIN 0 //on nodeMCU this is D3 GPIO0 - #define IR_RECEIVER_PIN 2 // put 2 = D4 on nodemcu, 2 = D2 on arduino - #define RF_EMITTER_PIN 4 //put 4 = D2 on nodemcu, 4 = D4 on arduino - - #ifdef ESP8266 - #define IR_EMITTER_PIN 14 // 14 = D5 on nodemcu #define only usefull for ESP8266 - //RF PIN definition - #define RF_RECEIVER_PIN 5 // 5 = D1 on nodemcu - #define BT_RX D7 //ESP8266 RX connect HM-10 or 11 TX - #define BT_TX D6 //ESP8266 TX connect HM-10 or 11 RX - #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 IRremote/IRremoteInt.h so as to free pin D3 for RF RECEIVER PIN - //RF PIN definition - #define RF_RECEIVER_PIN 1 // 1 = D3 on arduino - #define BT_RX 5 //arduino RX connect HM-10 or 11 TX - #define BT_TX 6 //arduino TX connect HM-10 or 11 RX - #endif -#endif - -#ifdef RFM69_Wiring // Without Support for I2C Modules and HM10 or 11 - #define DHT_RECEIVER_PIN 0 //on nodeMCU this is D3 GPIO0 - #define IR_RECEIVER_PIN 2 // put 2 = D4 on nodemcu, 2 = D2 on arduino - - #ifdef ESP8266 - #define IR_EMITTER_PIN 16 // 16 = D0 on nodemcu - //RF PIN definition - #define RF_RECEIVER_PIN 0 // 0 = D3 on nodemcu - #define RF_EMITTER_PIN D2 //put D2 on nodemcu - #define RFM69_CS D1 // GPIO5/HCS/D1 - #define RFM69_IRQ D8 // GPIO15/D8 -======= -#ifdef RFM69_Wiring // Without Support for I2C Modules - #define DHT_RECEIVER_PIN 0 //on nodeMCU this is D3 GPIO0 - #define IR_RECEIVER_PIN 2 // put 2 = D4 on nodemcu, 2 = D2 on arduino - #define RF_EMITTER_PIN 10 //put 4 = D2 on nodemcu, 4 = D4 on arduino - - #ifdef ESP8266 - #define IR_EMITTER_PIN 16 // 14 = D5 on nodemcu #define only usefull for ESP8266 - //RF PIN definition - #define RF_RECEIVER_PIN 0 // 5 = D1 on nodemcu - #define RFM69_CS D1 // GPIO15/HCS/D8 - #define RFM69_IRQ D8 // GPIO04/D2 - #define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ) - #define RFM69_RST D4 // GPIO02/D4 - #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 IRremote/IRremoteInt.h so as to free pin D3 for RF RECEIVER PIN - //RF PIN definition - #define RF_RECEIVER_PIN 1 // 1 = D3 on arduino - - #define RF_EMITTER_PIN 4 //4 = D4 on arduino - #define BT_RX 5 //arduino RX connect HM-10 or 11 TX - #define BT_TX 6 //arduino TX connect HM-10 or 11 RX - //RFM69 not tested with arduino - #define RFM69_CS 10 - #define RFM69_IRQ 2 - #define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ) - #define RFM69_RST 9 - #endif -#endif - - -//RF number of signal repetition -#define RF_EMITTER_REPEAT 20 - - /*-------------------ACTIVATE TRACES----------------------*/ #define TRACE 1 // 0= trace off 1 = trace on - diff --git a/ZsensorBH1750.ino b/ZsensorBH1750.ino index 9b71a71..57288d9 100644 --- a/ZsensorBH1750.ino +++ b/ZsensorBH1750.ino @@ -40,18 +40,6 @@ #ifdef ZsensorBH1750 #include "math.h" // Library for trig and exponential functions #include "Wire.h" // Library for communication with I2C / TWI devices -#define bh1750_always true // if false when the current value for light Level (Lux) is the same as previous one don't send it by MQTT -#define TimeBetweenReadingBH1750 30000 - -/*----------------------------USER PARAMETERS-----------------------------*/ -/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/ -#define LUX "home/LIGHTtoMQTT/lux" -#define FTCD "home/LIGHTtoMQTT/ftcd" -#define WATTSM2 "home/LIGHTtoMQTT/wattsm2" - -//Time used to wait for an interval before resending measured values -unsigned long timebh1750 = 0; -int BH1750_i2c_addr = 0x23; // Light Sensor I2C Address void setupZsensorBH1750() { diff --git a/ZsensorBME280.ino b/ZsensorBME280.ino index e69a029..5b2e32c 100644 --- a/ZsensorBME280.ino +++ b/ZsensorBME280.ino @@ -43,21 +43,6 @@ #include #include "SparkFunBME280.h" -#define bme280_always true // if false when the current value for light Level (Lux) is the same as previous one don't send it by MQTT -#define TimeBetweenReadingbme280 30000 - -/*----------------------------USER PARAMETERS-----------------------------*/ -/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/ -#define TEMPBMEC "home/CLIMAtoMQTT/bme/tempc" -#define TEMPBMEF "home/CLIMAtoMQTT/bme/tempf" -#define HUMBME "home/CLIMAtoMQTT/bme/hum" -#define PRESSBME "home/CLIMAtoMQTT/bme/pa" -#define ALTIBMEM "home/CLIMAtoMQTT/bme/altim" -#define ALTIBMEFT "home/CLIMAtoMQTT/bme/altift" - -//Time used to wait for an interval before resending measured values -unsigned long timebme280 = 0; - //Global sensor object BME280 mySensor; diff --git a/config_BH1750.h b/config_BH1750.h new file mode 100644 index 0000000..8db4e3d --- /dev/null +++ b/config_BH1750.h @@ -0,0 +1,50 @@ +/* + OpenMQTTGateway - ESP8266 or Arduino program for home automation + + Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker + Send and receiving command by MQTT + + This files enables to set your parameter for the BH1750 sensor + + Copyright: (c) Hans-Juergen Dinges + + This file is part of OpenMQTTGateway. + + OpenMQTTGateway is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenMQTTGateway is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + Connection Schemata: + -------------------- + + BH1750 ------> Arduino Uno ----------> ESP8266 + ============================================== + Vcc ---------> 5V -------------------> Vu (5V) + GND ---------> GND ------------------> GND + SCL ---------> Pin A5 ---------------> D1 + SDA ---------> Pin A4 ---------------> D2 + ADD ---------> N/C (Not Connected) --> N/C (Not Connected) + +*/ + +#define bh1750_always true // if false when the current value for light Level (Lux) is the same as previous one don't send it by MQTT +#define TimeBetweenReadingBH1750 30000 + +/*----------------------------USER PARAMETERS-----------------------------*/ +/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/ +#define LUX "home/LIGHTtoMQTT/lux" +#define FTCD "home/LIGHTtoMQTT/ftcd" +#define WATTSM2 "home/LIGHTtoMQTT/wattsm2" + +//Time used to wait for an interval before resending measured values +unsigned long timebh1750 = 0; +int BH1750_i2c_addr = 0x23; // Light Sensor I2C Address diff --git a/config_BME280.h b/config_BME280.h new file mode 100644 index 0000000..5b7ec10 --- /dev/null +++ b/config_BME280.h @@ -0,0 +1,54 @@ +/* + OpenMQTTGateway - ESP8266 or Arduino program for home automation + + Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker + Send and receiving command by MQTT + + This files enables to set your parameter for the BME280 sensor + + Copyright: (c) Hans-Juergen Dinges + + This file is part of OpenMQTTGateway. + + OpenMQTTGateway is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenMQTTGateway is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + Connection Schemata: + -------------------- + + BH1750 ------> Arduino Uno ----------> ESP8266 + ============================================== + Vcc ---------> 5V -------------------> Vu (5V) + GND ---------> GND ------------------> GND + SCL ---------> Pin A5 ---------------> D1 + SDA ---------> Pin A4 ---------------> D2 + ADD ---------> N/C (Not Connected) --> N/C (Not Connected) + +*/ + +#define bme280_always true // if false when the current value for light Level (Lux) is the same as previous one don't send it by MQTT +#define TimeBetweenReadingbme280 30000 + +/*----------------------------USER PARAMETERS-----------------------------*/ +/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/ +#define TEMPBMEC "home/CLIMAtoMQTT/bme/tempc" +#define TEMPBMEF "home/CLIMAtoMQTT/bme/tempf" +#define HUMBME "home/CLIMAtoMQTT/bme/hum" +#define PRESSBME "home/CLIMAtoMQTT/bme/pa" +#define ALTIBMEM "home/CLIMAtoMQTT/bme/altim" +#define ALTIBMEFT "home/CLIMAtoMQTT/bme/altift" + +//Time used to wait for an interval before resending measured values +unsigned long timebme280 = 0; + + diff --git a/config_BT.h b/config_BT.h new file mode 100644 index 0000000..04bdbac --- /dev/null +++ b/config_BT.h @@ -0,0 +1,38 @@ +/* + OpenMQTTGateway - ESP8266 or Arduino program for home automation + + Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker + Send and receiving command by MQTT + + This files enables to set your parameter for the bluetooth low energy gateway (beacons detection) + + Copyright: (c)Florian ROBERT + + This file is part of OpenMQTTGateway. + + OpenMQTTGateway is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenMQTTGateway is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/*----------------------BT topics & parameters-------------------------*/ +#define subjectBTtoMQTT "home/BTtoMQTT/" +#define HM-10 +//#define HM-11 // uncomment this line if you use HM-11 and comment the line above + +/*-------------------PIN DEFINITIONS----------------------*/ +#ifdef ESP8266 + #define BT_RX 13 //D7 ESP8266 RX connect HM-10 or 11 TX + #define BT_TX 12 //D6 ESP8266 TX connect HM-10 or 11 RX +#else + #define BT_RX 5 //arduino RX connect HM-10 or 11 TX + #define BT_TX 6 //arduino TX connect HM-10 or 11 RX +#endif diff --git a/config_DHT.h b/config_DHT.h new file mode 100644 index 0000000..6e2afc2 --- /dev/null +++ b/config_DHT.h @@ -0,0 +1,39 @@ +/* + OpenMQTTGateway - ESP8266 or Arduino program for home automation + + Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker + Send and receiving command by MQTT + + This files enables to set your parameter for the DHT11/22 sensor + + Copyright: (c)Florian ROBERT + + This file is part of OpenMQTTGateway. + + OpenMQTTGateway is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenMQTTGateway is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/*-------------------PIN DEFINITIONS----------------------*/ +#ifdef I2C_Wiring // With Support for I2C Modules + #define DHT_RECEIVER_PIN 14 //on nodeMCU this is D5 GPIO14 +#endif + +#ifdef Classic_Wiring // Without Support for I2C Modules + #define DHT_RECEIVER_PIN 0 //on nodeMCU this is D3 GPIO0 +#endif + +#ifdef RFM69_Wiring // Without Support for I2C Modules and HM10 or 11 + #define DHT_RECEIVER_PIN 0 //on nodeMCU this is D3 GPIO0 +#endif + diff --git a/config_IR.h b/config_IR.h new file mode 100644 index 0000000..7495320 --- /dev/null +++ b/config_IR.h @@ -0,0 +1,86 @@ +/* + OpenMQTTGateway - ESP8266 or Arduino program for home automation + + Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker + Send and receiving command by MQTT + + This files enables to set your parameter for the infrared gateway + + Copyright: (c)Florian ROBERT + + This file is part of OpenMQTTGateway. + + OpenMQTTGateway is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenMQTTGateway is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/*-------------------IR topics & parameters----------------------*/ +//IR MQTT Subjects +#define subjectGTWIRtoMQTT "home/IRtoMQTT" +#define subjectIRtoMQTT "home/IRtoMQTT" +#define subjectMQTTtoIR "home/commands/MQTTtoIR" +#define subjectIRtoMQTTprotocol "home/IRtoMQTT/protocol" +#define subjectIRtoMQTTbits "home/IRtoMQTT/bits" +#define subjectIRtoMQTTRaw "home/IRtoMQTT/raw" +// subject monitored to listen traffic processed by other gateways to store data and avoid ntuple +#define subjectMultiGTWIR "+/IRtoMQTT" +#define IRbitsKey "IRBITS_" // bits will be defined if a subject contains IRbitsKey followed by a value of 2 digits +#define IRRptKey "RPT_" // repeats will be defined if a subject contains IRRptKey followed by a value of 1 digit +#define repeatIRwMQTT false // do we repeat a received signal by using mqtt + +#define pubIRunknownPrtcl false // key to avoid mqtt publication of unknown IR protocol (set to true if you want to publish unknown protocol) +#define PanasonicAddress 0x4004 // Panasonic address (Pre data) + +#ifdef ESP8266 //IR supported protocols on ESP8266, all supported per default + #define IR_GC + #define IR_Raw + #define IR_COOLIX + #define IR_Whynter + #define IR_LG + #define IR_Sony + #define IR_DISH + #define IR_RC5 + #define IR_Sharp + #define IR_SAMSUNG + #define IR_PANASONIC + #define IR_RCMM +#else //IR supported protocols on arduino uncomment if you want to send with this protocol, NEC protocol is available per default + //#define IR_COOLIX + //#define IR_Whynter + //#define IR_LG + //#define IR_Sony + //#define IR_DISH + //#define IR_RC5 + //#define IR_Sharp + //#define IR_SAMSUNG + //#define IR_Raw + //#define IR_PANASONIC +#endif + +/*-------------------PIN DEFINITIONS----------------------*/ +#define IR_RECEIVER_PIN 2 // put 2 = D4 on nodemcu, 2 = D2 on arduino + +#ifdef I2C_Wiring // With Support for I2C Modules + #define IR_EMITTER_PIN 16 // 16 = D0 on nodemcu #define only usefull for ESP8266 +#endif + +#ifdef RFM69_Wiring // With Support for I2C Modules + #define IR_EMITTER_PIN 16 // 16 = D0 on nodemcu #define only usefull for ESP8266 +#endif + +#ifdef Classic_Wiring // Without Support for I2C Modules + #define IR_EMITTER_PIN 14 // 14 = D5 on nodemcu #define only usefull for ESP8266 +#endif + + + diff --git a/config_RF.h b/config_RF.h new file mode 100644 index 0000000..34aada2 --- /dev/null +++ b/config_RF.h @@ -0,0 +1,102 @@ +/* + OpenMQTTGateway - ESP8266 or Arduino program for home automation + + Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker + Send and receiving command by MQTT + + This files enables to set your parameter for the radiofrequency gateways (ZgatewayRF and ZgatewayRF2) with RCswitch and newremoteswitch library + + Copyright: (c)Florian ROBERT + + This file is part of OpenMQTTGateway. + + OpenMQTTGateway is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenMQTTGateway is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/*-------------------RF topics & parameters----------------------*/ +//433Mhz MQTT Subjects and keys +#define subjectMQTTtoRF "home/commands/MQTTto433" +#define subjectRFtoMQTT "home/433toMQTT" +#define subjectGTWRFtoMQTT "home/433toMQTT" +#define subjectRFtoMQTTprotocol "home/433toMQTT/protocol" +#define subjectRFtoMQTTbits "home/433toMQTT/bits" +#define subjectRFtoMQTTlength "home/433toMQTT/length" +#define RFprotocolKey "433_" // protocol will be defined if a subject contains RFprotocolKey followed by a value of 1 digit +#define RFbitsKey "RFBITS_" // bits will be defined if a subject contains RFbitsKey followed by a value of 2 digits +#define repeatRFwMQTT false // do we repeat a received signal by using mqtt +/* +RF supported protocols +433_1 +433_2 +433_3 +433_4 +433_5 +433_6 +*/ +#define RFpulselengthKey "PLSL_" // pulselength will be defined if a subject contains RFprotocolKey followed by a value of 3 digits +// subject monitored to listen traffic processed by other gateways to store data and avoid ntuple +#define subjectMultiGTWRF "+/433toMQTT" +//RF number of signal repetition +#define RF_EMITTER_REPEAT 20 + +//variables to avoid duplicates for RF +#define time_avoid_duplicate 3000 // if you want to avoid duplicate mqtt message received set this to > 0, the value is the time in milliseconds during which we don't publish duplicates + +/*-------------------RF2 topics & parameters----------------------*/ +//433Mhz newremoteswitch MQTT Subjects and keys +#define subjectMQTTtoRF2 "home/commands/MQTTtoRF2" +#define RF2codeKey "CODE_" // code will be defined if a subject contains RF2codeKeyrotocolKey followed by a value of 7 digits +#define RF2periodKey "PERIOD_" // period will be defined if a subject contains RF2periodKey followed by a value of 3 digits +#define RF2unitKey "UNIT_" // number of your unit value will be defined if a subject contains RF2unitKey followed by a value of 1 digit + +/*-------------------PIN DEFINITIONS----------------------*/ +#ifdef I2C_Wiring // With Support for I2C Modules + #define RF_EMITTER_PIN 15 //put 15 = D8 on nodemcu + #ifdef ESP8266 + //RF PIN definition + #define RF_RECEIVER_PIN 0 // 0 = D3 on nodemcu + #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 IRremote/IRremoteInt.h so as to free pin D3 for RF RECEIVER PIN + //RF PIN definition + #define RF_RECEIVER_PIN 1 // 1 = D3 on arduino + #endif +#endif + +#ifdef Classic_Wiring // Without Support for I2C Modules + #define RF_EMITTER_PIN 4 //put 4 = D2 on nodemcu, 4 = D4 on arduino + #ifdef ESP8266 + //RF PIN definition + #define RF_RECEIVER_PIN 5 // 5 = D1 on nodemcu + #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 IRremote/IRremoteInt.h so as to free pin D3 for RF RECEIVER PIN + //RF PIN definition + #define RF_RECEIVER_PIN 1 // 1 = D3 on arduino + #endif +#endif + +#ifdef RFM69_Wiring // Without Support for I2C Modules and HM10 or 11 + #ifdef ESP8266 + #define RF_RECEIVER_PIN 0 // 0 = D3 on nodemcu + #define RF_EMITTER_PIN D2 //put D2 on nodemcu + #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 IRremote/IRremoteInt.h so as to free pin D3 for RF RECEIVER PIN + //RF PIN definition + #define RF_RECEIVER_PIN 1 // 1 = D3 on arduino + #define RF_EMITTER_PIN 4 //4 = D4 on arduino + #endif +#endif + + + + diff --git a/config_RFM69.h b/config_RFM69.h new file mode 100644 index 0000000..0ff1187 --- /dev/null +++ b/config_RFM69.h @@ -0,0 +1,68 @@ +/* + OpenMQTTGateway - ESP8266 or Arduino program for home automation + + Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker + Send and receiving command by MQTT + + This files enables to set your parameter for the radiofrequency gateways (ZgatewayRF and ZgatewayRF2) with RCswitch and newremoteswitch library + + Copyright: (c)Florian ROBERT + + This file is part of OpenMQTTGateway. + + OpenMQTTGateway is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenMQTTGateway is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/*----------------------RFM69 topics & parameters -------------------------*/ +#define subjectRFM69toMQTT "home/RFM69toMQTT" +#define subjectRFM69toMQTTrssi "home/RFM69toMQTT/rssi" +#define subjectRFM69toMQTTsender "home/RFM69toMQTT/sender" +#define subjectMQTTtoRFM69 "home/commands/MQTTtoRFM69" +#define RFM69receiverKey "RCV_" // receiver id will be defined if a subject contains RFM69receiverKey followed by a value of 3 digits +#define subjectGTWRFM69toMQTT "home/RFM69toMQTT" +#define defaultRFM69ReceiverId 99 + +// Default values +const char PROGMEM ENCRYPTKEY[] = "sampleEncryptKey"; +const char PROGMEM MDNS_NAME[] = "rfm69gw1"; +const char PROGMEM MQTT_BROKER[] = "raspi2"; +const char PROGMEM RFM69AP_NAME[] = "RFM69-AP"; +#define NETWORKID 200 //the same on all nodes that talk to each other +#define NODEID 10 + +//Match frequency to the hardware version of the radio +#define FREQUENCY RF69_433MHZ +//#define FREQUENCY RF69_868MHZ +//#define FREQUENCY RF69_915MHZ +#define IS_RFM69HCW true // set to 'true' if you are using an RFM69HCW module +#define POWER_LEVEL 31 + +/*-------------------PIN DEFINITIONS----------------------*/ + +#ifdef RFM69_Wiring // Without Support for I2C Modules and HM10 or 11 + + #ifdef ESP8266 + #define RFM69_CS D1 // GPIO5/HCS/D1 + #define RFM69_IRQ D8 // GPIO15/D8 + #define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ) + #define RFM69_RST D4 // GPIO02/D4 + #else + //RFM69 not tested with arduino + #define RFM69_CS 10 + #define RFM69_IRQ 2 + #define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ) + #define RFM69_RST 9 + #endif +#endif +