You can go to any dollar store, gas station, big box store, or your favorite Internet retailer and get a USB power bank. It’s a lithium battery mashed into a plastic enclosure with a USB port, probably poorly engineered, but it does serve as a great power supply for the Raspberry Pi. For the Raspberry Pi Zero contest we’re running over on hackaday.io, [Patrick] built a lithium phosphate battery pack that’s much better engineered and has some features a simple USB power bank will never have.
[Patrick]’s Raspberry Pi UPS isn’t just a battery and charge controller attached to the power rails; this board has a microcontroller that has full control over when the Pi wakes up, when the Pi goes to sleep, and can put the Pi into a clean shutdown, even in headless mode. SD cards around the world rejoiced.
The electronics for this project are just a low-power MSP430 microcontroller and a boost regulator. The battery pack/power manager attaches to the Pi through the first few GPIO pins on the Pi’s 40-pin header. That’s enough to tap into the 3.3 and 5V supplies, along with the serial console so power events can be scripted on the Pi.
So far, [Patrick] has made a few time-lapse movies with his lithium battery backup, a Pi Model A+, and a Raspberry Pi camera. He managed to take 99 pictures over the course of about 24 hours, powered only by a single lithium-ion cell. You can check that video out below.
The Raspberry Pi Zero contest is presented by Hackaday and Adafruit. Prizes include Raspberry Pi Zeros from Adafruit and gift cards to The Hackaday Store!
See All the Entries || Enter Your Project Now!
So Impressed :)
I’ve been looking for something to do this for ages! was thinking along the lines of an SLA and PSU with 2 diodes, which could also run an external drive.
Thanks! :)
I hope to be selling these pretty soon. I was thinking the price point would be $20-25. I know that’s as much or more than a Pi, but unfortunately I don’t have the connections they do and need to make a living… ;)
So would you buy one for that price? I’m trying to figure out if it’s worth it to invest in a build…
If I were you I would contact Adafruit… Just ask what would they think about it.
As awesome as this device is, my problem is that I wanted to run a 12v external HDD from the UPS aswell ;/
Yes. Make a few in low volume, have some docs and some code on the pi for auto shutdown and battery level etc, and put it on tindie and see what you get.
Make sure you completely document everything. Copyright infringement can be a scarry mess.
I have got a project about this just around the corner. I just have to put it in hackaday.io
Best thing about mine: no micro…
This project here does have charging which i do not have.
More details ? As I can imagine it right now, it’s just a voltage regulator. Maybe you have included more functionality like shutting down the battery when the voltage gets too low (using some amp op to keep it analogic) ?
It has got rc timers to signal the pi to shutdown and shut down power after that.
the “proper” way of doing it is the use the gpio-poweroff.c driver to set a gpio when linux has shut down
I made a simpler version too http://www.electrobob.com/5up-simple-5v-ups/ There is no low battery indication, but the PI can use a GPIO to know if the input voltage is present and shutdown after a fixed time.
I never could wrap my head around why the Pi wasn’t designed to deal with power loss. Despite being a Linux computer, it’s also a microcontroller for all intents and purposes. Even if the Pi foundation didn’t do that with the first version, certainly later versions of the Pi should have had a way to deal with that design flaw after the foundation saw how their product was being used.
That’s half the reason why I don’t even use mine, the other half is that I can’t think of a cool project to use it in (complete brain failure).
The issues with power loss are not specific to the Raspberry Pi, they have to do with Linux.
https://www.embeddedarm.com/about/resource.php?item=459
There is nothing you could do in hardware alone to fix this.
For an ideal “back up” battery you would want to utilize a Lithium-Thionyl-Chloride cell. Yes they can not be recharged, and are only suited for extremely low discharge use (sub 1 mA). But they can last an extremely long time. Some even ~20 years provided they’re maintained and used correctly.
Unless you really need the voltage or energy den$ity or mil$pec reliability of the Thionyl cells, you may be better off these days just going with LiFeS cells, like http://data.energizer.com/PDFs/l91.pdf — you get the 20 year shelf life and low temperature performance, but you also get enormously greater current capability.
Of course, 20 years of backup is not really the point of this project. A Lithium-Thionyl-Chloride cell would not run a power-hungry beast like a Raspberry Pi for more than a couple of hours either! *lol*
The Lithium Iron Phosphate chemistry works well for this because it provides 1000-2000 recharge cycles and doesn’t mind staying at the float voltage as much as other lithiums.
Thanks so much for featuring my project on the blog Hackaday! :) I was wondering what happened that made me get 20 new follows and 15 skulls overnight! *lol*
I’m hoping to either do a Kickstarter or just run a build to have these available in my Tindie store real soon.
Since this project has an unusual amount of attention at the moment, a couple of questions for potential users:
This provides UPS functionality, an hour (RPi2) or better (2:30 on Model A+ and PiZero) independent run time, provides clear power down with touch button or when power fails, and has a (somewhat inaccurate) wakeup timer. Anything I’m missing that would be really useful?
Since your oscillator pins are free, why not add a 32.768KHz oscillator and make it a RTC as well?
Excellent idea! I could probably add PCB edge connections for that.
Downside is that the low power oscillator will be running at 32 kHz instead of 12 kHz so power consumption in sleep mode will be a little higher. But adding RTC functionality and making the wakeup timer accurate is probably worth it!
I will probably need to upgrade the micro from the 1K to the 2K version since the flash is completely stuffed as it is. :)
I’ve been looking for a decent board that does charging/low battery detection and RTC. Preferably that can be configured for whatever high capacity battery I can find … but I guess that would explode the amount of complexity of your project?
Not necessarily… The base LiFePO4wered/USB board has been used by customers with much bigger cells successfully. It takes some hacking, but this IS Hackaday after all. ;-)
In principle I could also provide the top board (the Pi power manager) by itself if you bring your own battery and charger. It has to be LiFePO4 though since the micro is powered straight from the battery and other lithium chemistries reach too high a voltage during charge.
That sounds an excellent idea, splitting it into power management + rtc / charging circuit.
This would definitely make me get a couple. I’ve got a couple of PIs that could use a good battery backup and RTC.
I’d buy one of these for my PiZero project for sure.
This seems like it’s entering into territory better suited for a C.H.I.P with its rather nifty-looking onboard power management and LiPo support. I know they’ve been pushing a bunch of code upstream to support that natively in Linux too. (Unfortunately I haven’t managed to get my hands on either that or a Pi Zero yet.)
There was a succesful Kickstarter campaign in 2014 for a product called MoPi which seems to have similar functionality as this but with additional features. Created by Sheffield University based in the UK. They are already commercially available and have been for a long time. I currently have one running a time-lapse camera. If you are based in the UK or Europe it might be worth taking a look at.
Seconded – I used a MoPi for a time-lapse project too :) Link below, Pimeroni distribute these, costs £25. They don’t handle charging, though the team involved have given people pointers for how to add that if wanted, it is meant to be used running off dual battery or mains+battery (as a UPS).
https://pi.gate.ac.uk/pages/mopi.html
Or you can get just a Chinese board with everything built-in http://lb9mg.no/2015/06/28/banana-pi-on-battery-power/
We need more projects like this!
I have lots of 18650 cells but I don’t use them because I am worried they will catch fire/explode. I’d love to have a project that uses more cells, charges and cuts off when the voltage is low.