My Sonoff Mini hardware switch is unreliable

Hi

Ive recently managed to get ahold of some sonoff minis, and I flashed with Tasmota following the excellent guide here on Superhouse. Only problem I have is now that it is installed using my existing light switch as a toggle - it seems very unreliable - sometimes I try to turn it on or off and nothing happens. I can toggle the switch 7-8 times and it does not register with the device. It seems to happen if you try to turn it on and off a few times in quick succession, but it also sometimes just happens out of the blue.

Any ideas on what i can try to fix it?

Cheers!
Cint

Hi Cint!

So far I haven’t seen any reliability issues with the Mini, but perhaps I’ve been lucky.

Do you have them linked to any sort of home automation controller, such as OpenHAB, Node-RED, Home Assistant, etc? Do they respond reliably if you control them via the network?

Yes I have it hooked up to Node-Red using MQTT and that works well. I also have a debug output on the sonoff’s stat/# topic and if I view this while toggling the switch I get no output when the problem occurs. When the switch works I see “ON” or “OFF” in the logs.

That sounds like an electrical problem with the switch. Can you disconnect the switch from the Mini (for safety) and check continuity through the switch when you flip it? Does it behave consistently?

Hi Jon

Ive just been up and tested the continuity of the switch from the sonoff ends of the switch wire and it seems perfect. Could it be anything to do with the length or type of the cable? Its just standard UK lighting cable though, nothing unusual.

Cheers
Cint

Ive just experimented with the same switch and sonoff. But this time attached with a 20cm switch cable and it seems to work perfectly, I can switch it on and off 20-30 times no problem.

Interesting. I didn’t think to ask how long the cable is, because I assumed it was directly behind the switch.

The external switch is wired to a 3.3V logic input on the microcontroller, so if the wire is long it could have problems with electrical noise. This would be especially bad if the cable goes near wires that are carrying mains voltage.

How long is the cable?

Ah right! The cable is about 3-4m long, I had to put my sonoff up in the loft as there is no neutral at the switch.

It also runs pretty close to the 240V cabling so I can try to create some clearance and see if it helps.

Cheers!
Cint

I’d love to hear the outcome of this :slight_smile:

Hi Jon

I finally managed to get around to separating the cables a bit yesterday, so they have about 50mm between them now. No problems so far but Ill monitor it for a few days any post here once I know how successful it was. By the way, have you made any progress on producing the programming board for the Sonoff mini?

I’ve made one, but the design is likely to change now that I’m working on a standardised header for ESPxx programmers. Auto-reset works perfectly and I’m fairly happy with how it came out.

Most of the PCB will be fine, I just need to update the pinout on the programming header to match what I settle on for the programmer.

1 Like

Hi Jon

That is great I need to get one when available its too dodgy soldering onto those tiny pads!

Re my switch - it is still slightly unreliable maybe not as bad as before but still annoying. I can think of 2 fixes:

  1. Shield the wiring somehow
  2. Use 2 sonoffs - change my line in/line out light switch cable to a line/neutral, then use that to power another sonoff which only detects the toggling of the wall switch then publishes to mqtt. Then I can have a standard sonoff in the attic which does the actual light switching.

Cheers
Cint

1 Like

This is puzzling me. The problem is likely the resistance in the 4m wire (8m in total to the switch and back). Noise would cause false triggers and doesn’t explain a switch not working at all.

But even with very high resistance (let’s say crazy 100 ohms) the pull down will still be “stronger” than the (guessing >1K) pull-up in the Mini and should win… even over a long wire run.

But what of the Mini isn’t “weak pull-up”, with the switch pulling it low, but instead puts 3v on the one pin and expect to see 3v on the other side through the switch?.. like through an opto-coupler led maybe? In that case just a few ohms in the wire can drop the voltage to below the trigger voltage. That would be very weird design though and I would be surprised if they did that.

One thing to try is to put a potentiometer across the switch pins on the Mini side and “tune” it to a level where the switch reliably triggers the input. This is “floating” the input though and now you might see false triggers caused by noise. It will be interesting to know at what resistance the Mini triggers… turn the pot until it triggers and measure the resistance over the pot (disconnected)

I’m really curious what you find.

Rudie

1 Like

That’s a really interesting theory to test. If you do it, please post the results here. Otherwise I may have a go at it.

Thanks Rudie

I half understand what you are saying I think (I’m a software developer, just learning electronics). Will give this a go when I can and get back to you!

Cheers
Cint

Still curious about this… Did separating the wires do the trick in the end?

I don’t have a Mini yet but would love to know if the length of the cable has any influence on the switch. I also have a few “far from neutral” situations.

Rudie

Hi Guys

Sorry this took so long to get done been unbelievably busy with work :frowning:

I had an experiment with the switch cable like you suggested, so i removed my light switch from the ends of the switch cable and plugged the two ends into a breadboard with a potentiometer attached. With the light initially off, i lowered the resistance till the point the son off was triggered then found the rough switching resistance by fine tuning it to the point it switched on and off.

