I'm working on a very basic doorbell raspberry pi project, by following this post: https://harizanov.com/2013/07/raspberry-pi-emalsms-doorbell-notifier-picture-of-the-person-ringing-it/

however, i'm getting a very strange behavior, can anyone explain the cause to me? or how to fix it?

the symptom: random voltage when I'm monitoring the GPIO input

the code:


while True:
    if (GPIO.input(11)):
        print "000"
        print "xxx"

the result: xxx xxx xxx 000 000 000 xxx xxx xxx 000 000

since the GPIO17(11) and GPIO Ground(9) are not powered at all, why I'm getting the random HIGH and LOW for the input?

PS: the symptom only happens when there are two wires connect to the GPIO17 and GND, or any other Green pin with GND, if I remove the wire from the GPIO, the result shows XXX only

tks in advance

  • 2
    can we see a photo(s) of the circuit? Do you have a pullup/down resistor in the circuit? I am assuming that you have (GPIO15 connecte to ground through a button to ground, is this correct? If so you need a pullup resistor. That will keep the pin high until connected to ground by pressing the button - avoiding the floating state of the pin, Assuming that my assumptions above are true this may be all you needL GPIO.setup(buttoPin, GPIO.IN, pull_up_down=GPIO.PUD_UP) Jan 3 '16 at 7:45
  • 1
    That's called a floating pin.
    – Aloha
    Jan 3 '16 at 14:12

Ok, by few minutes googling, found the answer by myself. All I had to do was to add the following line:

GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)

Here's the post

Raspberry pi GPIO input pins give random values

Not the answer you're looking for? Browse other questions tagged or ask your own question.