[PASS] Banana Pi Self-managing Uninterruptible Power Supply

13 14961
Edited by DIYMaker at 2014-10-23 00:23

Name: Banana Pi Self-managing Uninterruptible Power Supply

Open-source project: Yes

Distribution License: CC BY-SA 3.0

The application number: 3 pieces

Applicant self-introduction:

We are three developers of medical information systems software in South Africa. We run servers in hospitals that capture, store and deliver medical information to clinicians computers and mobile phones. We would like to install our system in small remote clinics and hospitals because it help clinicians care for their patients more effectively, but there are some major problems with using information technology in rural Africa:
1. Power supply is is lost frequently for hours at a time.
2. Internet connections are expensive, low speed and unreliable.
3. It is difficult to maintain hardware in remote areas.
4. Equipment is often stolen.

To solve these problems, we ported our software to Arch Linux on a Raspberry Pi. It solves all these problems:
1. Raspberry Pi uses little power and can be kept running on a lead-acid battery during power failures.
2. A local WiFi hotspot lets clinicians access medical data without using the Internet.
3. A GSM dongle can allow us to maintain the system remotely when Internet is available.
4. The Raspberry Pi is small and can be hidden in the roof or in a locked cupboard.

But we have also found problems using the Raspberry Pi:
1. Even overclocking CPU to 1GHz, it runs slow and cannot connect many simultaneous users.
2. The WiFi connection is intermittent.
3. It has no SATA storage.

Then we read about the Banana Pi at http://hardware-libre.fr/2014/06 ... anana-hardware-duel and http://hardware-libre.fr/2014/06 ... nd-sata-performance. The Banana Pi appears to have the stability, power and storage capacity to perform as a server for our purposes.

However there is still one more problem to solve - it must be able to manage its own uninterruptible power supply (UPS):
1. It must detect and notify a loss of AC power.
2. It must monitor the UPS battery voltage and perform a clean shutdown when the battery is 50% discharged.
3. It must switch back on when the AC power is restored.

This is tricky, but possible:
1. We propose designing and building a UPS circuit with 220VAC input, 12VDC lead-acid battery and 5VDC 2A output.
2. The circuit will generate a resistance based on battery voltage that will be connected to the Banana Pi MIC input.
3. We will write a script that monitors the battery voltage for fluctuations, notifying by email when AC power is lost.
4. When the battery is 50% discharged, the script will perform a clean shutdown of the Banana Pi.
5. When the circuit detects no power consumption, it will cut the 5VDC output and will only resume it when AC power is restored, booting the Banana Pi in the process.

The open source content and the first distribute website: Circuit diagram, scripts and documentation at http://forum.lemaker.org.
Single Polls, Total 27 Users voted View Voters
0.00% (0)
100.00% (27)
Your User group have no permission to vote
Great project. As I'm working on a similar idea (mainly for RPi) im looking forward to get more informations from you ;)
Will your system also include a charging system for the battery ?


Hi Adun

Will your system also include a charging system for the battery ?

Yes, although it will not fast charge at 14.4V; it will just deliver a constant 13V float charge using a regulator like LM338.

The input voltage will be from an off-the-shelf 220VAC->16VDC PSU. We don't want to put the transformer on the board as transformers heat up and can burn out, so we don't want it anywhere near the Pi and UPS.

Have you received the Banana Pi?

The Banana Pi has alreadfy an On-Board Power Management which can handle a Li-Ion Backup Battery. If connected, it will stay on after power loss and it will charge the battery automatically while powered.
I wrote some C-Code to monitor the power and handle the features of the power management chips. I'll contribute it as GPL Free Code into this project.

gwaihir replied at Fri Jan 2, 2015 13:23
The Banana Pi has alreadfy an On-Board Power Management which can handle a Li-Ion Backup Batt ...

I am looking forward to it.

Edited by gwaihir at Sun Jan 4, 2015 14:09
tony_zhang replied at Sun Jan 4, 2015 00:17
I am looking forward to it.

O.k. here we are.
The C-File can be compiled with "gcc axp209.c". The generated "a.out" file is the executable, you can rename and copy it with "sudo" to /usr/local/bin.
Before, you can test it with "./a.out". It will show the options.
To get it really to work, you must call it as superuser: sudo ./a.out.

You should connect a LiIon battery (single cell, 3.7V) to the BAK Battery Pins:
Picture how to contact.

The scripts shown in this Forum entry have some bugs: Charge and discharge current is swapped and the discharge current is
2x too high. I verified the values of my code by actually measureing the currents and voltages.

If you like to have more infos, consult the data sheet of the AXP209 here

After connecting the battery, you can check the status with "sudo ./a.out all"
For normal LiIon Cells, you don't need to change anything. The Banana Pi as already configured to charge the cells and switch
power to battery supply after disconnecting the main connector.

It you want to change the charge current, be careful: The chip cannot handle too high curents and your USB supply must be able to
provide that additional curent.

sudo ./a.out monitor&  will start a background process shutting down the Banana Pi after disconnecting the power.
This could take some minutes if the network-driver is waiting for closing open connections....

Have Fun !


5.19 KB, Downloads: 179

Edited by Skipper_1024 at Thu Mar 12, 2015 11:13
gwaihir replied at Fri Jan 2, 2015 13:23
The Banana Pi has alreadfy an On-Board Power Management which can handle a Li-Ion Backup Batt ...

Where on the Banana Pro would you attach the Li-Ion Backup Battery?
Also how many volts should this battery be outputting?



Edited by brousant at Sun Mar 15, 2015 06:50


You can connect a single cell  (3.7V) Li-Ion battery to the Banana Pi as described on http://hardware-libre.fr/2014/11 ... y-power-monitoring/

In Bananian, I am running this really simple script from rc.local:

while :
        if grep -q 0 /sys/class/power_supply/ac/present
                echo "ac is not present, shutting down..."
                shutdown -h now
                sleep 100
        sleep 1
exit 0

Now, when the AC input is down, the BPi, continuing on battery power, performs a shutdown. And when the AC input comes back, it restarts.
I also reconnected the AC input while the shutdown was still in progress. I was pleased to see that in this case as well, the BPi came back on without a problem.

This pretty much satisfies my requirements for Banana Pi UPS functionality, which are mostly that the SD card is protected from corruption by sudden power loss, to an extent that the Banana Pi is not able to start up anymore when power comes back (this is reported to be a problem with the Raspberry Pi and I assume it is not different with the Banana Pi).

I think the major drawbacks of this solution are
- requires soldering to the BPi, since a battery connector is not mounted by default
- does not provide uninterrupted power supply to a SATA drive (the SATA drive power comes directly from the AC input)

With respect to the second drawback: with a conventional hard drive, this may not be that much of a problem; the data on can probably be sufficiently protected by running a journaling file system on it such as EFS4. With SSD's it would be a different story.

Best regards

Thanks for you quick reply.
Its a real shame that the banana pi/pro don't have a battery connector on-board that you are able to just plug in a 3.7v Li-Ion battery into to use as a battery backup in case of an AC power failure. And so that the user doesn't have to solder connectors onto the board. Makes me nervous when all the parts are so close to where you have to solder.  Maybe we can suggest it to LeMaker to take it under consideration for the next board model (If they are making another, I have no idea).

With much thanks,

You have to log in before you can reply Login | Sign Up

Points Rules