1

I have a simple circuit that goes to a garage door contact sensor then to a resistor then to an LED to show if the circuit is open or closed. I've confirmed that my wiring works with a power source - when the door is closed, the circuit is closed and the light turns on. Light turns off when the door is open.

Then when wired it to my RPI, I'm using GPIO pin 20 and ground pin 34. Using the GPIO commands, I can't see to get the circuit to close correctly and export the circuit value. The exported value is always 1. I was able to get my circuit to close and light the LED by doing these commands

gpio -g mode 20 in
gpio -g mode 20 up
gpio export 20 in

The LED is on when the door is closed and the exported value is 1 but it remains 1 when the door is open. I would expect the export value to change?

My question is - Do I have this wired to the right pins? Am I using the right commands?

Edit: added pic. Yellow wire is incoming from GPIO pin 20. Purple and gray wires are my sensor

enter image description here

  • Unanswerable without at least a schematic of the wiring and preferably a photo or photos. – joan May 28 '18 at 12:03
  • 1
    If the circuit from the contact sensor is not pulled to ground when the door is open, the pull-up set on the GPIO will keep it high. – goldilocks May 28 '18 at 12:35

Your Answer

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

Browse other questions tagged or ask your own question.