From ca7d5d4195488552025087960709a4e8443d78b0 Mon Sep 17 00:00:00 2001 From: 1technophile <1technophile@users.noreply.github.com> Date: Thu, 8 Aug 2019 21:27:34 +0200 Subject: [PATCH] Add of SONOFF RFR3 environment Relay ok Button press ok RF reception 433toMQTT ok To have the RF reception you need to connect D0 of SYN470 to GPIO4 of ESP8285. Instruction to follow. Do not do that if you are not confortable with soldering and don't have an electrical background. --- main/config_GPIOInput.h | 12 +++++++----- main/config_ONOFF.h | 14 ++++++++------ main/config_RF.h | 38 ++++++++++++++++++++++++-------------- platformio.ini | 19 +++++++++++++++++++ 4 files changed, 58 insertions(+), 25 deletions(-) diff --git a/main/config_GPIOInput.h b/main/config_GPIOInput.h index edb1939..04f5b67 100644 --- a/main/config_GPIOInput.h +++ b/main/config_GPIOInput.h @@ -34,10 +34,12 @@ extern void GPIOInputtoMQTT(); #define GPIOInputDebounceDelay 60 //debounce time, increase if there are issues /*-------------------PIN DEFINITIONS----------------------*/ -#if defined(ESP8266) || defined(ESP32) - #define GPIOInput_PIN 14 -#else - #define GPIOInput_PIN 7 +#ifndef GPIOInput_PIN + #if defined(ESP8266) || defined(ESP32) + #define GPIOInput_PIN 14 + #else + #define GPIOInput_PIN 7 + #endif #endif -#endif \ No newline at end of file +#endif diff --git a/main/config_ONOFF.h b/main/config_ONOFF.h index 55b665e..4545882 100644 --- a/main/config_ONOFF.h +++ b/main/config_ONOFF.h @@ -35,12 +35,14 @@ extern void MQTTtoONOFF(char * topicOri, JsonObject& RFdata); #define subjectGTWONOFFtoMQTT Base_Topic Gateway_Name "/ONOFFtoMQTT" /*-------------------PIN DEFINITIONS----------------------*/ -#ifdef ESP8266 - #define ACTUATOR_ONOFF_PIN 15 //12 for sonoff basic relay -#elif ESP32 - #define ACTUATOR_ONOFF_PIN 15 -#else - #define ACTUATOR_ONOFF_PIN 13 +#ifndef ACTUATOR_ONOFF_PIN + #ifdef ESP8266 + #define ACTUATOR_ONOFF_PIN 15 //12 for sonoff basic relay + #elif ESP32 + #define ACTUATOR_ONOFF_PIN 15 + #else + #define ACTUATOR_ONOFF_PIN 13 + #endif #endif #endif \ No newline at end of file diff --git a/main/config_RF.h b/main/config_RF.h index 93122b5..2029fec 100644 --- a/main/config_RF.h +++ b/main/config_RF.h @@ -91,20 +91,30 @@ RF supported protocols #define repeatPilightwMQTT false // do we repeat a received signal by using mqtt with Pilight gateway /*-------------------PIN DEFINITIONS----------------------*/ -#ifdef ESP8266 - #define RF_RECEIVER_PIN 0 // D3 on nodemcu // put 4 with rf bridge direct mod - #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 -#elif ESP32 - #define RF_RECEIVER_PIN 27 // D27 on DOIT ESP32 - #define RF_EMITTER_PIN 12 // D12 on DOIT ESP32 -#elif __AVR_ATmega2560__ - #define RF_RECEIVER_PIN 1 //1 = D3 on mega - #define RF_EMITTER_PIN 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 IRremote/boarddefs.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 +#ifndef RF_RECEIVER_PIN + #ifdef ESP8266 + #define RF_RECEIVER_PIN 0 // D3 on nodemcu // put 4 with rf bridge direct mod + #elif ESP32 + #define RF_RECEIVER_PIN 27 // D27 on DOIT ESP32 + #elif __AVR_ATmega2560__ + #define RF_RECEIVER_PIN 1 //1 = D3 on mega + #else + #define RF_RECEIVER_PIN 1 //1 = D3 on arduino + #endif +#endif + +#ifndef RF_EMITTER_PIN + #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 + #elif ESP32 + #define RF_EMITTER_PIN 12 // D12 on DOIT ESP32 + #elif __AVR_ATmega2560__ + #define RF_EMITTER_PIN 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 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 + #endif #endif #endif \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 21907e4..f57c209 100644 --- a/platformio.ini +++ b/platformio.ini @@ -22,6 +22,7 @@ extra_configs = ;you can also adapt the modules by removing the corresponding lines in the env detail ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;default_envs = sonoff-basic-rfr3 ;default_envs = rfbridge ;default_envs = esp32dev-all ;default_envs = esp32dev-rf @@ -299,6 +300,24 @@ build_flags = '-DGateway_Name="OpenMQTTGateway_ESP8266_RF"' board_build.flash_mode = dout +[env:sonoff-basic-rfr3] +platform = ${com.esp8266_platform} +board = esp8285 +lib_deps = + ${com-esp.lib_deps} + ${libraries.rc-switch} + ${libraries.esp8266_mdns} +build_flags = + ${com-esp.build_flags} + '-DZactuatorONOFF="ONOFF"' + '-DZsensorGPIOInput="GPIOInput"' + '-DACTUATOR_ONOFF_PIN=12' + '-DGPIOInput_PIN=0' + '-DRF_RECEIVER_PIN=4' + '-DZgatewayRF="RF"' + '-DGateway_Name="OpenMQTTGateway_SONOFF_BASIC_RFR3"' +board_build.flash_mode = dout + [env:atmega-all] platform = ${com.atmelavr_platform} board = megaatmega2560