I'm using Pi 3

I have a line that gives 12V. I need to invoke something on Pi, when the line goes High.

As I cannot connect the 12V to GPIO, I thought of using a relay, that will trigger on 12V, and then connect the 3v3 to a GPIO.

This will happen periodically, for almost a second.

I know that the 3v3 will have current that is unused by the Pi, but in this case I cannot always be sure how much thag would be.

Is this safe?

4 Answers 4


Use a voltage divider, or a 10V zener diode. My 10V zeners drop 9.49V, and would in your case yield 2.51V; a HIGH on PI. Optionally use a PNP+NPN pair to close the connection from the 12V line to the Pi when polling the voltage, or there will be a bit of leakage.


First you need to implement a De-bounce circuit, it will prevent the mechanical contact that can bounce when they touch together and be read as multiple contacts.

There is no "unused" current, the circuit will draw as much current as it need and the output will deliver it, if it can.


It is simple to interface a higher voltage indicator to the Pi, provided they can share a common ground connection.

Using relays is sledgehammer solution which introduces a number of other problems.

The simplest approach uses a voltage divider. Do NOT attempt to produce 3.3V, anything over 2.2V will reliably trigger the Pi (my tests indicate 1.3V is OK).

If the source is not clean DC you can implement various protective measures - either a diode clamp to 3.3V or a total isolation e.g using an optoisolator.

  • No, I'm saying can I just use the 3v3 given by the pi, and supply it to one of its own GPIOs for a second? Commented Feb 15, 2018 at 8:08
  • @DushyantBangal Yes you can. If connecting any low impedance source to a Pi GPIO it is recommended to use a series resistor ~1kΩ. Using a relay is still a sledgehammer approach with potential contact bounce issues.
    – Milliways
    Commented Feb 15, 2018 at 8:17
  • The thing is, I have the -ve going to a motor in an enclosed casing. So I cannot really get it to a voltage divider without some rewiring. Also, wouldn't voltage divider give out same amount of current and hurt Pi? Commented Feb 15, 2018 at 17:30

See my answer to another question here regarding the use of an interposing relay.

In the answer I posted I made mention to use a pull down resistor, and a current limiting resistor in series with the GPIO. This would look something like this.


simulate this circuit – Schematic created using CircuitLab

R2 serves to limit the current going to the input. We don't need a lot, we are simply looking for a voltage (as measured across pull down resistor R1). I typically use a 10:1 ratio, but for R2 you can use a lower value like 330 ohms.

SW1 represents the contact of a relay, the coil not shown. Pick a relay with a 12Vdc coil, these are common.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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