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
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:
- 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.
- 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?
Hi HA_fan
I’ve not had the first problem that you describe, but number 2 does sound very familiar. I know what you mean about it seeming like MQTT lag as there is a slight lag even when it works, but of course MQTT should not come in to play here as the switching is being done from within the firmware. You are right that sometimes it seems like the failed switching attempts are grouped, i.e. that it can work fine 20 times then all of a sudden 5 times in a row it will fail.
Im afraid im not clued up enough to advise on how a resistor or capacitor might fix the problem, but I did carry out the experiment above on Rudie’s advice although I’m not sure if it is any help to you.
The only thing i can think of is to replace my standard lighting cable with shielded speaker cable in case that is the problem.
Cint
Thanks for replying!
In my case, the cables between S1 / S2 are no longer than 5 cm each, so I am afraid changing the cables isn’t going to fix it the ghost switching.
The lag is strange. I might change the mini for another one, to see if it is just the device which is detective.
If you end up solving this puzzle, please let me know. I will note my updates here too.
No problem, by the way I did also try another mini, but had the same problem.
The resistor between 3V and GPIO is a Pull-up. It should not he necessary based on Cint’s test (that seems to indicate there is already a pull-up in the circuit) but can’t hurt to try. The capacitor between gpio and gnd is to debounce the switch. This is worth a shot if you get multiple triggers caused by the contacts bouncing. You can put a cap over the switch contacts on the wall plate side saving you having to open the mini in the ceiling.
I’m officially out of ideas for the erratic behaviour. Multiple triggers can be explained but a switch that sometimes works and sometimes doesn’t is beyond my skills. It would be great to have a oscilloscope on gpio to see what’s happening.
Maybe try the shielded audio cable next and let us know if anything changes.
Rudie
I replaced the sonoff mini with another one. Same behaviour… I upgraded all the sonoffs to Tasmota a few days ago. The original ewelink software didn’t cause this lag and/or ghost switching. I am starting to believe it is related to tasmota. How is this possible… I don’t want to go back to ewelink though
You could give esphome a go and see if problem exists with that?
They used to tell me never trust a programmer with a screwdriver!
Umm I find this whole discussion very interesting.
My story is that I run a little AirBnB (granny flat) on my property. The main house is constructed in such a way that ANY wiring is very difficult to do/hide (redwood clad walls Etc.) I initially wanted a simple way of knowing when the hot water service was in use so that I could avoid using the washing machine Etc. when guests were in the shower - my old Rheem system didn’t have a wireless remote control unit. As such, the the normal remote units were not that practical as they use fixed wiring and the signals are not readily decoded. My solution was to install a flow switch on the inlet pipe of the heater and use the switch to operate S1,S2 on a Sonoff Mini. The mini doesn’t actually do anything other than triggering an automation in Home Assistant when turning on and off. Because it does this I can use any number of other Sonoff Basics around the place to turn on their LED’s when triggered. Again as such, the Mini acts like a broadcaster and the remote units act like receivers and light up. The whole system works fantastically and because S1,S2 are 3.3v it’s almost decoupled from the hot-water service. In fact, the flow switch is plastic… So all good and works well with the Sonoff Mini about 1m from the hot water service. I’ve got these in three bathrooms, kitchen, laundry Etc.
My second project was to try to improve my commercial wireless doorbell system to stop it going off when guests arrive at 02:00am next door Etc. or after power failure’s where it would seem to latch onto the frequency that is first used nearby. For this project I already had a wired 12V doorbell from the street into the house that would then operate various receivers in the house, shed Etc. This seemed like a good candidate for the the same strategy Eg. use the doorbell button press to connect to S1,S2 and then use triggers to operate various ding-dong appliances that were on my network.
Now what I found is that the length of the cable from the pushbutton into the house makes the the Sonoff Mini oscillate crazily. It’s not quietly “ghosting” but rather going crazy. If I put a simple switch onto S1,S2 with negligible wiring it’s fine. I assume therefore that the cable I’m using for my doorbell is profoundly influenced by nearby 12V, 240V Etc. The cable is of course old telephone cable. I thus conclude that because the Mini has 3.3V on GPIO4 that it very prone to induction, interference and other stuff if the cable is anything other than short, well-shielded and possibly twisted.
If you have any ideas how I might fix this problem I’d be grateful. Is a low pass filter the answer? If so how does it get wired on a Mini as I’m just a newbie.
Cheers All
PS Using Home Assistant and ESPHome
I ended up doing a klutzy work-around for my specific issue. To close S1/S2 I used a solid state relay. That worked fine as the wires were only 15cms long. To operate the relay I converted the the old doorbell system from passive to active by squirting 5v down the line from an old phone charger. Looking back the Mini was a bad choice because it is VERY SENSITIVE to induction issues. I only used it because it had an on/off switch already exposed. I’ll probably redo this with a ESP-01S and daughter Relay Board at some stage in the future. So my experience with the Mini is mixed. The first project was a dream the second showed that is a bit less than “Nearly Perfect”
Mmm. You might be onto something here jmann! Maybe Cint’s problem could be explained by a noisy induced signal drowning out the 3v signal. Once in a while the 3v might win and switch and them seem erratic. This is the opposite of the induced signal creating false triggers but is a theory that could be explored.
The passive approach sounds like a plan… switch a relay in the attic next to the mini with the wall switch and switch the mini with the relay contacts. Or put some more serious filtering on the line and mini input. My analog skills are unfortunately to a standard to give you proper advice on how.
Rudie
Forgot to add that perhaps the Ewelink firmware has beter software de-bounce or filtering than Tasmota. ESPHome is nice in that sense that it gives you full control over debounce, delays and filters so there might be a software solution after all.
Hi, did anyone get to the bottom of this? I have a simple switch with a series of downlights. The s1 and s2 are rigged up to a physical switch. Sometimes it works. Sometimes it doesn’t. I’ve tried the capacitor idea, but still no use.
The issue seems to be more of a problem if I’ve turned the lights on with Alexa, they then won’t turn off with the physical switch.
Any support would be really well received. It’s driving me mad (and my wife now hates the fact I’ve rigged the house up with sonoffs).
Thanks,
Andy
I changed the bulb, from an old CFL energy saving type to an LED and it seems to have improved the performance a lot, maybe from working 75% of the time to working 95% of the time, and being a lot quicker to respond. Not sure why, or why it still occasionally fails but its so rare now it has stopped bothering me and my wife has not even complained