2

I would like to connect the garage door's button to a GPIO input on my Pi. I want to be able to trigger actions when someone pushes the button. I am able to read the status of a basic switch using this circuit I found:

Example Pull-Up and Pull-Down Circuit

My concern is that when I connect a volt meter across the garage door button I see over 16 volts (presumably to drive the LED in the button?). I am concerned that if I connect my switch reading GPIO input circuit to the button, that 16 volts could fry my Pi. How can I read whether the button is open or closed, but protect my Pi from the voltage on the line?

I do also have a garage door magnetic switch sensor that works great, but my requirements include knowing when the button is pushed- not just whether the door is open or closed.

3

I've not worked with the GPIO yet, but I believe 5V is the most you're supposed to provide, so 16V on the input would most likely be bad. It's easy to fix though; all you need are a couple of resistors to build a voltage divider. In this case, to get 16V down to 5V, the top resistor needs to be 2.2 times the bottom, so you'd need a combination like 1k and 2.2k. You possibly want to use higher values (10k/22k, 100k/220k, etc) to reduce the amount of current that could flow into the RPi if something goes wrong.

  • Thanks for the idea. I'm going to try an optocoupler first, but I may use your suggestion if that fails. – dgel Mar 8 '13 at 16:05
  • In a way you may end up with both - in that you'll probably need a current limit resistor to protect the optocoupler, and that in turn will protect the pi. It sounds like you might end up with inverted logic - optocoupleer on when switch not pressed, and that pulling a GPIO line low. When the switch is pressed, the optocoupler would turn off, and a pullup resistor would take the GPIO high. Software can of course be made to work with either "sense" – Chris Stratton Mar 10 '13 at 23:31
  • @ChrisStratton - Rather than commenting on this answer, why not post an answer of your own? There is enough information here to be worth an answer and you are guaranteed at least one up vote. *8') – Mark Booth Mar 12 '13 at 10:06
  • 2
    3.3V operating max (3.6V absolute max). 5V will probably damage the GPIO – John La Rooy Mar 12 '13 at 11:07
1

I was able to solve this problem by using this optocoupler. The control pins on the optocoupler are connected in parallel with the garage door button. The DC+ and DC- pins are connected to a GPIO input on the Pi using the same circuit as above. When the garage button is pressed, the optocoupler opens the switch, enabling me to detect the event through the GPIO.

  • Much better, thanks dgel. Are you sure you meant to say that the control wires should be in parallel with the button though? Knocking up a quick schematic over at circuitlab would make it really obvious what you meant. – Mark Booth Mar 12 '13 at 19:10

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.