# Watch a voltage level and when it drops below 5v, supply power to something

#### scythe944

Joined Jan 30, 2021
12
Hi all, I'm new here and don't have much of a background in electronics, as much as I would have liked to (went into IT instead of electronics).

I have what seems to be a unique case, although I'm sure it's been done before. This thread sort of seems like what I'm going for: https://forum.allaboutcircuits.com/threads/how-to-use-a-drop-in-voltage-to-trigger-a-switch.114349/

So, basically, I need something small and cheap, like an arduino or a pi pico or something else that I've never heard of to simply look at the voltage level of two wires (positive and negative DC voltage, 13V Max) and when the voltage drops to about 5VDC, then I need it to turn on power (I don't care if it's the 5VDC signal that I'm watching to provide the power, or another 12V source).

I basically need something that acts like a reverse relay maybe? I'm reading about comparator's now, and I've never heard of them until today.

So basically, I'll have a 13v DC signal that will slowly drop, and when it gets down to 5V I simply want to power an LED.

Can anyone give me a basic list of things that I'd need to accomplish this and possibly some sample code if I have to write something and modify it for my needs to get me started? I'd greatly appreciate everyone's help!

#### SamR

Joined Mar 19, 2019
3,411
They actually make a voltage monitor and alarm chip. Take a look at: 7665S CMOS Micropower Over/Under Voltage Detector

#### djsfantasi

Joined Apr 11, 2010
7,693
Before I answer, what do you think a “negative DC voltage” is?

In your case, is it 13V below ground? Which implies the voltage difference is 26V. Or is it the ground connection for a 13V supply?

#### dl324

Joined Mar 30, 2015
12,871
Welcome to AAC!
So basically, I'll have a 13v DC signal that will slowly drop, and when it gets down to 5V I simply want to power an LED.
What do you mean by signal? Is this a battery voltage that you want to monitor? If it truely is a signal, what supply voltage is available to power a comparator?

#### scythe944

Joined Jan 30, 2021
12
Welcome to AAC!
What do you mean by signal? Is this a battery voltage that you want to monitor? If it truely is a signal, what supply voltage is available to power a comparator?
Yes, there is a voltage coming from a fuel level sending unit. When fuel starts to get low, the voltage drops. When the fuel gets to about a 1/4 tank, the voltage appears to be 5V at that point, and when that happens, I want to light up a low fuel warning LED.

#### scythe944

Joined Jan 30, 2021
12
They actually make a voltage monitor and alarm chip. Take a look at: 7665S CMOS Micropower Over/Under Voltage Detector
Thank you, I'll google that and take a look!

#### scythe944

Joined Jan 30, 2021
12
Before I answer, what do you think a “negative DC voltage” is?

In your case, is it 13V below ground? Which implies the voltage difference is 26V. Or is it the ground connection for a 13V supply?
Um, a negative DC voltage would be when you put your test leads on a circuit backwards? I replied to someone else, but basically this is for a vehicle's fuel system. When the tank is full, the unit sends voltage and it's about 12v. As the tank gets lower, the voltage drops. At about a 1/4 tank, the voltage is at about 5VDC. At that point, I'd like to power a "low fuel" LED.

#### djsfantasi

Joined Apr 11, 2010
7,693
Um, a negative DC voltage would be when you put your test leads on a circuit backwards? I replied to someone else, but basically this is for a vehicle's fuel system. When the tank is full, the unit sends voltage and it's about 12v. As the tank gets lower, the voltage drops. At about a 1/4 tank, the voltage is at about 5VDC. At that point, I'd like to power a "low fuel" LED.
ok, voltages are always measured between two points. Those points often include a ground or common node, which is at 0V. When the second node is 13V, you read a positive voltage. 13V minus 0V is +13V. If you reverse the leads, the ground is at 13V and the second point is 0V. 0V minus 13V is -13V. It’s all relative. When I see negative 13V, I imagine 13V minus -13V or 26V. It’s all relative. Electronics is an engineering discipline, so words are very specific. I (now) understand what you were saying and it’s all good.

