Sonoff basic keeps switching from GPIO14

1,428 views
Skip to first unread message

Dries Dokter

unread,
Mar 10, 2017, 3:08:25 AM3/10/17
to SonoffUsers
Hello,

I have 2 sonoff basics, both used in the same way: switch connected to GPIO14, zo I can have a nice "Button" on the wall and hide the Sonoff somewhere.
Both buttons are pushbuttons. one of them works just fine, the other has very erratic behaviour, as if it is picking up static ..

I have 2 wires connected to GPIO14 and GND (Pin5 and Pin4), the moment I configure GPIO14 for use with this pushbutton, the sonoff starts toggling power but no one pressed the button.If I do press the button it toggles as it should (but switches of right after that, and on etc)
It is completely random the times between switching. But when I disconnect the wires from Pin4 and Pin5 the behaviour stops..

I was lead to believe that GPIO14 has it's own pull up resistor and this does work fine on the other sonoff (where the wire between sonoff and switch is much longer).
I have already swapped the sonoff (same behaviour), using a multimeter, the switch is only shortcut when I push it...

Any suggestions?

Dries Dokter

unread,
Mar 10, 2017, 3:12:54 AM3/10/17
to SonoffUsers
09:10:23 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:25 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:26 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:28 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:28 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:29 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:29 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:36 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:36 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:39 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:40 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:42 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:42 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:45 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:45 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:54 MQTT: cmnd/halknop/POWER1 = TOGGLE
09:10:54 MQTT: cmnd/halknop/POWER1 = TOGGLE

David Lang

unread,
Mar 10, 2017, 3:23:52 AM3/10/17
to Dries Dokter, SonoffUsers
This does sound like a missing pull-up resister, try putting one on the switch
and see if it stabilizes it.

David Lang

Pǝtǝr FlCKlNGER

unread,
Mar 14, 2017, 3:33:29 PM3/14/17
to SonoffUsers, dries....@gmail.com, da...@lang.hm
What kind of resistor should do you mean, David? Can you recommend a value? Is it to connect in series to the switch, or parallel?

Thanks!
Peter

David Lang

unread,
Mar 14, 2017, 5:42:18 PM3/14/17
to Pǝtǝr FlCKlNGER, SonoffUsers, dries....@gmail.com
On Tue, 14 Mar 2017, Pǝtǝr FlCKlNGER wrote:

> What kind of resistor should do you mean, David? Can you recommend a value?
> Is it to connect in series to the switch, or parallel?

If you are connecting a switch to ground, you would connect a 5-10K resister
from the pin to vcc so that when the switch is not turned on, the pin is
reliably high.

This should not be needed (the esp8266 is supposed to be doing this internally),
but we've seen some reports of some systems where this helped.

there have also been reports of cold solder joints on some modules that caused
them to be flaky

David Lang

David Lang

unread,
Mar 14, 2017, 5:44:51 PM3/14/17
to Pǝtǝr FlCKlNGER, SonoffUsers, dries....@gmail.com
as you noted elsewhere, noise picked up by the wires can also cause grief, and a
small capacitor from the pin to ground can help reduce it.

David Lang

Dario Silva Moran

unread,
Mar 14, 2017, 9:37:17 PM3/14/17
to SonoffUsers, p.fic...@googlemail.com, dries....@gmail.com, da...@lang.hm
I've posted a similar issue here.
I'm wondering if it is there an ultimate solution that combines the capacitor and/or resistor to guarantee the proper behavior of switch or a push button connected to GND and CPIO14

David Lang

unread,
Mar 14, 2017, 10:10:50 PM3/14/17
to Dario Silva Moran, SonoffUsers, p.fic...@googlemail.com, dries....@gmail.com
well, there are lots of things you can do to reduce noise on a switch, and it
usually doesn't make sensse to do them all.

pull-up resisters (should not be needed as this is built-in on the ESP-8266)

shielded wires to the switch (with the shield grounded), twisted pairs.

route the wires so that they are not in parallel with high voltage signals

capacitor to route high speed signals (probable interference for a switch) to
ground, which distorts the switch signal, but should not matter much when we are
talking switches being operated by humans

On Tue, 14 Mar 2017, Dario Silva Moran wrote:

> I've posted a similar issue here
> <https://groups.google.com/forum/#!topic/sonoffusers/uhcrcgspJYI>.

Dario Silva Moran

unread,
Mar 15, 2017, 6:49:44 PM3/15/17
to SonoffUsers, dar...@gmail.com, p.fic...@googlemail.com, dries....@gmail.com, da...@lang.hm
Hello and thanks for your suggestions.
I started with the shielded cable, connecting one end of the stripped internal ground wire between the switch screw and the metal frame of the lamp, hopping to achieve a proper ground. There were no improvements whatsoever. 
I'm attaching some pictures.
20170315_161510.jpg
20170315_161531.jpg
20170315_161841.jpg
20170315_193655.jpg

Dries Dokter

