I've got a fairly simple circuit that I've made where a motion detector is connected to a Raspberry Pi B+ GPIO by way of a fairly long ~30ft stretch of wire. The detector is being powered by a 9V battery and the schematic is as follows:

PIL Schematic

I'm running a python script to pick up the motion and it is as follows:

import RPi.GPIO as gpio
import time
gpio.setup(17, gpio.IN)
while True:
  print ("LOW","HIGH")[gpio.input(17)]

I was getting an output that was consistently 9-11 HIGHs, then 9-11 LOWs then repeating, and I was wondering what was up so I disconnected the PIR motion detector, leaving the wire not connected to anything, and I got the same result: a consistent fluctuation between low and high.

From my research, LOW for GPIO is roughly <0.54V while HIGH is >2V. Measuring the difference in voltage between the wire and the Raspberry Pi GND pin (PIN 39) gives me 0.32V consistently, with no fluctuation. Why is this happening, and how can I fix it?

  1. based on your schema, looks like RPi can get 9V when high? Or am I readint it wrong?
  2. Your setup has one flaw: GPIO not connected to HIGH or LOW is neither of them. So it is oscillating. And your device puts HIGH or transient state. So, GPIO value oscillates

Read about pull-up resistors: https://learn.sparkfun.com/tutorials/pull-up-resistors/what-is-a-pull-up-resistor

  • Although in this case if a +ve voltage indicates switch closed the OP should use a pull-down to 0V. @OP check your sensor outputs 3.3V rather than 9V. All the Pi's gpios are 3.3V. – joan Apr 11 '15 at 7:46
  • It outputs 3.3V but takes 5-12V in. – globby Apr 11 '15 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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