I took the switch cables away and measured the resistance across the potentiometer and it read 5.88Kohm (see attached image)

Does this mean anything to you, any suggestion on how i can use this info to improve the switching?

Cheers!


Cint

Hi Cint,

Happy new year to you!

If it switches at 5K it will certainly switch at lower resistance so my theory about the 3V drop is out the window.

Did you test the wall switch itself? If it is old maybe it has oxidised contacts and doesn’t like to switch the low voltages anymore. Easiest test is to use another switch on you breadboard or replace the wall switch and see if things improve. Process of elimination unfortunately.

Rudie

Finally, I am not the only one! I’ve been experiencing the same behaviour. But even more issues. Flashed 8 sonoff mini’s with tasmota. Connected wall switches to all of them (between S1 and S2). On one sonoff mini weird stuff is happening.

Two problems I am experiencing:

  1. Ghostswitching happens at random moments. Light will turn on/off randomly every second and it doesn’t stop untill I flip the physical switch connected between S1/S2. So this is not a “retain setting” issue (the - totally unrelated with this issue - magical solution when looking it up on Google). My wifi signal is 98% and stays connected, so no retain issues.
  2. Flipping the switch sometimes doesn’t work. I can flip it 6 times and the sonoff mini doesn’t toggle. Feels like an MQTT lag. Sometimes it just works as it is supposed to. Very strange behaviour.

Possible solution for problem number 1? I found online (sonoff basic with tasmota had the same ghost switching issues) that it would be solved by soldering a resistor + capacitor between 3v3 / gpio / ground. Is this a solution for the Sonoff mini too?

What about problem number 2? Any luck yet? Would this “resistor / capacitor” trick also solve that problem?!

See schematic:
27986203-a6668b82-642e-11e7-90bf-a5602a746225__01|685x397

Edit: it just happened again (ghost switching). Here’s the log.

11:31:30 MQT: sonoffschwoonkamer/stat/SWITCH1 = {“STATE”:“TOGGLE”}
11:31:30 MQT: sonoffschwoonkamer/tele/STATE = {“Time”:“2020-01-03T11:31:30”,“Uptime”:“0T11:43:51”,“UptimeSec”:42231,“Heap”:24,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“MqttCount”:1,“POWER”:“ON”,“Wifi”:{“AP”:1,“SSId”:“Nanox2.4G”,“BSSId”:“C8:54:4B:95:4B:A1”,“Channel”:6,“RSSI”:100,“Signal”:-47,“LinkCount”:1,“Downtime”:“0T00:00:06”}}
11:31:30 MQT: sonoffschwoonkamer/stat/RESULT = {“POWER”:“ON”}
11:31:30 MQT: sonoffschwoonkamer/stat/POWER = ON
11:31:30 MQT: sonoffschwoonkamer/stat/SWITCH1 = {“STATE”:“TOGGLE”}
11:31:30 MQT: sonoffschwoonkamer/tele/STATE = {“Time”:“2020-01-03T11:31:30”,“Uptime”:“0T11:43:51”,“UptimeSec”:42231,“Heap”:24,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:21,“MqttCount”:1,“POWER”:“OFF”,“Wifi”:{“AP”:1,“SSId”:“Nanox2.4G”,“BSSId”:“C8:54:4B:95:4B:A1”,“Channel”:6,“RSSI”:100,“Signal”:-48,“LinkCount”:1,“Downtime”:“0T00:00:06”}}
11:31:30 MQT: sonoffschwoonkamer/stat/RESULT = {“POWER”:“OFF”}
11:31:30 MQT: sonoffschwoonkamer/stat/POWER = OFF
11:31:30 MQT: sonoffschwoonkamer/stat/SWITCH1 = {“STATE”:“TOGGLE”}
11:31:30 MQT: sonoffschwoonkamer/tele/STATE = {“Time”:“2020-01-03T11:31:30”,“Uptime”:“0T11:43:51”,“UptimeSec”:42231,“Heap”:24,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:20,“MqttCount”:1,“POWER”:“ON”,“Wifi”:{“AP”:1,“SSId”:“Nanox2.4G”,“BSSId”:“C8:54:4B:95:4B:A1”,“Channel”:6,“RSSI”:100,“Signal”:-49,“LinkCount”:1,“Downtime”:“0T00:00:06”}}
11:31:30 MQT: sonoffschwoonkamer/stat/RESULT = {“POWER”:“ON”}
11:31:30 MQT: sonoffschwoonkamer/stat/POWER = ON
11:31:30 MQT: sonoffschwoonkamer/stat/SWITCH1 = {“STATE”:“TOGGLE”}
…
(Same pattern keeps on going)
…

Hi Rudie

The wall switch is pretty new, and i did test it with a shorter cable and seems to work perfectly. This makes me think it must be the length of the cable and a problem with interference?