[OBSOLETE] Sonoff, Sonoff TH, S20, Dual, 4CH, POW, & Touch Device Handler & SmartApp ($5 & $10 Smart Switches)

UPDATE: Fixed: (Sonoff T1 US 2 and 3 gang)
Looks like i have 2 edit in “my Devices” and assign and mod the type to be “Sonoff 4ch wifi switch”. it doesn’t do it automatically.

now have 4 devices (1 parent, 4 Childs, deleted the last unused child) and can now control each relay individually as well as master control

Also, odd that flashing the 2 and 3 requires 2 different procedure (though no more soldering, just use your dexterity talent). (esp or nodemcu at 74880 is fine)
2 port - let it boot, hold touch button 1 (left most, then press momentary switch briefly and release both, wifi indicator will stop blinking)
3 port - let it boot, hold touch button 3 (Right most, then press momentary switch briefly and release both, wifi indicator will stop blinking)

hope this helps.

Yes! Please do! Have you had any success adding the “Toggle/Momentary” option? That would work great for garage/gate openers… Thanks loads great work!

how to flash sonoff T1 US 2 or 3 gang? please share device handle.

Thanks to erocm123, use his 4ch dh and child dh


Experimented with S31, looks like the basic Sonoff bin works but no pow monitoring. Its a pain to flash, since the pads don’t have holes (I used tape and get to practice my dexterity abilities), flashes the same way as the basic too. Looks like a more finished product than the s20 and should be better when the pow mon works.

1 Like

I’ve already modified Sonoff Basic with wired magnetic sensor connected to GPIO14.
I would like to be able to use it as momentary switch with door open/close status, something similar like Mimolite

Device Handler for Mimolite is here: https://github.com/fortrezz/smartthings
Documentation: http://www.homecontrols.com/homecontrols/products/pdfs/FZ-FortrezZ/FZMIMO2US-Guide-with-SmartThings.pdf


or even to controll two garage doors

is there any firmware of DeviceHandler or SmartApp available with that feature ?

1 Like

What do you use? Sonoff4CH.ino.generic.bin or SonoffTouch.ino.generic.bin

on top of this page, there is a link provided by erocm1231. use the dh, smartapp and child handler.

2017_05_10 Update: Sonoff Dual - Firmware 769 and device handler 553 and child device handler 333. Flashing info here. Sonoff 4CH - Firmware 300 and device handler 236 and child device handler 333. delete unused relay in the smartapp, i flashed 8 without soldering and they work well.

use esptool (change your com port)

esptool.exe -vv -cd nodemcu -cb 74880 -cp COM4 -ca 0x00000 -cf Sonoff4CH.ino.generic.bin

or use nodemcu (instructions) are on top of this page also, change the 74480 speed.

hope it helps

1 Like

Hello, now for some month i play with the TH, TO, Basic & Dual. When my WLAN is off, the TO,TH & Basic try to connect to another WLAN (ist it open, they connect to them :frowning_face:). Only Power/off-on let they connect to the configured WLAN. Is there a workaround for this issue? Or is it an old FW. Where can i check the versions?

Hi, any chance that you could do a device handler for iFan02? https://www.itead.cc/sonoff-ifan02-wifi-smart-ceiling-fan-with-light.html

I’m pretty sure that has been in there for a while. :wink:

Hi, I’ve been trying to flash a Sonoff TH10 with the firmware in the original post (SonoffTH). The flashing appears to be successful but the Sonoff then becomes unresponsive. No flashing from the lights and no wifi hotspot appears.

I can reflash the original firmware and it seems to become responsive again, other firmware for other smart integrations also appear to flash successfully.

Any idea what’s going wrong? I’ve attempted the flash 10-20 times now. Exact same response each time.

Firstly thank you all for being such a supporting community. I have successfully accomplished all of my sonoff automation tasks and it’s been stable.
Now you all know there are always more projects that come up randomly…
So I need some help with a certain project involving a skylight window with a idle, up and down wall switch.
This is similar to shutter control but it uses mains power and not 12/24v.
After having some thoughts I think I can accomplish this using a sonoff dual with auto switch off by adjusting the timing in the configuration.
However there is one big issue. I don’t want the state of both relays to be switched on at the same time.
Both can be idle and if one is on the other must always remain off and visa versa.
This should be something like an interlocking mode which should make it impossible to have both buttons “on” in the same time
Any thoughts or suggestions around this.

Try it with a virtual switch. In Smarthings make a virtual switch with the different states of the sonoff. When virt.Switch on, Sonoff sw1 goes on and sonoffsw2 off, if virt.Switch off, Sonoff vise versa


Hello, flashed the sonoff switches with the aktual FW, sometimes the sonoff give no response, but they are via IP-Adress reachable and i can controll them. Any Ideas? Befor i update the FW, the TH works fine, after update, i have the issues.


Thanks for the input Mike.
I did think of this but I will be using the gpio pin headers for physical wall switches (bypass smartthings if internet is down).
This means that I can have a chance of simentaneous activation if I toggle up and down consecutively.
What I might be asking for is an interlocking option in the firmware for the button configuration.
Maybe @erocm1231 Eric might have come across any implementation for the sonoff duals.

me too, any body help?

Hi @erocm1231

Having a few issues with a pair of Sonoffs running your firmware and think you might be able to add something to the FW to help out if possible? Basically two sonoffs control a circuit of exterior lighting each and the sonoffs are connected via GPIO14 to a normal toggle light switch in the house. The sonoffs are in a junction box about 5m (cable length) from the switches. I have beefed up the pullup resister on the GPIO but on occasion when I switch one circuit on or off the other switches too. I’m guessing this is because of a small amount of EMI cross talk between the long wires on the GPIO pins and the fact they run parallel etc.

Anyway is it possible to add an adjustable debounce to the switch input? Either in ms or a low/med/high type option? I can live with a slight delay (even 1s) in the switch input for a more reliable switching experience. Happy for it to be in the web gui only :slight_smile:


Ignore me, just updated the FW and I see the option is there now :slight_smile:

You da man!


Me again. So the debounce makes things better but not perfect. I think the issue is caused more by the close proximity of the two sonoffs to each other as all was fine until I put them back inside the junction box. Now any switching (local or remote) of one sonoff seems to trigger the other one about 30% of the time.

I think adding a small capacitor to the switch lines might help, but I’m at our holiday home and don’t have any parts with me and they aren’t exactly easy to source around here.

I’m wondering if a pre-debounce would be an option - with a delay before switching the relay. My thinking is something along the lines of

  if (!digitalRead(14)) {
    delay(200); // pre delay
      if (!digitalRead(14)) { // confirm switch is still on
      //do action

Obviously needs adjusting to work with toggle/momentary switches etc and fitting into your code.