0

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?

Dushyant Bangal
  • 139
  • 1
  • 6

4 Answers4

2

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.

user2497
  • 679
  • 5
  • 8
0

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.

schematic

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.

mike
  • 111
  • 1
  • 1
  • 7
0

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.

MatsK
  • 2,791
  • 3
  • 16
  • 20
0

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.

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • 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? – Dushyant Bangal Feb 15 '18 at 08: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 Feb 15 '18 at 08: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? – Dushyant Bangal Feb 15 '18 at 17:30