unread,
Apr 2, 2017, 7:54:49 AM4/2/17
to SonoffUsers
I solved my problem by using shielded cable connecting the shield (and 1 signal wire) to GND of the sonoff. Pull-up resistors (of 4k7) reduced the static a lot but still the light would switch by itself..

Cheers,

Dries

Simon Maddox

unread,
Apr 4, 2017, 5:50:53 AM4/4/17
to SonoffUsers
The longer the cable distance, the lower the pullup resistor should be. A 470R is not out of the question - it puts an extra 10mA load on the power supply while the button is pressed, but the power supply will cope with that. Additionally, a 100nF capacitor across the switch should clean things up.

Ruben Tavares

unread,
Apr 6, 2017, 6:52:44 AM4/6/17
to SonoffUsers
Having a similar problem, i have a +/-2meter long UTP cable from the sonoff to the wall switch, connected on GPIO14 and RX pin, both have 10k pull-up resistors, but only the RX pin is giving me erratic behavior. maybe i forgot to turn something off, i know i turned off serial logs. But maybe theres a extra step to use the RX and TX pins without problems?
Maybe i have to use a lower resistance or/and a capacitor? but then the cable connected to GPIO14 should be showing erratic behaviour also, and so far it has worked fine.

Dario Silva Moran

unread,
Jun 25, 2017, 9:31:44 PM6/25/17
to SonoffUsers, dar...@gmail.com, p.fic...@googlemail.com, dries....@gmail.com, da...@lang.hm
Hi again, back with the on/off self trigger issue. Adding a 10k pullup resistor to GPIO14 solved the issue for a 0.1M shielded cable, which I used in two sonoff modules. Works perfect.
But I have another two modules, in a ceiling lamp, about 3Mts away from the wall switch, so I had to install a longer cable between the wall box and the lamp (where the sonoffs are installed). The problem with these two is that self on/off trigger persists, not very often but they are certainly happening.
I should mention that the signal cable is alongside with main power (220v), I can't avoid that since there is only one conduit.

I've read that the longer the cable, the lower the resistor should be (<10k). Do you have any suggestion about the value? I've never installed the capacitor, though.

David Lang

unread,
Jun 25, 2017, 9:40:56 PM6/25/17
to Dario Silva Moran, SonoffUsers, p.fic...@googlemail.com, dries....@gmail.com
sorry, no suggestions on the values to use. My understanding is that they aren't
that critical. I see a lot of people using 10k resistors and a lot using 3.3k or
4.7k resistors. I think this is just a matter of common sizes that they happen
to have on hand.

If going with a longer wire starts causing it to trigger on it's own, I'd add a
capacitor before worrying about changing the resistory size.

David Lang


On Sun, 25 Jun 2017, Dario Silva Moran wrote:

> Date: Sun, 25 Jun 2017 18:31:44 -0700 (PDT)
> From: Dario Silva Moran <dar...@gmail.com>
> To: SonoffUsers <sonof...@googlegroups.com>
> Cc: dar...@gmail.com, p.fic...@googlemail.com, dries....@gmail.com,
> da...@lang.hm
> Subject: Re: Sonoff basic keeps switching from GPIO14

Brad Cole

unread,
Nov 24, 2017, 2:12:46 PM11/24/17
to SonoffUsers
I have a similar configuration, and experienced the same problem. I noticed that when I disconnected the wall switch from the I/O pin, the random switching stopped, so my conclusion was that there was noise being introduced on the control line that was triggering the relay. To filter this line, I put a 47nF cap from pin 14 to ground. This seems to have cured the problem.

Aaron Newcomb

unread,
Nov 28, 2017, 3:49:43 AM11/28/17
to SonoffUsers
I can confirm that adding a small cap between GPIO14 and GND fixed it for me as well. I used 33nF. I removed my pullup resistor and used the internal pullup in my code.

Vitor Dalto

unread,
Dec 12, 2017, 2:00:05 PM12/12/17
to SonoffUsers
Aaron and Brad
Could you please send me a photo of the new assembly ?

Where specifically have you put this 33nF ?

I was going to put the Sonoff in my bedroom lights, but got concerned, imagine if it's randomly turns ON at night and wakes me up ?!

Thanks

Aaron Newcomb

unread,
Dec 12, 2017, 3:48:29 PM12/12/17
to SonoffUsers
Vitor,

This one kind of shows it. You need to connect one side of the cap (ceramic) to the last pin on the 5 pin header and the other side to ground. I found it convenient to connect the other side to ground on the first pin of the 9 pin header that runs perpendicular to the 5 pin header, but any ground should work.


Also, this is a good reference for the pins on the board. http://tinkerman.cat/wp-content/uploads/2016/06/pinout_frontx.jpg

Vitor Dalto

unread,
Dec 12, 2017, 7:16:35 PM12/12/17
to SonoffUsers
Got it !
Thank you.
Now I understood

Tomer Ben Simon

unread,
Dec 26, 2017, 4:36:52 AM12/26/17
to SonoffUsers
Reply all
Reply to author
Forward
0 new messages