Arduino pin getting input with just a physical touch

Thread Starter

DonBradman

Joined Mar 30, 2023
40
So I have a switch connected via two wires to a two pin plug which is supposed to go in a two pin socket. One pin of the socket goes to 5V and the other goes to a digital I/O in the Arduino + GND (via 10K). When the switch is pressed and the digital arduino pin goes high, stuff is supposed to happen. Now here's the interesting part, if I touch the 10K arm on the other end of GND, with flesh or anything conducting, the stuff that's supposed to happen starts happening, EVEN IF THERE IS NO PLUG IN THE SOCKET (who needs a switch, switches are overrated!). Basically, the moment something conducting comes in touch with the pin connected to the digital I/O, the process starts. That's a bummer because now I can't even connect the plug in. Interestingly it doesn't happen if I touch the arm of the resistor towards the GND, only happens when I touch the arm of the resistor away from the GND, that too only when the touching medium is conducting. This setup is new but the same circuit I have used countless times without issues. What the hell is happening here?


1682918597759.png
 

dendad

Joined Feb 20, 2016
4,451
A couple of things to check....
Is the 10K resistor connected? Measure the resistance from pin12 to gnd at the Nano.
Also check it is a 10K and not a 100K etc.
Do you have the pinMode (12, INPUT); and NOT pinMode(12,INPUT_PULLUP); If the pullup is on, the input will be sitting above 0V for a start, making it more susceptible to noise.
 

DickCappels

Joined Aug 21, 2008
10,153
You are being an antenna, picking up the ambient electric field (almost certainly mostly 50 Hz or 60 Hz) and injecting it into the Arduino input pin.

Be careful. If you happen to touch the pin after you acquire a large static voltage charge, you can damage the Arduino controller. In other words, I recommend that you stop touching that pin.
 

Thread Starter

DonBradman

Joined Mar 30, 2023
40
You are being an antenna, picking up the ambient electric field (almost certainly mostly 50 Hz or 60 Hz) and injecting it into the Arduino input pin.

Be careful. If you happen to touch the pin after you acquire a large static voltage charge, you can damage the Arduino controller. In other words, I recommend that you stop touching that pin.
So new update. You are right, its EMI issue. I am surprised. I have two power supplies which can convert 220V AC to 12V DC. One is giving this issue, one isn't. And Surprisingly even more, these power supplies are placed 1 foot from the point of trouble. For now I'll just try to arrange the other power supply, but how to know in the future which power supply is good and which bad?? And if I have a bad power supply, is there a way to emi proof this system?
 

DickCappels

Joined Aug 21, 2008
10,153
A. Do not touch the pins on the controller chip,

B. Reverse the wall plug of the wall wart that is giving you problems -it may help. You might also want to mark it with a piece of colored tape a gel pen or other means.
 

Thread Starter

DonBradman

Joined Mar 30, 2023
40
A. Do not touch the pins on the controller chip,

B. Reverse the wall plug of the wall wart that is giving you problems -it may help. You might also want to mark it with a piece of colored tape a gel pen or other means.
I am actually using something like this
1682943961146.png
 

dendad

Joined Feb 20, 2016
4,451
A lot of switch mode power supplies have significant leakage through them.
Just for interest, have the supplies running but with no connection on the outputs and measure the AC voltage from the output to mains Earth.
 

Thread Starter

DonBradman

Joined Mar 30, 2023
40
Ok, confusing results. Firstly below is the image of where I had set my multimeter, is it ok?



IMG_20230502_084735
IMG_20230502_0847351920×2560 228 KB



Now when I test the bad power supply it reads 10.9, and when I test the good power supply it reads 18.

I also tested between earth and AC mains. Bad power supply reads 36, good power supply reads80

A lot of switch mode power supplies have significant leakage through them.
Just for interest, have the supplies running but with no connection on the outputs and measure the AC voltage from the output to mains Earth.
 

Sensacell

Joined Jun 19, 2012
3,432
If you replace the 10k resistor with a 330 ohm resistor the problem will go away.

The 10k impedance is too high given all the leakage from the mains, via the power supply.

Lowering the impedance dilutes the effect of the leakage current
 

Thread Starter

DonBradman

Joined Mar 30, 2023
40
If you replace the 10k resistor with a 330 ohm resistor the problem will go away.

The 10k impedance is too high given all the leakage from the mains, via the power supply.

Lowering the impedance dilutes the effect of the leakage current
I tried 1K before, it didn't work, pin 12 went naturally high
 

MrAl

Joined Jun 17, 2014
11,389
So I have a switch connected via two wires to a two pin plug which is supposed to go in a two pin socket. One pin of the socket goes to 5V and the other goes to a digital I/O in the Arduino + GND (via 10K). When the switch is pressed and the digital arduino pin goes high, stuff is supposed to happen. Now here's the interesting part, if I touch the 10K arm on the other end of GND, with flesh or anything conducting, the stuff that's supposed to happen starts happening, EVEN IF THERE IS NO PLUG IN THE SOCKET (who needs a switch, switches are overrated!). Basically, the moment something conducting comes in touch with the pin connected to the digital I/O, the process starts. That's a bummer because now I can't even connect the plug in. Interestingly it doesn't happen if I touch the arm of the resistor towards the GND, only happens when I touch the arm of the resistor away from the GND, that too only when the touching medium is conducting. This setup is new but the same circuit I have used countless times without issues. What the hell is happening here?


