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