Tasmota: Sonoff sometimes turns on / off by itself

Created on 8 Mar 2018  路  17Comments  路  Source: arendst/Tasmota

Sonoff basic with tasmota 5.12.0
GPIO14 wired to a toggle switch, wire length is 5cm
MQTT with home assistant

Sometimes my lights change state randomly, I suspect it might be noise on the gpio14. Since I'm using a toggle switch rather than a momentary switch can I just add a .3s delay on the gpio14 before the sonoff changes the relay to eliminate any interference?

Thanks
Mike

good tip

Most helpful comment

Thanks to this video i solved the problem.
Basically, it says to add a low pass RC filter. I used a 10kohm resistor and a 100nF=0.1uF ceramic capacitor.

@vaz83 i did it too a while ago, but i don't like to reinvent the wheel every time, Sonoff-Tasmota is a great firmware and has already been tested from a lot of users

All 17 comments

Change GPIO14 to NONE, then observe if it occurs again, if it occur again, check (from console) if MQTT connection is lost randomly, if your MQTT broker reconnect the relay status might change, it might be your broker is toggling your relay after reconnection due to "retained" topics. That's from my experience.

Thanks jnherm.
yeah i think you might be right, and I'll try that.
I read the wiki on PowerRetain PowerOnState etc and found it confusing.

I'd like the state of the switch to be stored on the sonoff.
I'd like MQTT to act as a messenger only.
I'd like HA to tell the sonoff to do something, but not store the state.
I think above is most reliable method.

Wasn't sure what I need to set, currently it's set to:

05:04:37 MQT: stat/sonoff.dining/RESULT = {"PowerRetain":"ON"}

05:04:40 MQT: stat/sonoff.dining/RESULT = {"PowerOnState":3}

and in home assistant:

mqtt:
broker: core-mosquitto

light:

  • platform: mqtt
    name: "Dining Room"
    state_topic: "stat/sonoff.dining/POWER"
    command_topic: "cmnd/sonoff.dining/POWER"
    availability_topic: "tele/sonoff.dining/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: true

If you're using GPIO14 with an external switch, this is almost mandatory:

  • Solder a 10k resistor (lower values also work, but more power consumption) between GPIO14 and 3.3V
  • Capacitor (100-500 pF) between GPIO14 and GND

If you still want to use the 4 serial pins, you have 3.3V and GND in other header, easier to solder:

https://camo.githubusercontent.com/f014130fdde36f97f37a5af20fc223621b192e1b/687474703a2f2f74696e6b65726d616e2e6361742f77702d636f6e74656e742f75706c6f6164732f323031362f30362f70696e6f75745f6261636b2e6a7067

I had the problem of lights randomly switching on and off and it was fixed with this.

Also, some kinds of lights can produce the sonoff to restart in my experience if they use ballast.

Hi

I caught the sonoff turning itself off. It seems to be MQTT.

08:29:08 MQT: Attempting connection...
08:29:08 MQT: Connect failed to 192.168.178.80:1883, rc -2. Retry in 10 sec
08:29:12 DNS: Initialized
08:29:15 WIF: Checking connection...
08:29:15 WIF: Connected
08:29:22 MQT: Attempting connection...
08:29:22 MQT: Connected
08:29:22 MQT: tele/sonoff.dining/LWT = Online (retained)
08:29:22 MQT: cmnd/sonoff.dining/POWER =
08:29:22 MQT: Subscribe to cmnd/sonoff.dining/#
08:29:22 MQT: Subscribe to cmnd/sonoffs/#
08:29:22 MQT: Subscribe to cmnd/DVES_73F286/#
08:29:24 RSL: Received Topic cmnd/sonoff.dining/POWER, Data Size 3, Data OFF
08:29:24 RSL: Group 0, Index 1, Command POWER, Data OFF
08:29:24 MQT: stat/sonoff.dining/RESULT = {"POWER":"OFF"}
08:29:24 MQT: stat/sonoff.dining/POWER = OFF (retained)

And it just turned off again without permission:

