How to read a 12V signal on the ground side of a relay

Background: I’m working on an automotive project (controlling some lights using an Arduino Nano). It’s going great mostly, but I want to be able to read my high beam status to program in some logic to let me have a mode where the lights are all synced to the high beams so I can quickly turn everything off if a car is coming the other way.

Problem: the high beam wire that I have access to is on the ground side of the relay, because the car’s body control module grounds the relay to turn on the high beams. I need to step this down to 5V so the arduino can read it, but when I connect a voltage regulator to that wire to bring it down to 5V, I end up grounding the relay and turning on the high beams.

Is there a relatively simple way to read this wire with the Arduino without disrupting it but also without frying the Arduino pin?

I did find one somewhat related looking thread but I don’t see a definitive solution in it:

I’ve attached a simple diagram of the circuit in question with a wire coming off where I’m trying to read. I just need to be able to know with the arduino whether the switch is closed or not so I can act on it.

Thanks!

Thinking about this more I think I just need to use a voltage divider with very high resistance so as not to disturb the circuit sufficiently to close the relay? My multi-meter can read the wire without it turning the high beams on, so that makes sense to me.

I'm not sure what would constitute sufficiently high resistance for this purpose though, and also not sure how to build it such that it will deal with the noisy voltage of an automotive environment, anywhere from 12-15V, and probably with spikes when starting the car etc.

If anyone knows of an off the shelf component that can deal with such a scenario that would be awesome as well.

A diode.

A resistor pullup on a digital input, feed it with the diode. You are only interested on a GND signal, so you pull down the input with the signal.

jalisurr: I need to step this down to 5V so the arduino can read it, but when I connect a voltage regulator to that wire to bring it down to 5V, I end up grounding the relay and turning on the high beams.

Obviously you made a bad mistake wiring that together! Somehow you shorted out the regulator, without knowing just what you did, I would of course, not know how.

|440x500

So: |500x303

AJLElectronics:
A diode.

A resistor pullup on a digital input, feed it with the diode. You are only interested on a GND signal, so you pull down the input with the signal.

Thanks! So from the wire, I just need a simple diode into the arduino pin, with that pin set to input_pullup? Or does the pullup circuit have to be external to avoid frying the arduino from the 12V?

Paul__B: Obviously you made a bad mistake wiring that together! Somehow you shorted out the regulator, without knowing just what you did, I would of course, not know how.

|440x500

So: |500x303

Thanks! I definitely may have done something wrong, but the voltage regulator I was using was a standalone chip that I had, specifically a D24V50F5. So I just hooked Vin to the wire I want to read, Vout to the Arduino, and ground to ground. The moment I plugged the Vout into the Arduino, the high beams of the car turned on!

If I understand the circuit you posted correctly, it's a voltage divider with a 5v pullup, is that correct? Are those resistor values what I should be using in this project or is that just for illustration purposes?

jalisurr: Thanks! So from the wire, I just need a simple diode into the arduino pin, with that pin set to input_pullup? Or does the pullup circuit have to be external to avoid frying the arduino from the 12V?

Sorry for the repeated posts, doing a bit more searching to try to make sense of this. I found this thread: https://forum.arduino.cc/index.php?topic=521372.0

Which suggested this arrangement, is this what you are talking about? Using the internal pullup resistor of the Arduino would mean I only need the diode externally? |500x208

That looks like a good solution.

Thanks! I definitely may have done something wrong, but the voltage regulator I was using was a standalone chip that I had, specifically a D24V50F5.

Voltage regulators are for “power” not for “signals”. (It can work in an application like this but it’s not the best solution.)

If I understand the circuit you posted correctly, it’s a voltage divider with a 5v pullup, is that correct?

The pull-up is the relay coil. When the switch is off you have 12V on both ends of the coil (as long as the “load resistance” is high relative to the coil resistance).

Are those resistor values what I should be using in this project or is that just for illustration purposes?

The resistance values are not that critical.

D2 prevents excess positive voltage. R1 prevents excess current through the diode and into the 5V supply.

D1 protects against negative voltages. R2 is a pull-down resistor resistor as well as one of the of the voltage divider resistors. (A pull-down is not required if you don’t have D1.)

One of these [u]protection circuits[/u] can also work, without a voltage divider. (I’d increase the current-limiting resistor to at least 1K and I’d recommend Schottkey diodes if you are not using the Zener diode method).

Thanks all!

So it sounds like using the internal arduino pullup with a diode will be the simplest solution. I put it together in a circuit simulator and it seems to all work the way I expect.

Any gotchas here I need to know about? Seems like the noisy automotive voltage won’t affect this system, so I think I’m good?

Here’s the diagram, where the voltmeter with attached 20k resistor and 5v source is what I believe the arduino pin would look like when set to input_pullup

Just aside, that has to be one of the most obscure schematics I’ve ever seen.

Use this: pinMode (pin_number, INPUT_PULLUP) and You use the built in resistor in the controller.

jalisurr: Background: I'm working on an automotive project (controlling some lights using an Arduino Nano). It's going great mostly, but I want to be able to read my high beam status to program in some logic to let me have a mode where the lights are all synced to the high beams so I can quickly turn everything off if a car is coming the other way.

Problem: the high beam wire that I have access to is on the ground side of the relay, because the car's body control module grounds the relay to turn on the high beams. I need to step this down to 5V so the arduino can read it, but when I connect a voltage regulator to that wire to bring it down to 5V, I end up grounding the relay and turning on the high beams.

Is there a relatively simple way to read this wire with the Arduino without disrupting it but also without frying the Arduino pin?

I did find one somewhat related looking thread but I don't see a definitive solution in it: https://forum.arduino.cc/index.php?topic=636116.0

I've attached a simple diagram of the circuit in question with a wire coming off where I'm trying to read. I just need to be able to know with the arduino whether the switch is closed or not so I can act on it.

Thanks!

Use an opto isolator.... :)

Input pin will be HIGH when relay is NOT energized, LOW when it is.

relay_sw.png

Railroader: That looks like a good solution.

The circuit I suggested is protected from impulses below ground. :grinning:

Paul__B: The circuit I suggested is protected from impulses below ground. :grinning:

Paul__B: The circuit I suggested is protected from impulses below ground. :grinning:

OOPS! Didn't know it was a mining vehicle :)