Sonoff (with ESP8266) modified firmware

Hi everybody!

I bought sonoff modules (electrical relay modules with ESP8266)
With the original firmware i couldn’t do what i want (for example use domoticz) so i decided to flash the original firmware with another that i found here

I used the “BasicOTARelay.ino” witch allow me to control Sonoff with MQTT messages.
But my problem is if I have a wifi issues, i can’t control anything. So I would like to use th switch button (integrated on the module on GPIO0) to turn ON/OFF the relay and the LED. I tempted to modify the *.ino code with function “INPUT_PULLUP” in program’s loop but Sonoff doesn’t receive MQTT messages anymore…

I’m not very strong in programming, and i’m sure that the solution is near, and i need some help.
You will find in attached “BasicOTARelayTV (original).ino” with witch MQTT messages are OK but the integrated button isn’t active and “BasicOTARelayTV (original).ino” with witch i can activate LED and relay with integrated button, but MQTT messages doesn’t work anymore. (maybe the loop blind sequence with MQTT…)

Thanks in advance for your help


BasicOTARelayTV (original).ino (4.34 KB)

BasicOTARelayTV (modified).ino (5.31 KB)

It appears that you recently flashed a Sonoff. I tried to do the same, but not successful yet.
Can you confirm that this recently worked?

The Netherlands

Not sure if You fixed it.
– Don’t use delay in your code, arduino code will freeze and do nothing but wait for Your code in that time.
Use timer functions like milis to trigger your code when needed

This is an example on Your code

BasicOTARelayTV (modified 2).ino (5.62 KB)