08:41:35 WIF: Checking connection...
08:41:35 WIF: Connected
08:41:44 MQT: tele/sonoff.dining/STATE = {"Time":"2018-03-15T08:41:44","Uptime":"7T22:10:20","Vcc":3.465,"POWER":"ON","Wifi":{"AP":2,"SSId":"Skynet 2.4ghz","RSSI":80,"APMac":"38:10:D5:B0:A2:B4"}}
08:41:44 MQT: tele/sonoff.dining/SENSOR = {"Time":"2018-03-15T08:41:44","Switch1":"ON"}
08:41:55 WIF: Checking connection...
08:41:55 WIF: Connected
08:42:09 MQT: Attempting connection...
08:42:09 MQT: Connected
08:42:09 MQT: tele/sonoff.dining/LWT = Online (retained)
08:42:09 MQT: cmnd/sonoff.dining/POWER =
08:42:09 MQT: Subscribe to cmnd/sonoff.dining/#
08:42:09 MQT: Subscribe to cmnd/sonoffs/#
08:42:09 MQT: Subscribe to cmnd/DVES_73F286/#
08:42:09 RSL: Received Topic cmnd/sonoff.dining/POWER, Data Size 3, Data OFF
08:42:09 RSL: Group 0, Index 1, Command POWER, Data OFF
08:42:09 MQT: stat/sonoff.dining/RESULT = {"POWER":"OFF"}
08:42:09 MQT: stat/sonoff.dining/POWER = OFF (retained)
08:42:10 CFG: Saved to flash at F4, Count 400, Bytes 1648
08:42:15 WIF: Checking connection...
08:42:15 WIF: Connected
08:42:35 WIF: Checking connection...
08:42:35 WIF: Connected

I also would like to know if it would be possible to have the toggle switch pushed for 3 sec. until the sonoff reacts. That would be also very helpful to prevent switching by mistake.
Thanks and regards from germany
Flo

Hi everyone! I have recently flashed a sonoff to add a external switch and added a 10k resistor from GPIO14 to +3.3v, and a 100pF capacitor between GPIO14 and GND. the length of the wires to the switch is about 1,5 meters, and from time to time i still get the light turning on and of by itself. Can anyone help me out on what should i do more? I have read everything i could regarding this issue but haven't found a solution yet.

Any update on this? I've the same problem.

I have solved the problem by software. I listen to the input for 100ms, and if there are no glitches on that time only then I turn the light on. It has fixed all the problems I had

What is the name of the option?

It鈥檚 not an option, I have made my own firmware :)

Thanks to this video i solved the problem.
Basically, it says to add a low pass RC filter. I used a 10kohm resistor and a 100nF=0.1uF ceramic capacitor.

@vaz83 i did it too a while ago, but i don't like to reinvent the wheel every time, Sonoff-Tasmota is a great firmware and has already been tested from a lot of users

Thanks for share your solution to the ghost switching.

Closing this issue. Please, ask to reopen if needed. Thanks.

It鈥檚 not an option, I have made my own firmware 馃憤
Can you share the file or files you modified?

The 100 pf cap is not enough. Try a .1 mfd capacitor to ground. Very small ones are available on Ebay.
The higher the value of the capacitor, the more "noise" will be filtered out. What is happening is that electrical noise is triggering the input. The module can detect signals of less that 1 microsecond. So you need all the capacitance that is available. .1 mfd is the optimal value for this application.

@willyk0 @vaz83 @fttx @JimInWoodstock Hey I am trying to use a PIR sensor (AM312 mini) and a manual regular wall switch with Sonoff Basic using GPIO1 and GPIO3 with Serial Logging off.

I seem to face these random switching issues randomly. Sometimes no problem for a week, sometimes happens every day. When it happens (it's constant back and fort)

Sometimes it's the PIR sensor that constantly triggers, sometimes it's the manual switch.

Kind of don't know what to do. There are so many different solutions out there. I have material for none so will be ordering anyway, so wanted your opinion on how to approach this.

Options:

  1. Just a resistance (seems like you can use any but 4k7 is recommended).
  2. Low-pass filter with any resistance and 33pF capacitor (this is the component I am having a hard time finding, especially with the weird conversion units pF uF nF what not)
  3. Shielded twisted wires (probably just use the ethernet cable I have lying around?)
  4. Some kind of aluminum foil b/w sensor and esp8266 chip (have no clue how to get this done, someone mentioned need for grounding the foil + making sure not to short things or something)
  5. ALL of the above.

Basic goal is just to have a reliable PIR sensor without false triggers.

The other question to my situation is do I need this "Low-pass R-C filter" for both the PIR sensor and the regular wall switch?

Thanks in anticipation.

Was this page helpful?
0 / 5 - 0 ratings