Go Down

Topic: Why Input_pullup in arduino detecting state LOW (Read 159 times) previous topic - next topic

Andrew1990

Hello everyone, thank you for reading,

digitalRead will detect state LOW on pin(INPUT_PULLUP) when we will stick wire

 from pin(INPUT_PULLUP)  to GND.

I made circuit with short cable like 100mm and 1 wall-switch(Bell, ring)  one end connected to pin (INPUT_PULLUP) and second to GND

and it works as it should be i detect LOW when te circuit is closed and HIGH when it doesn't.

Then i made circuit with 10 wall-switches with common GND still with 100mm cable

and it works perfect as well.

then i lay the cable (copper wire 0,75 mm) each max long 10 m thro the hause
and made a circuit with 10 wall-switches with common GND, ive made the measurement of  resistance and it was ok as it should be. then i connected it to arduino and it works but sometimes when i click some switch digitalRead detect pin state LOW on other switch as well i cant sleep with that.

then i unpluged everything from arduino and then i connect short wire 100mm to pin(INPUT_PULLUP) and second end to common GND of that switches remeber this common gnd is not connected to gnd of arduino rhight now this circuit with switches is connected to nothing. and digitalRead sometimes return LOW when i stick cable from input_pullup to this common gnd of switches wich is not connected to gnd.

and my question is why arduino detecing LOW of pin(INPUT_PULLUP) in circuit wich is not connected to anything


sorry for my english, please help

Geek Emeritus

this does not answer your question, but it's good to know: I was having problems with my device rebooting when I shorted pins. loud pops, blue sparks. I got a pile of resistors and put them in line with my shorting lead; starting  at 4700 ohms, and worked my way down.

I got reliable triggers without drama and unexpected results with 47 ohms in line. if you see unexpected results, try that.
All PMs will be deleted unopened due to arrogant argumentative pot stirring Malfoys.
 If you have not read "How to use this forum - please read", in particular: "7. If you are posting code or error messages, use "code" tags":  expect rude responses

DVDdoug

Yes, a lower value (external) pull-up resistor may help...


Quote
and my question is why arduino detecing LOW of pin(INPUT_PULLUP) in circuit wich is not connected to anything
It could be picking-up noise (usually 50/60Hz electromagnetic radiation from your house wiring).   There is a certain small-amount of energy being picked-up, depending the length of the wires, shielding (if any) and the location (how close they are to the power wiring) and orientation of the wires, etc.  

If you've ever touched an audio input connection and heard a "buzz", that's the same thing, with your body acting as an antenna instead of a long unshielded wire.

"Energy" (more accurately power) is measured as Watts (or micro-watts in this case) and power is calculated as Voltage x Current.

With a given amount of energy (microwatts) you'll get higher voltage  into a higher impedance.   You could easily get 1 volt or more if you touch a high impedance Arduino input because with high impedance you don't get much current.   With lower impedance (or lower resistance) the voltage (from the noise) drops because a very-small amount of current is flowing through a lower resistance (Ohms Law).  There isn't enough energy picked-up to get "high" voltage and "high" current at the same time.

Since the High/Low is determined by voltage, lowering the impedance/resistance lowers the noise-voltage, making it more immune to noise.    

In this application, an external 1K pull-up resistor is fine and hopefully the noise problem will go-away.  5V and 1K only requires 5mA, which your doorbell switches and power supply can easily handle.

Andrew1990

#3
Apr 18, 2019, 06:23 pm Last Edit: Apr 18, 2019, 06:46 pm by Andrew1990
Yes, a lower value (external) pull-up resistor may help...

It could be picking-up noise (usually 50/60Hz electromagnetic radiation from your house wiring).   There is a certain small-amount of energy being picked-up, depending the length of the wires, shielding (if any) and the location (how close they are to the power wiring) and orientation of the wires, etc. 

If you've ever touched an audio input connection and heard a "buzz", that's the same thing, with your body acting as an antenna instead of a long unshielded wire.

"Energy" (more accurately power) is measured as Watts (or micro-watts in this case) and power is calculated as Voltage x Current.

With a given amount of energy (microwatts) you'll get higher voltage  into a higher impedance.   You could easily get 1 volt or more if you touch a high impedance Arduino input because with high impedance you don't get much current.   With lower impedance (or lower resistance) the voltage (from the noise) drops because a very-small amount of current is flowing through a lower resistance (Ohms Law).  There isn't enough energy picked-up to get "high" voltage and "high" current at the same time.

Since the High/Low is determined by voltage, lowering the impedance/resistance lowers the noise-voltage, making it more immune to noise.    

In this application, an external 1K pull-up resistor is fine and hopefully the noise problem will go-away.  5V and 1K only requires 5mA, which your doorbell switches and power supply can easily handle.
Hello mate thank you for reply, so i should connect resistor 1 Kohm to (5V from arduino ?) and to pin(INPUT_PULLUP)  im i wrong ?

and there is any other way how i can fix this i mean how to get rid of "electrical noise" with other way ?

wvmarle

The internal pull-ups are 20-30k, not very strong.

When you use an external pull-up you may disable the internal one; it's not doing much if anything. 1k is pretty strong, don't go below that number. 2k2 or 4k7 is probably enough. It goes between the pin and Vcc.

Another way of reducing noise may be a small capacitor (10-100nF) between pin and GND. That should filter out a lot of the electric noise.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

sterretje

This older post shows how you can wire switched to an Arduino over longer distances.

then i unpluged everything from arduino and then i connect short wire 100mm to pin(INPUT_PULLUP) and second end to common GND of that switches remeber this common gnd is not connected to gnd of arduino rhight now this circuit with switches is connected to nothing. and digitalRead sometimes return LOW when i stick cable from input_pullup to this common gnd of switches wich is not connected to gnd.

and my question is why arduino detecing LOW of pin(INPUT_PULLUP) in circuit wich is not connected to anything
1)
Current from your pin needs to be able to flow back to the Arduino; so that 'common ground' that you're referring to needs to be connected to the Arduino GND.
2)
Your 100mm wire is no longer a 100mm cable when you connect it to the 10 meter wire; so indeed a good chance that you pick up noise that is strong enough to 'override' the effect of the pull-up resistor.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Go Up