Raspberry Pi Low Battery Warning LED Circuit

To purchase a completed board or to get a BOM so you can make your own, visit the store page here.

Every battery powered device needs some way of notifying you when the battery is running low. The Pi doesn’t have this ability built-in, but it’s very easy to add using the LM393 Voltage Comparator. It’s an 8-pin device that compares two voltage sources and changes the output depending on the result of that comparison. The LM393 is actually a dual comparator, but for this purpose only one side is used.

lm393The LM393 has one positive power input, V+ (red, Pin 8), and a ground power input, GND (black, Pin 4). The power for the LM393 can be supplied using the same +5v and ground that supply power to the Pi.[spacer height=”20px”]

lm393 powerWhen the INVERTING INPUT (orange, Pin 6) voltage is higher than the NON-INVERTING INPUT (yellow, Pin 5) voltage, OUTPUT B (green, Pin 7) outputs the voltage from V+ (red, Pin 8). When the INVERTING INPUT (orange, Pin 6) voltage is lower than the NON-INVERTING INPUT (yellow, Pin 5) voltage, OUTPUT B (green, Pin 7) switches to GND (black, Pin 4).

 

For example, in my PSPi build the low battery LED is already connected to +5v, so a ground must be connected to the other terminal of the LED for it to light. In the PSPi, the output of Pin 7 is then used to switch the low battery LED on when Pin 7 is GND and off when Pin 7 is at +5v. As long as the battery voltage exceeds the reference voltage, the output on Pin 7 stays at +5v and no power is applied to the LED. When the voltage drops below the reference voltage, Pin 7 connects to GND and powers the LED.

The positive terminal from the battery connects to Pin 5 and the reference voltage connects to Pin 6. The 3.3v GPIO pin does a great job as the reference voltage for Pin 6, but be aware that this will not give a lot of time before the battery is fully depleted since the battery voltage drops very quickly when it is nearly depleted. I decided to use a Mini Buck Converter to generate a voltage of about 3.6v for my reference in the PSPi because that project has a high power drain and 3.3v only gave me about 10 minutes of low battery notice.  Another very simple option for generating a reference voltage is to make a resistor voltage divider.

Questions? Comments? Leave a reply.

3 thoughts on “Raspberry Pi Low Battery Warning LED Circuit

Leave a Reply