#### scythe944

Joined Jan 30, 2021
12
ok, voltages are always measured between two points. Those points often include a ground or common node, which is at 0V. When the second node is 13V, you read a positive voltage. 13V minus 0V is +13V. If you reverse the leads, the ground is at 13V and the second point is 0V. 0V minus 13V is -13V. It’s all relative. When I see negative 13V, I imagine 13V minus -13V or 26V. It’s all relative. Electronics is an engineering discipline, so words are very specific. I (now) understand what you were saying and it’s all good.
Understood, thanks!

#### crutschow

Joined Mar 14, 2008
27,231
Here's the LTspice simulation of a simple circuit that turns on an LED at 5V.
It uses a TLV431 programmable shunt regulator as a comparator.
It conducts its cathode current to ground when the Ref voltage is below 1.24V, as determined by the R3/R3 voltage divider, and stops conducting when the voltage is above that point (thus allowing the R1 current to flow through the LED).
As you can see, the LED (red trace) turns on when the fuel sensor voltage (green trace) goes below 5V.

#### PRASS

Joined Feb 22, 2018
30
You could use a Arduino
Analog voltage is an example in the IDE.
You would have to figure out you circuit load & apply the correct resistence to bring the voltage down to 5V & below so the Arduino could read it. Or use an appropriate Zener Diode.
Then just make a IF ELSE statement that allows your LED to switch on at the desired voltage.

You could also use a Zener diode as a cut off device & use the Digital Read functon of a Arduino in the LOW state to activate the LED etc. This si also in the IDE as an example.

You can use the same process to switch off power consumers on the circuit & or switch on other power supply methods.

#### crutschow

Joined Mar 14, 2008
27,231
You could use a Arduino
So you really would substitute an Arduino for a TLV431?

#### PRASS

Joined Feb 22, 2018
30
So you really would substitute an Arduino for a TLV431?
Of course !
Apart from the fact you can't run the TLV431 on the original 12V supply or run anything above 140mA.
You also have to figure out load vs resistance to make the TLV431 shunt at the desired current. By the sounds of it the above mentioned circuit in the post would be on a continuous draw to the source & would make setting up the TLV431 extremely difficult.
Also it would only serve it's singular purpose.
The Arduino on the other hand is able to do everything the TLV431 can do plus 16000 more functions per second. It also already has a built-in LED as desired & can monitor the volts, amps, etc from multiple sources at the same time.
It can be powered by the original 12V from the source & has multiple built-in resistors, diodes & regulators to prevent back EMS that would blow the TLV431 apart if a light on the circuit was switched off etc.
You can also just disconnect the Arduino then use it on some other project(s) doing a completely different task time & time again with just a small amount of code.

I use Arduino's for most everything these days. It's like fritzing but physically with straight away results.

#### crutschow

Joined Mar 14, 2008
27,231
Apart from the fact you can't run the TLV431 on the original 12V supply or run anything above 140mA.
It's rated for 18V and I'm running less then 3mA through it.
You also have to figure out load vs resistance to make the TLV431 shunt at the desired current.
I would consider making a voltage divider to generate 1.24V at the desired trip point rather trivial.
Certain a lot simpler then learning to code an Arduino for the newbie TS.
The Arduino on the other hand is able to do everything the TLV431 can do plus 16000 more functions per second.
Sure it can do thousands of other things, but it's rather overkill for this task.
the above mentioned circuit in the post would be on a continuous draw to the source & would make setting up the TLV431 extremely difficult.
I doubt if a 40kΩ load would significantly affect the source voltage but, if it does, those resistor values can be readily increased since the Ref input to the TLV431 is very high.
Anyway the Arduino would also need divider resistors to lower the 12V to the maximum input it can tolerate.

#### PRASS