View attachment 293220
Hi,

After quickly reading this thread i am not sure if you are pulling the point high or not but it sounds like you are when you touch it.

Maybe you could try a resistor in series with the wire that goes to pin 12.
If all else fails maybe you could use an opto coupler. You'd still have to use the 5v and ground lines from the Arduino, but you would never have to touch the problem point again.

BTW, where is that 10k located, is it near the Arduino or plugged into a header and/or have long wires. It may have to be closer to the uC chip.
 

Thread Starter

DonBradman

Joined Mar 30, 2023
40
Hi,

After quickly reading this thread i am not sure if you are pulling the point high or not but it sounds like you are when you touch it.

Maybe you could try a resistor in series with the wire that goes to pin 12.
If all else fails maybe you could use an opto coupler. You'd still have to use the 5v and ground lines from the Arduino, but you would never have to touch the problem point again.

BTW, where is that 10k located, is it near the Arduino or plugged into a header and/or have long wires. It may have to be closer to the uC chip.
So I have changed the setting a bit. Now Pin 12 is normally high by connecting it to 5V through a 10K (directly soldered onto the pins, but I am planning to create some distance in the future if I create a PCB for it). And I am using a switch to put it low by connecting it to GND and then reading it when it is low. It works for the "good" power supply, but doesn't work for the "bad" power supply, and I don't know why. However bad the EMI, once a pin is connected to GND, it should be low, right? But then I think, in the pull down system where Pin 12 was supposed to remain normally low by being in continuous touch with GND through 10k, it was still high. So basically I have no idea what is happening and why its happening.

BTW, what is the role of the 10K? Is it just a current limiting resistor? Would perhaps a 100K help with the "bad" power supply?

One more question, if in a 2 layered PCB if GND and +ve lines cross, can that contribute to EMI?
 
Last edited:

DickCappels

Joined Aug 21, 2008
10,153
One more question, if in a 2 layered PCB if GND and +ve lines cross, can that contribute to EMI?
Not necessarily. I assume you mean if the cross on different layers, otherwise you would have other problems.
 

MrChips

Joined Oct 2, 2009
30,708
BTW, what is the role of the 10K? Is it just a current limiting resistor? Would perhaps a 100K help with the "bad" power supply?
What is the difference between 10kΩ and 100kΩ?
And the answer is not 90kΩ.
It is more that just current limiting.

Let us assume that the logic low input threshold of the 5V device is 2V (which might not be the case). Hence the voltage across the pull-up resistor will be Vcc - 2V , equal to 3V when the input registers logic low.

With R = 10kΩ, current is 3V/10kΩ = 300μA.
With R = 100kΩ, current is 3V/100kΩ = 30μA.

It means that the input with 100kΩ pull-up resistor will more sensitive to stray pick-up.

Next, have you heard of wetting current?
This is the minimum current that switch contacts need to make a reliable connection. The recommended wetting current for small switches is between 1-20mA. Thus the pull-up resistance should be between 150-3000Ω.
 

MrAl

Joined Jun 17, 2014
11,389
So I have changed the setting a bit. Now Pin 12 is normally high by connecting it to 5V through a 10K (directly soldered onto the pins, but I am planning to create some distance in the future if I create a PCB for it). And I am using a switch to put it low by connecting it to GND and then reading it when it is low. It works for the "good" power supply, but doesn't work for the "bad" power supply, and I don't know why. However bad the EMI, once a pin is connected to GND, it should be low, right? But then I think, in the pull down system where Pin 12 was supposed to remain normally low by being in continuous touch with GND through 10k, it was still high. So basically I have no idea what is happening and why its happening.

BTW, what is the role of the 10K? Is it just a current limiting resistor? Would perhaps a 100K help with the "bad" power supply?

One more question, if in a 2 layered PCB if GND and +ve lines cross, can that contribute to EMI?
Hi again,

I assume you mean the 'extra' 10k resistor in series with pin 12.
In that case, the 10k has a dual function. The primary reason is to try to isolate pin 12 a little more. The secondary reason is to limit the external spike energy that can get to the ESD diodes internal to the IC chip by limiting the current. The internal diodes have a maximum rating depending on the part number, usually from 2ma to 20ma, but it could vary more you have to check the specs on the data sheet(s).
I would say that 10k is probably too high unless you really need it. I would think 1k max would be the limit, although it's hard to quote this exactly because it depends on what is expected on the external line. The rationale is that if you had a 10v external pulse and the chip was operating at 5v, then the max current to the chip internal ESD clamp diode would be 5/1000=5ma with a 1k resistor. That's probably fine but check the data sheet.
I am guessing that you have the pin mode set to digital input which should be right, and there is no obtuse code that might change that.
I am also assuming that the ground lead to the chip is stable, and the chip has adequate capacitor bypassing across Vcc and ground and that cap is very close to the IC chip.
That reminds me, have you tried a capacitor across the input where the switch plugs in?
 
Top