So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By buzzy
#78255 Can someone please try to put this code on your esp8266. The blue LED should turn on after flashing it. Then take any wire (like a breadboard wire) and tap it several times to GPIO12. Do not connect the wire to anything other than tapping the GPIO12! Does the LED turn off?? I have tried it on 2 different esp266 boards. Even when running on batteries, my LED turns off and I just can't figure out why??

How can the state change on a PIN just by tapping on it?? I am using INPUT_PULLUP so the PIN is NOT floating. Not only tapping on the PIN changes the state for me. I can even turn on the ceiling fan in my room and the PIN changes state?? I tried powering the esp8266 using a battery. Same results! I am so confused...

Here is the simple code: https://pastebin.com/1F4WBJ5p
User avatar
By rudy
#78257
take any wire (like a breadboard wire) and tap it several times to GPIO12. Do not connect the wire to anything other than tapping the GPIO12! Does the LED turn off??

No. Yes. Sometimes. It depends on the charge on the wire and how that compares to the potential of the input.

If I were to be in contact with the wire, I then use the wire to touch VCC, I make myself the potential of VCC. I then touch the input pin and there is no change. I am at a logic high.

But if I instead ground myself to the metal case covering the ESP module (I used a ESP-M3) and then touched the input with the wire (still in contact with my body) the blue led goes off. As expected.

I am part of the circuit and I hole a lot of charge. Just with a bare wire, well insulated, 22AWG, 2 feet in length, I can repeat the above test, ground the wire then use it to touch the input, and it only rarely turns off the blue led. The charge on the wire mostly can't overcome the pull up resistance. But this is if I had the charge on the wire at circuit ground potential. If I had the charge as being more negative then it would have a stronger likelihood to cause the input to see a low state.

You need to understand that everything has a potential and a charge and sometimes they become relevant in our circuits. With that understanding you can then decide if they are significant or not.

Debounce routines are useful but they are not always a proper fix. It is much better to understand the underlying cause and then to make the best decisions given the situation. It can be far better to include a RC delay on a pin set for interrupts, to deal with high frequency noise, than to try and fix it in software. There is no best one solution. There are always tradeoffs.
User avatar
By buzzy
#78263
rudy wrote:
take any wire (like a breadboard wire) and tap it several times to GPIO12. Do not connect the wire to anything other than tapping the GPIO12! Does the LED turn off??

No. Yes. Sometimes. It depends on the charge on the wire and how that compares to the potential of the input.

If I were to be in contact with the wire, I then use the wire to touch VCC, I make myself the potential of VCC. I then touch the input pin and there is no change. I am at a logic high.

But if I instead ground myself to the metal case covering the ESP module (I used a ESP-M3) and then touched the input with the wire (still in contact with my body) the blue led goes off. As expected.

I am part of the circuit and I hole a lot of charge. Just with a bare wire, well insulated, 22AWG, 2 feet in length, I can repeat the above test, ground the wire then use it to touch the input, and it only rarely turns off the blue led. The charge on the wire mostly can't overcome the pull up resistance. But this is if I had the charge on the wire at circuit ground potential. If I had the charge as being more negative then it would have a stronger likelihood to cause the input to see a low state.

You need to understand that everything has a potential and a charge and sometimes they become relevant in our circuits. With that understanding you can then decide if they are significant or not.

Debounce routines are useful but they are not always a proper fix. It is much better to understand the underlying cause and then to make the best decisions given the situation. It can be far better to include a RC delay on a pin set for interrupts, to deal with high frequency noise, than to try and fix it in software. There is no best one solution. There are always tradeoffs.


Sure, I completely agree with you on this one. However, I am NOT attached to the wire in any way. I am just holding the plastic part of the wire, so I am not part of the circuit. I even tried this when powering the board using a battery-pack with the same result.

And like I wrote in my original post, the "touching the wire" is not even the worst part. It even happens when I turn on my ceiling fan in ANOTHER room :) How is it even possible that a pin changes on my wemos, when I just turn on my fan in another room? It's super weird. The obvious reason would be if the pin is floating, but it's not. I have tried both with the internal resistor and several different value external ones. I can post a video to make it more clear if needed.

You mentioned an RC delay? What is that? Could you please elaborate some more. Thanks!