Powerboost Low Battery Signal and Raspberry Pi

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
wesleyfurr
 
Posts: 3
Joined: Sat May 23, 2015 9:46 pm

Powerboost Low Battery Signal and Raspberry Pi

Post by wesleyfurr »

I have built a digital camera into an old film TLR camera body using a Raspberry Pi A+ and camera module, powered by a Powerboost 500, fed from a smartphone Lithium Ion battery direct to the 5v and ground pins on the GPIO header of the Pi. The last step in the project was to get the low battery indicator working to shut down the Pi.

All the notes I could find indicated that I should simply connect the LB pin to a GPIO input pin, which I did...even though that would seem to send potentially upwards of 4.3v (supposedly full charge of a Lithium Ion battery?) into a 3.3v pin. I created a python script (actually, just added on to one that is already running to take photos, etc) and set it up to blink an LED for 30 seconds, then shut down. It ran for 3.5 hours or so, then when I hit the camera shutter, that apparently caused the battery to dip enough to trigger low battery, and it blinked the LED and shutdown as expected. But...since that time, it has acted weird. The red low battery LED on the Powerboost would come on when I power cycled everything, then it went off when the system finished booting...I assumed the lower current draw allowed the voltage to rise enough that it was then OK. It has progressed now to where the low battery indicator stays on constantly even with another fully charged battery...and the really weird thing is if I disconnect the LB lead going to the GPIO pin, the low battery indicator goes out. It seems to be working just fine, but the low battery indicator is just not working properly...or the Raspberry Pi's GPIO somehow is causing a problem.

Any thoughts? Did I somehow mess up that GPIO pin? As noted, I just connected it direct from LB as was noted in another forum post here...as well as at least two different projects I found others had done using the Powerboost and a Pi.

Thanks in advance,

Wesley

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Powerboost Low Battery Signal and Raspberry Pi

Post by adafruit_support_bill »

The nominal 3.7v output of a LiPo is right around the upper limit of what is safe for the RasPi GPIO pins. But the 4.2v of a fully charged battery is likely to cause damage over time. You can use a level-shifter to keep the LBO output to a safe level. Another option is to use a blue LED to clamp the voltage at Vf (typically 3.2v-3.4v).

User avatar
wesleyfurr
 
Posts: 3
Joined: Sat May 23, 2015 9:46 pm

Re: Powerboost Low Battery Signal and Raspberry Pi

Post by wesleyfurr »

Do you think I have somehow damaged that GPIO pin on my Pi? If I turn it on with the LB pin connected to GPIO, the low battery indicator on the Powerboost is lit. If I pull it off of GPIO without turning off, the low battery LED goes out.

Another forum post says to connect it direct to GPIO:

http://forums.adafruit.com/viewtopic.php?f=8&t=55195

This guy is doing the same thing:

http://garthvh.com/raspberrypi/linux/po ... -Shutdown/

And I seem to recall seeing at least one other similar post... Just confused all around on this...

Thanks,

Wesley

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Powerboost Low Battery Signal and Raspberry Pi

Post by adafruit_support_bill »

If I turn it on with the LB pin connected to GPIO, the low battery indicator on the Powerboost is lit. If I pull it off of GPIO without turning off, the low battery LED goes out.
Not sure how you have your GPIO configured, but if pullups are enabled, it would affect the operation of the LBO indicator circuit.

I haven't found an authoritative source with much detail on exactly what the RasPi GPIO pins will tolerate. It is stated that they are not 5v tolerant. I would expect that prolonged exposure to a fully charged LiPo could damage it. Some sources say you can use a resistor to limit the current when connecting to out-of-range signals. Limiting the signal via level shifter or diode clamp is a safer approach.

User avatar
wesleyfurr
 
Posts: 3
Joined: Sat May 23, 2015 9:46 pm

Re: Powerboost Low Battery Signal and Raspberry Pi

Post by wesleyfurr »

I was concerned about the voltage also as I understood it to not be 5v tolerant and to run on 3.3v....but the other post here in the forums and several other people were indicating it should just be direct connected...

I've got it done as a pull up as noted in the link in my last post (I used their code as a starting point)...though it is just a direct connection from LB to GPIO. My last bit of testing was done with the SD card removed, so it wasn't even booting the OS at that point...unless the Pi stores the GPIO config and restores it at power on time?

Here's how I did it...more in the program than what I've posted, but these are the pertinent parts...it blinks a low battery LED for 30 seconds, then if the voltage is still low (such as getting marginal and taking a photo pushed it over the edge, but then it came back) it would leave the LED on solid but not shut down...though I've not actually tested it since it started acting weird. My original programming just blinked 30 seconds and shut down regardless. With this bit of code included, the rest of my script (which includes a line at the top to turn on an LED as soon as it starts) does not seem to work...I've not tried putting it back the way it was though...so I could have a bug here somewhere.

import RPi.GPIO as GPIO
import time
import os

GPIO.setup(13, GPIO.OUT)
GPIO.setup(26, GPIO.IN, pull_up_down = GPIO.PUD_UP)

def lowbattery(channel):
print "Low Battery Detected!!"
for x in range(0,30):
GPIO.output(13,True)
time.sleep(0.5)
GPIO.output(13,False)
time.sleep(0.5)
GPIO.output(13,True)
time.sleep(2)
if GPIO.input(26)
GPIO.output(13,False)
else
print "Shutting down..."
os.system("sudo shutdown -h now")

GPIO.add_event_detect(26, GPIO.FALLING, callback = lowbattery, bouncetime = 200)

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Powerboost Low Battery Signal and Raspberry Pi

Post by adafruit_support_bill »

Not sure about how 'sticky' the pullups are. But they would affect the voltage at the low-battery sense circuit. In fact, when the batter voltage exceeds VCC on the Pi, the pullup will effectively become a pulldown.

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”