0

I’m new to RPI and have a project. Please take a look at the fire switch on the diagram. I would like to add a RPI on that loop and see when the fire button is depressed. This is a 12V system so any advice on how to best do this would be greatly appreciated. Thank you.

enter image description here

0

Edit Beware while the first approach MAY work if you have a common Gnd; otherwise it risks destroying the Pi. The ONLY safe approach is some form of isolation, see the second approach.

In general, use a voltage divider for the input on the Pi's GPIO pins:

12V signal
---------------+
               |
              +-+
              | | R1
              | |
              +-+ 
               |------------------------
              +-+
              | | R2                -> to the Pi's GPOI
              | |
              +-+ 
gnd            |
---------------+------------------------

You would choose something in the range R1=3*R2. The exact value depends a bit on the noise in your environment (more noise, smaller resistors). You might put a 3v3 zener diode parallel to R2, which would protect your Pi a bit more.

A safer way would be to use an opto-coupler, where you provide galvanic separation. That would result in:

12V signal                       Pi 3V3
---------------+        +--------------- 
               |        |          
              +-+      +-+
              | | R1   | | R2
              | |      | |
              +-+      +-+
          .....|........|....     pi gpio
          :   ---       |----------------
          :   \ / ->  |/    :
          :   _V_ ->  |\    :
          :    |        v   : 
12V ground:....| .......|...:     pi gnd
---------------+        +----------------

The values of the resistors depend on the optocoupler that is used. Read the datasheet. Values for R1 may vary between 470ohm and 4k7, so really read the data sheet for the typical input current. R2 is not that critical; I'd try a 4k7.

Note that there are also ready to use optocouppler boards available.

2
  • Ljm Dullaart, thank you for providing a solution. One question on the second solution, what resistor values would you recommend for R1 and R2? Sep 30 at 17:47
  • Added comment about resistor values to the answer. Sep 30 at 20:02

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.