Updated 9/28/16 to add a diode to the LM393
This tutorial assumes you are using the Lithium Charge Module (available from eBay, or Banggood) that was used in the PSPi Version 2 Project. It builds upon the functions of the Soft Power On/Off Circuit and the LM393 Low Battery Circuit. The purpose is to provide an indicator of your battery status and to indicate whether it is charging. Some projects, such as the PSPi, have two LEDs already built in that can be used with this circuit. It was not originally used in the PSPi Version 2 project, but the project has been modified to include it now.
List of Materials Needed:
N-Channel Mosfet on eBay or Amazon
Resistors (R2 and R3) with ohm ratings appropriate for the color LEDs you will be using (not needed for PSPi, since they are already included on the board)
Two different color LEDs or a multi-color LED with shared anode. Use this calculator (link coming) to determine resistor values.
1M Ohm Resistor
Green LED turns when on when the Pi is powered on and the battery is above 25% (or whatever threshold you set the LM393 reference voltage)
Green LED turns when on when the Pi is powered off and the charger is connected and the battery is 100% charged
Orange LED turns when on when the Pi is powered on and the battery is below 25% (or, again, whatever threshold you set the LM393 reference voltage)
Orange LED turns when on when the Pi is powered on and the charger is connected and the battery is under 100% charged
Orange LED turns when on when the Pi is powered off and the charger is connected and the battery is under 100% charged
Green LED always turns off when the Orange LED turns on
The Green LED and Orange LED are off in all other conditions
The power supply module has three LEDs built into it. One LED turns on whenever the module is supplying power to a device, such as the Pi Zero. If you’re using an on/off circuit, such as this one, the LED only turns on when the circuit is powered. The second LED turns on when the module is receiving 5V power and charging the battery. The third LED turns on when the module is receiving power and the battery is fully charged. All of these LEDs are operated by switching the GND connection off and on.
In the schematic , LM393 is coming from Pin 7 (OUTPUT B) on the LM393 circuit. Operation of this circuit is detailed in the Low Battery Circuit Tutorial.
Power for the LEDs comes from the +5V output of the power module. Every LED in the circuit is connected to this output. A resistor should between the +5V and the anode of each LED. The value of this resistor will depend on the type and color LED you choose. If you’re adding this circuit to the PSPi, the proper resistors are already attached to the LEDs, so you won’t need to add them. The N-mosfet is included so that the Green LED turns off any time that the Red LED turns on. This is done here because it will be controlling what is basically a dual LED with a shared anode, and this keeps the colors from blending. The gate of the N-mosfet is pulled high to 5V using a resistor, so it is normally turned on. The ground wire for the Red LED connects directly to the gate, and pulls the gate down to GND. This turns the mosfet off and kills power to the Green LED.
Questions? Comments? Leave a reply or visit the forum.