Joined Feb 22, 2018
30
It's rated for 18V and I'm running less then 3mA through it.
I don't know where you got 18V from ?
7V max input & 1.258V max voltage reference.
TLV431
I would consider making a voltage divider to generate 1.24V at the desired trip point rather trivial.
Certain a lot simpler then learning to code an Arduino for the newbie TS.
A voltage devider that produces 1.24V ?
You can just plug an Arduino straight into 12V
This also has the benefit of being able to use the Arduino as an Oscilloscope at the same time that can take all data in real time & can be monitored as well as stored for later use thrugh it's Serial Monitor or Serial Plotter.
Best of all it's all freeware

I doubt if a 40kΩ load would significantly affect the source voltage but, if it does, those resistor values can be readily increased since the Ref input to the TLV431 is very high.
I am refering to after the fact of having an Arduino as the measurement device being affected by the load on the original circuit that is drawing on the 13V max circuit to pull it down to the 5V threshold he is looking for.
I dare say this is to create a cutoff switch for a car stereo or a solar battery bank by the sounds of it.
With an Arduino it can be written into the code of the IVR rules so it knows if the battery is actually bellow the 5V or if the load is just making it look that way.
The TLV431 would just go into shunt mode if a load if a load any bigger then 400mA was turned on.
Anyway the Arduino would also need divider resistors to lower the 12V to the maximum input it can tolerate.
An Arduino can run on 12V & doesn't require any resistors as it's not being used as a passive component.
But the input signal would need a 2 X 1KΏ devider or a 2kΏ trimpot would make life a lot easier.

#### crutschow

Joined Mar 14, 2008
27,231
I don't know where you got 18V from ?
7V max input & 1.258V max voltage reference.
I was looking at the On Semiconductor data sheet here.
Apparently in the TI data sheet, it's designated as the TLVH431.
But the input signal would need a 2 X 1KΏ devider or a 2kΏ trimpot would make life a lot easier.
That's the voltage divider I was referring to.
So you really think that someone without much a a background in electronics could use an Arduino without first learning how microprocessors work, and understanding the code?

#### scythe944

Joined Jan 30, 2021
12
I was looking at the On Semiconductor data sheet here.
Apparently in the TI data sheet, it's designated as the TLVH431.
That's the voltage divider I was referring to.
So you really think that someone without much a a background in electronics could use an Arduino without first learning how microprocessors work, and understanding the code?
I have an Arduino, it came with a kit, I was able to get a breadboard to light up some LEDs and went through a couple of the tutorials pretty easily, so I don't think what I'm trying to do would be incredibly difficult. I will certainly give it a try.

@PRASS, thanks very much for that, I didn't realize (because it's been so long since I had the Arduino software installed) that it came with preloaded functions to read analog voltages. That seems perfect.

All I'd need to do is setup that to read the voltage and when it reaches 5v or less, then close a circuit and provide power!

I'll have to load that software up and see if I can figure out how to either use a relay or just tell the board to start supplying power to a set of leads. Thanks for the inspiration!

#### scythe944

Joined Jan 30, 2021
12
So, yes, if I go the Arduino route, which may invariably be overkill for this project, I would basically need a combination of the "Blink" sample, as well as the "Read Analog Voltage" sample, and just put them together with like and IF/Then statement of sorts. Just have to figure out how, as I'm no programmer. I've built countless servers and computers and have managed hundreds of VDI computers, configured firewalls and wireless networks, but I have no idea how to code, lol.

In the blink sample, which I have functioning correctly on my desk right now, I'd plug the LED into PIN 13 on my Arduino UNO and ground, then I just need to plugin the source voltage that I'm trying to read into PIN 0 and ground. I'd have the "Read Analog Voltage" routine looking at PIN 0 and waiting for the voltage to drop to 5V or below, and when it does, then have it run the "Blink" routine.

#### crutschow

Joined Mar 14, 2008
27,231
Okay, the Arduino seems like an okay way to go if you already have one and know sufficient programming to modify the code to do what you want.
It's overkill, but it allows you to do other things if you like.
For example, You could do several levels to light different color LEDs.