20 Replies Latest reply on Aug 16, 2020 9:03 PM by onewhocandraw

    PowerBoost Low Battery Output to Safely Shutdown Raspberry Pi


      I've got an Adafruit PowerBoost 1000C and I'd like to connect the LBO (Low Battery Output) to a Raspberry Pi GPIO pin to detect low battery and shut down safely. I'm using a 2500 mAh battery.


      What I think I want is this:


      PowerBoost LBO -> diode -> resistor -> GPIO


      I have a few questions about this:


      1. I'm using the diode to prevent current flow back into LBO, which I've read can cause the low battery LED to light up at the wrong time. I have some 1N914 / 1N4148 switching diodes. Are these appropriate for the task?
      2. What resistor value do I want to use? I think Ohm's law is relevant here, but I'm not totally sure what values to plug in and why.
      3. Is it better to have the diode before the resistor like above, or should I reverse those? Does it matter?


      I saw a recommendation not to source or sink more than 0.5mA into an input pin. In that case, it seems like a 10Kohm resistor would be appropriate (4.2V / 10000Ω = 0.00042A) since 4.2 is the voltage of a fully-charged LiPo and 0.42mA is close to 0.5mA. Am I thinking about this correctly?

        • Re: PowerBoost Low Battery Output to Safely Shutdown Raspberry Pi

          It just occurred to me that 4.2V is also higher than the maximum safe voltage of 3.3V.


          So now I'm just confused. Is it possible to limit current to 0.5mA and voltage to 3.3V with a single resistor, or do I need to introduce another component somewhere? As you can see, my basic electronics knowledge is lacking. Any help is appreciated.


          As a side note, I'm not positive that 0.5mA is really the limit for GPIO pins on the Pi. I've also seen 16mA in places, but I can't find the official spec.



          2 of 2 people found this helpful
          • Re: PowerBoost Low Battery Output to Safely Shutdown Raspberry Pi

            Hi Andy,


            You're right, some resistor based circuit is needed to get that 4.2V down to a usable value. You can do it with a potential divider circuit, e.g. have a 10k or 12k resistor, and put a 33k resistor in series. Connect one end of the 10k or 12k resistor to the LBO pin (which is being pulled high as you say, up to 4.2V), and connect the other end of the 33k resistor to ground. The junction between the two resistors can be directly connected to the Pi (first confirm with a multimeter that you see a voltage of around 3.3V at the junction). No need for any other resistors/diodes etc hopefully. If you have a multimeter, you can check that the junction voltage drops to close to 0V when the battery voltage reduces. Provided it goes to less than 0.8V, the Pi will detect that as a valid logic '0'. The exact voltage levels I'm unsure of, but definitely by being under 0.8V, the Pi should see the pin as a logic '0'.

            One thing to bear in mind is that some small amount of current will flow through the resistors even when the system is off, so the battery will slowly drain - but it could be low enough not to worry, depending on your use-case. There are ways around that, but they involve more circuitry (a MOSFET) or tapping off the connection elsewhere.But hopefully it will work well enough to get you going for now. There are some input/output interface circuit ideas by the way for the Pi here: Raspberry Pi GPIO Explained


            EDIT: I just checked the IC datasheet, and the datasheet for the BJT on that board (I should have done that first), and looks like the internal resistor is about 47k. So, the values above are too high. Please ignore it all.

            Here is an easier approach that will work and needs just one resistor.

            Connect a 100k resistor between LBO and ground. Then connect LBO to the Pi. You're all set.

            8 of 8 people found this helpful
            • Re: PowerBoost Low Battery Output to Safely Shutdown Raspberry Pi

              I tried Shabaz's idea of putting a 100K resistor between LBO and ground in order to connect the LBO output to a Pi.


              Prior to adding the resistor, I read about 5V at the LBO pin.  The docs say "By default it is pulled high to BAT", but since BAT reads 4.2V I'm a little confused. I see that on the schematic Vbat is not actually the battery voltage (that's Vlipo), so maybe this is just some confusion between the PCB labels and the schematic (so the pin labelled BAT on the PCB is actually Vlipo, and LBO actually tracks Vbat, which is exposed on the pin labelled Vs).


              After adding a 100K resistor between the LBO pin and ground, I see:


              - The LOW LED goes on immediately.

              - I read about 4.2V at the LBO pin.


              That doesn't seem to match the discussion here. Does this seem unexpected, or am I just misreading this thread?



              1 of 1 people found this helpful