Uninterruptible Supplies

Need a power supply with battery backup that shuts off your PI or similar gracefully when the battery gets low and starts up when the battery  recovers? I’m sure most of us who play with the likes of Raspberry Pis and other SBC boards as well as other devices, have looked at uninterruptible supplies at one point or another – I often use the little battery powered chargers you get for phones – and until recently I thought that was a universal solution – having powered my Pi in Spain for many months now on one of these and we get awful power cuts there – no problem.

Latest update 23/07/2017

Lithium chargingThen someone pointed out to me that SOME of these units turn off the output when charging. Well of course they don’t ADVERTISE that – so that’s a problem if you’re looking for cheap options.

So today I received from BANGGOOD a cheap circuit board that promises to do the job. As it happened my one and only Lithium in a torch left in storage over the winter had kicked the bucket… but I remembered I had a spare but dead battery pack for one of my laptops – and proceeded to open it up. Sure enough half a dozen Lithium batteries in there.

I took one out that looked clean – dead. Put it on my big power supply for a couple of minutes at 2 amps – it looks ok.  So now I’ve attached it to this little board and plugged the board into a decent USB supply. one of the little chips is getting a little hot as it pumps power into the board but I think it will be fine (update once the battery ha some charge this cooled off – then running a FriendlyArm SBC nothing at all got warm).   So after it had been on for a while to give the battery a chance to get some power, I plugged an SBC into it’s output. You can see all of this in the picture above. Worked a treat and the little board settled into a blue-flashing-light mode after a few seconds.   I repeatedly disconnected the incoming power – no difference, the SBC just kept going.

So if you want something new to play with…. and you’re aware of the dangers of going within 100 miles of Lithium batteries – you might want to give this a shot. At £2.37 inc shipping – you can’t really go wrong provided you give it a damn good test before doing anything serious with it.  I think I may make a little bank of them with the remaining Lithium batteries from my power pack.


I’ve had a look to see if I could identify the bits – the battery charging chip is easy and monitoring (2 of them) but can I hell figure out what is used to provide the 5v out boost.

But there is a catch! I only just discovered this...  If the battery is TOTALLY DEAD and you start things up - nothing happens - the battery doesn't charge - the load does not come on. Disconnect the load for a short time and the battery immediately starts to charge and you can now reconnect the load.

This got me to thinking about a solution and in keeping with the ultra-low costs above, here is my ultra-low cost solution..

An Arduino Nano with relay (total cost around £3 from AliExpress) can control the output of the unit via the relay. The analog input (A0) can attach to the battery while the NANO is driven by the output of the unit.  The ultra-low current consumption of the NANO when the relay is off should prevent issues....  so what is needed is this - when the power gets low, this unit should alert the Pi to shut down..  it does this with a GPIO bit (D11 in this case) and optionally via serial - a nice way to do this would be to output a JSON package.

Here is an example of testing the little board from power up..


So the output message is init - and stays that way - the power is seen to be adequate - and a timer starts - after X seconds the relay turns on. Next, the battery is seen to be low - a timer starts and a warning GPIO bit is turned on  - the Pi could depending on your software, choose to use either the serial signal or the digital input - and shuts itself down.  In my case, serial was out so a simple port input was used instead.

The output from the NANO then goes low and stays low until the battery voltage rises significantly. You HAVE to have "hysteresis" in there - i.e. a difference between ON trigger voltage and OFF trigger voltage as the battery is going to recover a little the instant you turn off the load.

Now then there is an important point here - the NANO in this case is running on 5v... and the Pi will be 3v3 - so in the case of the WARNING OUTPUT and the SERIAL OUTPUT if you use one, the other or both you will need LEVEL SHIFTING - the simplest being a pair of resistors - that is a resistor from the NANO output to the Pi and a resistor from that PI pin to ground - as you don't want 5v going into the Pi - the maths is simple - I'd make the first resistor say, 10k and the second (grounded) resistor, say 15k.  In my case I just used a simple serial 1K resistor to limit current.

OLED display on controller

What we have here is an AliExpress OLED display costing just a couple of pounds, a cheap supply as mentioned above – running on a single cell and running on an Arduino NANO.

For the OLED, the Adafruit library uses WAY too much RAM but this little number doesn’t.. https://github.com/greiman/SSD1306Ascii

Here’s a link to the little OLED display -  on a cheap Chinese Nano it uses pins A4 and A5 and you need to use a couple of pull-ups to 5v for the i2c. I used 2k2 as they were handy  - https://goo.gl/nXjpxd (another – possibly slightly cheaper https://goo.gl/PO0GiO)

Code here https://bitbucket.org/snippets/scargill/XLeLE

This unit also lets you set the max and min voltages and this is stored in EEPROM. I’m using 3.7 and 3.1 by default. Pins to ground for the controls are D5 for set, D6 for up and D7 for down.

And here’s a diagram kindly provided by Antonio, aka MrShark (on this blog comments) who’s been closely following this project! If you’re on a PC you can expand these images by clicking on them. Power supply is just the nearest available and does not represent the current supply you see in the photo above.

As for getting the Pi or whatever controller you are using to listen to port inputs – if you’ve a genuine Pi that should be no problem – I was using a NEO2 – not quite so simple until it all started to sink in – read this entry for more about accessing GPIO - https://tech.scargill.net/gpio-the-hard-way/


Disclaimer: if this blows up your Pi – or worse – blows up – it is on your head! If you don’t understand the above – don’t do it. Make sure you have everything working and polarity is correct before attaching anything expensive.

Incidentally if you want to roll your own and find the above  text-only library for those OLED displays a bit limiting, the Adafruit lib is no good as it takes WAY too much RAM. The u8glib library on the other hand uses <400 bytes of RAM and has full graphics capability – here it is – I ran their standard test and it ran no problems – https://goo.gl/e2yVNM – if on the other hand you want speed, stick with the one I’ve used.

Since I came up with the circuit we’ve seen several other supplies and I bought one of those WEMOS supplies- well, not surprisingly, as no-one is doing anything original, this one fell WAY short of claims-  check out this video and thanks to Antonio for pointing me to this – https://www.youtube.com/watch?v=aND0j2Y2IkM

I still think my clumsy NANO solution is a good one – now that there is an ESP8266 with OLED display built in – this might be a better way (still needs a relay and the ESP takes rather a lot of current)… on the other hand I’ve recently had a situation back in the UK where a PI has TWICE developed an SD issue that can’t be sorted by rebooting and needs to be sorted by power cycling – possibly the ESP+OLED solution could be used to handle the battery as above and act as a watchdog. With up to 8 lines of tiny text on the OLED there’s plenty of room for info.


135 thoughts on “Uninterruptible Supplies

  1. I was looking for a cheap solution for a long time 🙂
    I order from this module and will try
    Thanks for the sharing

    1. There's a 4056 and several other chips on the board. The 4056 is presumably the one that handles charging - I'm not sure what handles voltage conversion to bring the output up to 5v - whatever it is, it does a good job.

  2. Would this be a reasonable option for solar charging?
    I'm looking to power a project with a couple of 18650 cells, with a solar panel to charge them, but I was running into the "no output while charging" situation you described.

    1. I see no reason why not but there is a pair of input pads - I'm wondering if they'd be better suited to variable input voltage than the usb input. Perhaps someone familiar with the 4056 could comment?

      1. I'll rephrase that - it seems like the chip is expecting something around 5v input... so you'd need an extra stage - a switching downconvertor - mind you, they're only around £1.50 - I've seen them handle an amp output - taking in anything from 5v to 30v - might check the same supplier. Each of these stages of course reduces efficiency but if you have a big enough solar panel (as, funnily enough I do - I've a couple of 12v (generating up to 18v) 40w panels... I dare say this board and one of those step down boards together would do the job for solar.

          1. Agreed on that tiny solar cell. I have one from Ray-o-Vac, made for outdoor trail cameras, that I want to use. Just took it outside with my meter and it did a steady 11v at 105mA, so with a step-down converter, I should be in good shape.

  3. Does the 'Mini USB To USB A Power Supply Module' have a status pin that you can connect up to one of the GPIO pin's on the SBC and shut it down after x seconds when it is on battery, like a normal ups?

  4. I have something similar for my projects for recharging but I've found I can power my project at the same time I'm charging although the device is battery powered and the mains just tops it up.

    I'm using to power my remote temperature display so that I just keep it on top of a QI wireless charger pad and it will run for around 4 days when removed. (I'm sure I could get it to run longer if I revisit the code)

  5. I'm still searching for my perfect Pi UPS. For something so simple, it seems many people want to make it really complex. I think I'll end up running one of them from one of the little switchmode "buck" regulators that you can get for a few dollars from China. I can then diode or a 9v power supply and a pack of 8 x 1.2v NiMH batteries onto the input to the regulator.

    I came across this project - I'd be interested to see if anyone else is using one? https://pi.gate.ac.uk/pages/mopi.html

    1. The most likely cause here is that you did not install as user Pi and/or you were not sitting in the /home/pi/.node-red directory when you installed it.

      The folder should be in /home/pi/.node-red/node-modules folder. Just delete the folder and try again.

  6. This is a great little board. It's been working well for me for the last 3 weeks.
    I noticed one potentially troubling behaviour, though:
    I have a bank of three 18650 cells connected in parallel, with an Arduino and sensor shield.
    I left it running overnight to drain, which it did. The Arduino, of course, shut down.
    I connected it to power to charge, which it did, however, the power to the Arduino did not restart until the Arduino was disconnected and reconnected.
    I need to do some more testing to see if I can reproduce it.

      1. Wired up another module, this time to a single 18650 and attached my Arduino and shield (about 1.8 A load) and let it run down.
        When I plugged in charging power, once again the Arduino did not come back to life automatically. I let it charge for a bit and it still did not. I pressed the Arduino's reset button and this didn't work, but disconnecting and reconnecting the USB *did* let it restart.

  7. Thank you for posting about this little power supply board, Peter. Just what I was looking for...

    Cheerful regards, Mike

  8. An outstanding share! I've just forwarded this
    onto a friend who has been doing a little research on this.
    And he in fact ordered me dinner simply because I found it for him...
    lol. So allow me to reword this.... Thanks for the meal!!

    But yeah, thanx for spending time to discuss this issue
    here on your web page.

    1. Thanks Michal - that link actually seems to have a nice charger... but for one thing - they say 2 amps output (that would be at 5v) - but at the same time say 0.5amps charge current at 5-8v.

      Hmmm.... no warning signal for the Pi to shut down either...

      The more I read about these things the more I'm inclined to get the PCB design package out 🙂

      Nice and compact though...

  9. According to my humble opinion, the solution with lithiums lacks the elegance i learned to love in your blog.
    My recommendation is the use of supercharge-capacitors with these chinese 5V step-up convertres as described in
    "https://www.stall.biz/project/usv-fuer-homematic-ccu2-und-raspberry-mit-wirkungsvollem-ueberspannungsschutz" .
    I think google translator will offer the clever solution decribed in there ( as it´s unfortunately written in german language ) .
    And´it´s in my opionion a clever straight forward solution. Any raspberry, ESP .. only needs to spend one I/O pin with 2 resitors as voltage dividers to detect voltage failure. And the software needs ( or even has to try ) to send the last MQTT power failure message and start the controlled shutdown of system.

    1. Hi Klaus

      I've had a preliminary play with supercapacitors and buck convertors with no joy. There are no doubt elegant ways but none of them seem to be particulary cheap. There is little point in getting one of these £20 boards then spending £40 on backed-up power supply for it... hence I'm hoping discussing in here will provide at some point one or more cost-effective solutions for hobbyists. My little test board is actually working a treat - the reason I've gone quiet is I can't get the serial ports to work on the FriendlyArm NEO2 🙂 Indeed I've just written to them to ask the point of providing a board with so much IO and no drivers to make use of it.

  10. did my best with (the beast) Fritzing, was my first design (under indications of Peter about some errors and later additions)... now i understand why so many hate it (crashed 2 times, with partial recovery on restart...) and prefer Eagle or others... but this is the only i know with a breadboard view for easier understanding (not everybody knows real electronic components symbols...)

    note that the serial connection is not reported on schematic, in case you use it you better add an other limiting resistor on the line which goes from the TX of the arduino to the RX of the SBC you're using, as most of them are 3.3V and not 5V... no need for reverse sbc tx-->arduino rx as it's not used and anyway the arduino can detect a 3.3v signal as HIGH anyway, no problem here... but, as said, not used in this case...

  11. I considered https://www.tindie.com/products/xorbit/lifepo4weredpi3/ because it does say in the description:
    -An auto-boot feature to maximize uptime by making the Raspberry Pi run whenever there is sufficient battery power or when the USB input voltage is present.
    -An auto shutdown feature that makes it possible to automatically shut down the Raspberry Pi when the USB input voltage has been removed for a programmable amount of time.
    But yes a bit more expensive....

    1. But thanks Scott for bringing this into the discussion. I noted they state 1.33 amps. Is that really going to be enough for the Rasperry Pi 3 and can it be used with other boards? Often manufacturers of these boards state you should have a 2 amps power supply.

      So - one or two options out there, but we keep looking. Basically there is nothing stopping anyone with PCB skills taking what we have here now and making a new PCB to do the job... but I would like to see something that remains pretty low cost, now I'm used to it I do like the idea of the display.. and I'd like to see the ability to handle 2 amps. Some useful comments on that Tindie links about batteries!

      Something that is REALLY nice about that Tindie project - is the SIZE.. the board is tiny...

      1. Pete, I would also not buy the finished product and yes, I did see the limit which I think comes from the LiFePo battery he is using and not from the MIC2876 boost regulator with a 4.8A switch. Add a good heat-sink and a LiFePO4 26650 or a LiFePO4 32600P battery and you are better off. I am also looking for a better solution so I am thinking of hacking this one.
        In https://hackaday.io/project/9461-lifepo4weredpi he mentions he made a board to use the TI TPC61235P, which is a significant step-up to the MIC2876. I will ask if he will sell a few boards.

        1. I see what he's done - well, having gotten to grips with the monitoring side now - all I need is a very basic charger/buck convertor to provide the 5v... pref at 2 amps....

  12. So - monitoring and control cracked - what is now needed is the simplest possible circuit for a charger and boost-to-5v circuit able to simultaneously charge and power the load - but able to power up to 2amps - and pref with a logic control of the output to save having to use a relay.....

    Thoughts anyone.....

  13. I did think of a better way to do the status if one didn't want the LCD. Instead of using 1 light.. use 2... red and green - so red is standby, red flashing is considering coming on - green is on - green flashing is warning the micro it is about to shut down.... I think that's better and means in general use, no flashing lights.

      1. I would be inclined to use a serial RGB LED for that.. but I think folk are more likely to have red and green LEDs lying around. All my serial RGBs are SMT. Anyway the software is simple enough to do any of those based on a flag.

  14. I've found this page providing a nice comparison of various power supply solutions available for RPI UPS.
    Most offer finished products, however some are open source. You can review what has been tried.

    The TPS2113A autoswitching power multiplexer, also looks like a very helpful little IC. It allows to "switch seamlessly between two power sources of 2.8 V to 5.5 V while blocking reverse current into either source."

    1. Hey thanks for that Michal - the LIPO versions of these still seem to think 1 amp is enough (or less in some cases).... designs must be before Pi3 (though most of the boards I get these days recommend 2 amp supplies). I'll check all the links.

    1. But you see... THAT is the problem - these things are 10 a penny and are usually based on similar chips - but the specs are so vague you can't really tell and being Chinese your chances of getting a dialog with the supplier are slim. Two questions always to try and get answered - CAN it supply full power AND charge at the same time - and WHAT happens if the battery is FLAT - will it start up with a load connected - many will fail one or both of these challenges - presumably just due to lack of thought in the design process.

      So this looks good but the display is little more than a gimmick as it doesn't do anything. I'm wrestling with the idea of getting a little board made or encouraging someone to get one made - with my little OLED - maybe something that could pin onto the back of the Nano - and I only say THAT because the NANO is so cheap it is hardly worth duplicating. Actually there's a 4 line version of that OLED which is even smaller which would INDEED mount on the back of a Nano... I'm wondering how much degradation I'd get by using a P channel MOSFET to supply power to the Pi...mainly as it would be 10x smaller than a relay, not for any other reason.

      1. I wish we had schematics for some of these - on that board in question I can see the charge controller - and I can see what looks like 3 mosfets - but I can't see the bit that provides the output - surely that must have a chip.

      2. I ordered one. Testing and reporting in... 45 days? 🙂

        I am currently using a nice powerbank. One of those that keep powering the Raspi even when you plug and unplug it from the charger.

        I has been working flawlessly for more than a year, but it is a bit expensive for 'massive' deployments.

  15. Had a similar problem for a car dashcam. My car has start/stop and cuts power to the cigarette lighter socket during this. This was causing the camera to sometimes stop and not restart.

    I got 2 £1 usb powerbanks, and took the battery out of one, and wired it to the battery of the other powerbank, ie share the battery.

    One powerbank is now able to supply power via usb, and the other can be used to supply a charge at the same time, whereas they often cut output during charging.

    Cheap, and works well for me.

    1. Hi Paul

      So I'm looking at this on the English language site - https://goo.gl/KM6Q0i

      Around a tenner.... Not sure what Tesla's batteries have to do with anything as he doesn't exactly sell them in your typical Chinese outlet... however... "the output can reach 2 amps" - does that mean it can PEAK at 2 amps or that it will handle 2 amps... no sign of any heat dissipating arrangements. 0.5 amps charging current - they all seem to be tarred with this brush... so let me do the maths - starting with a flat battery.... (mains went off overnight....) and another power cut is coming along - you need 4 hours charge to get 1 hour out at 2 amps. I guess that's being picky but I do wonder why that limit.

      5v to 8v input is good - that means at a pinch you might be able to supplement things with solar input... that would be good. I'm assuming this then is merely a power supply - and not any kind of monitoring or having any kind of alert system which basically puts it on a par (though a lot neater) with solutions out there but POSSIBLY with that advantage of greater output.

      Would LOVE to hear from someone who can give this a good hammering and check the 2 amps claim, check if it will start up from dead etc.

  16. Searching for a different thing I bumped into these cheap UPS/Powerpack hats.

    Description (UPS board) says:

    - Can be charged and supplied power to raspberry pi at the same time.
    - With 4 LED power indicator;
    - Provides an example code to beginner to demonstrate how to demonstrate battery capacity displays the current battery level in the raspberry pi
    current program, it can detect the current battery, voltage etc.
    -- Applicatoin scene 1: You can program to control automatic backup of data at low power and safe shutdown.
    -- Applicatoin scene 2: Remind users to charge at low battery levels. etc.)
    - Removable battery, user can choose a more larger capacity lithium battery pack (NOTE: voltage must be 3.7V).
    - With safety protection circuit to prevent overcharge and over discharge.

    UPS hat: https://www.banggood.com/Geekworm-UPS-HAT-Board-2500mAh-Lithium-Battery-For-Raspberry-Pi-3-Model-B-Pi-2B-B-A-p-1105260.html

    Powerpack hat: https://www.banggood.com/V1_0-Lithium-Battery-Expansion-Board-For-Cellphone-Raspberry-Pi-3-Model-B-Pi-2B-B-p-1059297.html

    Comments are a bit scary, however 🙂

    1. the second one seems the one that Peter tested and was rubbish... you can find in other blog posts a photo where Andreas Spiess added a capacitor to try to not have it power down the pi, but even so is not ideal for rpi3...

      for both: none of them arrive at 3A, they talk about 2A or 1.8A, and NOT saying if it's continuos or only peak usage...

      a good ups have to have these features:
      1) 3A stable, or at least 2A stable and 3A peak...
      2) can be charged WHILE using it, without causing a reboot...
      3) startup the pi EVEN if battery is low, if charging power is back... many of these will not work if battery is flat and load is connected...

        1. It does indeed seem that way. This phrase needs clarification "When you click once the button, charging work will start and LEDs will show the dump energy. When you keep clicking the button over 2.5s, output will stop."

          Erm, what? Does that mean you have to press a button to start off charging? surely not?

          1. i think they just wrongly wrote... as they talk about dump energy... i think the button is to just start the power delivery FROM the battery to the load, but this is a problem anyway, as if battery goes flat and then power returns and start charging, even if charged, who will press the button to start the attached device???

            for rpi shutdown, as the board has 4 leds, you can test when the led just before the latest goes LOW, so you can trigger the shutdown... something Andreas Spiess did in 1 of his latest videos, using a 4 bars battery indicator

  17. so, my little board arrived... initial post: https://tech.scargill.net/a-question-of-lifespan/#comment-34547 (i took the model for 2.5A output, has a little lcd on a side)

    little soldering (some photos here: http://imgur.com/a/qjJt3 ) attached to charge, it says 032 (display is upside down, the photo with 001 was of a faulty battery, then changed...), i think it's a percentage... now it's at 074...

    while it's charging, i attached a little load, an usb flash light... no light at all... leaved light attached, disconnected charging cable, light came up... reattach charge, light off... very disappointing...

    to test the actual amps it can deliver, i'll wait it's charged... side note, don't know what's that button, as does nothing while charging, nor it does while serving power...

    1. Oh I would think that Nano gadget I made would do the job nicely. If they only problem it has is not starting up from flat, the simple solution indeed is for the Nano to turn off the load (except it's own very small load) before the battery gets to that point - and then not turn it on until the voltage has increased significantly and that's just what my little nano project does.

      1. no, the flat test was not done yet, as i just surrendered when i attached the load and it did not start until removed charging power... it works as many powerbanks, no output while charging... can we bypass this step? if yes, i'll do the remaining tests, otherwise they're worthless... 🙁

          1. do you think that monitoring battery power and using your nano setup to send the shutdown signal to the raspberry, and after 1 minute powering on the charge via your relay, is a viable thing? This way the PI is already shutted dows, so no problems when starting charge will disconnect server output power... when it' fully charged (or above a certain %, let's say 98%), disconnect the charge so power will go out from the battery and restart the PI... only BIG problem I see, this way the board will always be powered by battery and then shutted down while it's recharging, then again restarted, and so on... no, not good, at all... 🙁

  18. I think part of the problem we see is that none of these boards was designed for the purpose we want to use them for - most of the ones on Ebay will be from discontinued products or excess production or whatever. The problem is that if one of us tried to make one - the costs would vastly exceed anything the Chinese charge. I note that many of them use little controller chips with no attempt to utilise the PCB for heat dissipation - something that would cost almost nothing to implement. Anyway, so the ones that won't charge and run at the same time are suitable for the waste bin only - as for the rest, if nothing else my little Nano solution stops them getting to the point of discharge that they don't come back on and gives the opportunity for a graceful shutdown. A shame the I2c is in master mode for the display as if in slave mode, one could poll the unit for voltages and times and whether or not the computer should shut down. Hmmmmm.

  19. Browsing through BangGood I found this low voltage UPS for US$24
    5V2A 44W UPS Uninterrupted Power Supply https://www.banggood.com/5V2A-44W-UPS-Uninterrupted-Power-Supply-Alarm-System-Security-Camera-Dedicated-Backup-Power-Supply-p-1118312.html?rmmds=search.
    There is also a 12V version.
    Thinking about ordering one and seeing if there is some way to trigger a low voltage state to send the PI and let it know when to shut down. But 6 hours is probably enough for blackouts and brownouts that are not catastrophic.

    1. Hi Scott

      This one has had me rolling about laughing... check the specification...

      "If long time did not use this mini UPS, suggest 3-5 months to charge it once"

      Don't you just love Chinese translations.

      In all seriousness - it could well be a good one - my biggest question is always the same - if it is allowed to go flat.... given that the load is plugged in - when the power is returned - will it sensibly wait for sufficient charge and then turn on - or will the load need disconnecting, defeating the object.

      I would love for you to buy one of these and give it the test and let us know the result in here. Well spotted.

      1. Hey Pete,
        As with all Chinese products most come without a good manual and only way to know is to buy one and test it. The other thing is quality of critical components to handle the application.
        My question besides low budget is what are your critical power requirements, (Spain power)? With a product like this I am sure you are covered if you use a few relays and large Caps to make a serial UPS going from BG UPS to Solar to mains. The probability of not having sun, mains and the mini UPS run out is very low unless there is a major catastrophe, In my case it would be a hurricane in SoFla.
        I'm unemployed now so I need to justify to the wife buying more "toys", while I figure out how to set up NR to override BigClock with a push button.

        1. So most of the time here in rural Spain the power is ok, but without warning we may get a 5 minutes power break. Generally never more than a matter of minutes... however, very occasionally our hot tub has managed to take out the main earth leakage breaker... I've disconnected the heater for now as it is HOT here and that has solved the problem but I don't have a MEGGER to test for leakage - my normal meter shows around the correct resistance for the heater and no apparent earth leakage. A neighbour is bringing his megger over.. Now if that were to happen when we are not in Spain, it could be a day or two before I get someone to turn on the power. So for me I would like something that could power devices for a day but more importantly, that it will ALWAYS recover when the power recovers. To date, experiments with various boards has shown boards that will not recover from a flat battery until the load is removed - which is just about the stupidest thing imaginable. I've managed to get around that but it would be nice to stumble on a supply board at low cost that handles this without adding bits in.

          1. Sounds like Mexico.... Do you have a spike suppressor (MOV) on your mains? I have a few industrial units peppered around my house near motors, I got those from some Radio Base stations I installed last century. They are good for lightning strikes and reverse EMF when the fridge or pump start when demand is high after power comes back. A friend in rural Italy had a similar problem that actually killed some electronics. That is the importance of a good ground. Do you have a spear breaker? From hot tub to electric chair?
            I was also going to build a few Li-Ion packs with salvaged computer batteries instead of using Pb batteries http://www.batteryspace.com/pcbfor148vli-ionbatterypack5alimitwithfuelguagesocket.aspx.

    1. Well, if we replaced what I've done with the NANO - with an ESP-12 you'd have exactly the same thing though more messy - for considerably less. What is needed is a board like that little one I use - more power and a logical input to turn off ONE of the power outputs - the ESP still needs 5v to operate - the only down side on a small battery system would be the power consumed by the ESP unless it was put to sleep and periodically woken up.

        1. For me that's really overkill - you can get low power from the ESP if you keep it off most of the time - in this case ultra-low power is not that important - if you get a power cut lasting more than day you're in severe trouble anyway....

    1. those boards have a nice addon board on the side of which you can plug many premade modules, or a protoboard... this is a kit of esp8266+oled board, together with addon board and relay module:

      all the available modules, as of today: https://it.aliexpress.com/item/X1-shield-new-NODEMCU-wifi-ESP8266-ESP-12F-0-96-inch-OLED-learning-kit/32815664805.html

        1. well, yes, but if you take a wemos d1 mini, + an oled display, + a relay, and a little protoboard to put it on all by yourself, you get quite there as price, and you have to do all the required connections (in a bulkier way) and add the TIME you need to do all that... 🙂
          otherwise, take a standard sonoff and add an oled, and you end up to about 8€ for everything 🙂
          but maaaaaaaaaybe (*) you need to change the winbond memory, too... 😉

          (*) OT, a very funny sketch by Louis CK 😀

  20. Hi Pete,

    I've just taken delivery of a couple of these : -


    Quote: "Independent Circuit - Independent battery, charging and discharging at the same time, can work together and not influence each other"

    It didn't toggle the power to my Pi-a-like SBC when I removed the 'charge' feed. It seems pretty good but I need to do some thorough testing. I've populated mine with 4 non-cheap protected 18650 cells and I'll let you know my findings.

    I can't remember where I heard about this unit originally so it was on here and you already know about it, disregard this post.

    1. Absolutely, Darren - please do - because strangely enough I've just ordered from the same place, the 3-cell version so I am very interested.

      Checks - works as power connected and disconnected?
      What happens if battery gets low - does it shut off at a reasonable level?
      What happens then - if you apply power? Does the load eventually come back on without having to disconnect?

      Love to hear from you.


      1. Hi Pete,

        The tests you mention are pretty much the ones I'm interested in too.

        I need to set up a simple SBC and leave it running long enough to get through the battery (given there are 4x 18650, it may take a while) whilst logging a timestamp to disk every minute so that I can determine the answers without having to nurse maid it. I didn't have anything set up that wasn't in use doing something but I hope to sort something one evening this week as I have a similar use case to yourself with a holiday property with home automation on an RaspberryPi without any provision for power outages.

        I'll stick my Pine64 or an OrangePi +2E board on it and let you know the results.

        1. I've just fished out the "Product Manual" - just a small slip of paper - but if it does what it says it does, it sounds quite promising.

          "When input and output at the same time, it will automatically charge the device first, then charge the battery"

          "Without working, it will automatically shut down after 20 seconds; automatically power on once charging; automatically stop working once output current overcharge"

          "With dual output USB, two devices get charged simultaneously. The total output current for both USB ports is 2.2A when output at the same time. The latest USB port will be stopped working if total output current is more than 2.2A".

          That's the only concern - if powering 2 devices, the 2nd will be denied any power if there's an over-current situation. I am hoping to only need to run one device out of the unit and with it being a Raspberry Pi2 (possibly later to be replaced with an RPi3), it should be within tolerance.

          1. Hmm, but if it does what it CLAIMS - it will be doing something that MOST of the other units out there don't... and the pricing isn't bad - I think the 3 battery unit was £8... looking forward to seeing this.

            1. Hi Pete,

              I've got 4 fully charged Canwelum 18650 3.7v protected sells loaded up and an Raspberry Pi 2b as a load on one of the USB ports.

              Side view showing USB in and out.


              Front view showing 0.58A load at 5.08v into RPi2B


              I've also employed the use of chinese USB ammeter as it will not only record realtime current draw but total mAh.


              I've got a cron job logging the time/date to a text file every minute as an extra log to confirm time of death when the battery goes and also any resurrection after I plug DC power back into the battery pack when the battery runs flat.

              1. I have seen in the Tomo product page that you can use the 4 cells powerpack with only two of them installed.

                Obviously the capacity will be lower, but tests will run faster.

                (I have got my finger ready to click on 'buy' in the Aliexpress page) 🙂

  21. Off topic but, boy is photobucket now infested with adverts.

    Back on topic, I have one of these power packs. I seems robust but sometimes the load does not trigger the power. I suspect it has something to do with the 'sense' resisters used by USB ports to identify what kind of load you have plugged in.


    I have not experimented with SBC's to if they reliably power up, but it looks like others are doing so...

    1. Ok results now in ...

      The fully pre-charged 4-cell 18650 Tomo battery pack ran out of steam after running my (idle) RPi2b for 10 hours and 9 minutes providing a measured total of 5061mAh. As soon as I switched on the DC in feed, the unit sprang back into life, the display lit up on Tomo and the Raspberry Pi fired up without needing to press any reset button or anything at all on the Tomo device.

      I disconnected the DC in power 10 minutes later for a few seconds and the batteries had enough steam to run the Pi uninterrupted again but I quickly plugged it back in rather than trying my luck.

      I imagine it will take a fair while to recharged the cells now given the documentation suggests it favours dealing with the load side with a higher priority to recharging the cells but I don't see this as a problem as 10 hours and 9 minutes of standby time (idle RPi 2b) or 5061 maH provides plenty of protection against UK mains supply outages and is unlikely to get fully consumed in one outage.

      I'm a happy chappy. Please let me know if you have any further questions.

      1. Good man - can you make sure we have the EXACT link to that product... when mine arrives I'll do exactly the same and confirm or otherwise in here - and that'll give people some confidence.... if you hit any snags later on please DO come back in and let us know. Stable supply is so essential for the likes of Raspberry Pi - in the UK I've had issues with SD - nothing that could not be resolved with power down and up (but not reset) - in the last year - even though the power is quite stable there. Here in Spain the power is not stable - and so I have a battery pack (rather more expensive than these, hence the interest) on a Pi2 here and it has never, ever failed in well over a year. We know SDs don't last forever but I suspect from various conversations in here that a decent supply without breaks goes a long way to ensuring we get full use out of them.

        1. Hi Pete,

          Good call on confirming the URL of the product. The one I pasted in my original post yesterday is not the same seller that I bought from although the product looks the same. You can never be 100% sure given all the clone items out there so I'm glad you prompted me to double check.

          Looking back at my AliExpress order history, the seller I bought from was called "ADA PC Accessories Store"

          and the exact item link to the product in that store:-


          I paid £17.92 for 2 (£8.96 each) on 8th July but the price seems to have gone up a couple of quid since then. I was impressed with how quickly they arrived though - 11 days.

          i'd urge people to buy their 18650 cells wisely. I paid a premium for 'protected' cells. I wasn't brave or stupid enough to source cells without overcharge/discharge protection as, like you, my intention is for this kit to sit unattended in a kitchen cupboard in my wooden seaside chalet many miles away - I'd not want to reduce my holiday home to a pile of burning timber!

          I'll leave my test RPi2 running on the unit for the rest of the week with a view to putting it 'live' at the beach at the weekend if I'm still feeling as confident then. I'll be sure to report back any concerns or issues over the lifetime of the device as it will be under 24/7/365 use at my chalet and I monitor the network there from home on a daily basis. .

          I've been pretty lucky with SD Cards in my Pis. I've had a few power cuts at home and at the chalet but nothing regular or repetitive and probably not during 'busy' IO times. My live Home Automation Pis at both homes endure heavy use and lots of I/O although planned reboots/halts are always done carefully rather than just pulling cables. You're absolutely right in suggesting a stable power supply is vital in ensuring longevity though.

          Given the low price of even good quality microSD cards - I think I pay about £5-6 for a 16Gb - it makes no sense playing russian roulette and I'd suggest scheduling an annual backup/restore onto a fresh card every 12 months, perhaps retiring the old card to casual temporary file transfer duties at home as you'll never really know when a card's time is up.

          I'll keep you posted if I spot any peculiarities.

            1. The temperature sensor is a good shout. I have several kicking about and a python script already present on the Pi to log the data as that's how I monitored room temperatures at my chalet in my pre-ESP8266 sensor node days!

              I am not quite sure what I would do if I did see the temperature rising alarmingly as it takes an hour and a quarter from home or work to drive there to extinguish the fire ...it would be reduced to a stack of charcoal sticks before I got there! If the Pi was still running sat in the middle of the bonfire we could call it a partial success...

              1. I just had that with my solar kit - 4 12v Lead Acid batteries in series-parallel to get 24v... I could smell something in the office - and when I eventually got off my backside to take a look - two of the batteries were up like balloons. A temperature sensor stuck on the side of them would have alerted me long before they were in deep water.

              2. maybe a relay connected to a gpio before the usb charger which is connected to the charging ports, to at least disconnect it and cut out the actual charging and avoid to continue to pump energy in a hot device... then you're on just on batteries, if the device survive, but you should get alerts way before and have a less lethal situation to deal with...

          1. I have a Pi 3 running at home as a tvheadend server and external USB TV tuner to record scheduled TV. I shall power that down tonight and stick it on the Tomo power pack to test that for you...how does that sound? It should be a reasonable test as it will be doing some work. I have some additional spare brand new ready charged 18650s if the ones currently recharging in Tomo haven't caught up.

                1. I'll try and load the RPi3 up a bit during the start of the test by starting a few 'screen' sessions with some gzips of large files or something to stretch its legs a bit. I'm guessing we're mostly testing to see that "Tomo" can provide enough grunt to run an RPi3 without tripping its over-supply limit and cutting out given that last night's tests were on an 'idle' RPi2 whose only task was logging a timestamp once a minute in a cron job - I think the most it pulled was 0.6A so I haven't yet witnessed how Tomo handles a fully loaded SBC.

                  I'll also take the opportunity of repeating the "power cycle DC in" test and the "make sure it restarts the Pi without needing to press any buttons when DC in is reapplied to a flat battery" one too, just for good measure but the main focus will be on whether Tomo is man enough to handle a beefy Pi.

                    1. Well well well I have learned something very useful today! That's going to come in useful both at home and at work. Many thanks for the tip as I was going to start 4 separate screen sessions to multi thread the load otherwise

  22. Ok chaps ... I have some more feedback from some testing this evening ...

    The Tomo unit used last night to test 4x 18650 cells feeding a mostly idle RPi2b didn't receive much charge today when left charging with the RPi2 still running off it as the unit has a documented preference to feed the load on the battery first before its own cells so it had only been trickle charging all day. 4x 18650 cells gave us 10 amp hours last night so they will take quite a bit of recharging.

    I'm therefore performing tonight's RPi3 test using just 2 x 18650 cells in the 2nd Tomo that I purchased. I had hoped to do a 4 cell test again but then remembered my 4th spare 18650 is currently deployed long term powering an Wemos D1 Mini ESP8266. My last test saw 3 month battery life out of a single 18650 cell powering the Wemos D1 Mini direct to its 3v3 input bypassing the 5v MicroUSB for efficiency. On a the Wemos, I have an external dallas temperature sensor and its running ESPEasy firmware set to deep sleep 15 minutes and then wake to read temperature and transmit via MQTT to my nodejs based Pimatic Home Automation app on a Raspberry Pi. Simple but effective. Sadly this leaves me with just 3 x 18650 cells for Tomo and whilst it lit up showing 3 cells on the display, I thought I'd make the numbers easier and run just 2 cells, so 50% of the capacity we had last night.

    node on a 15 minute deep sleep Wemos D1 mini sending temperature information via MQTT to Pimatic (Home Automation) on one of my RPi 2 boxes.

    (I'm getting 3 months battery life waking the ESP once every 15 minutes to read the temperature via a DS18b20 and send it via MQTT to my Pimatic based RPi home automation setup).

    The RPi3 Tomo Test

    Anyway, back on topic, I've fired up one of my Raspberry Pi 3 machines. This one is running OSMC (a linux distro tuned for Kodi media systems). I've been running some random text file creation and gzipping and unzipping over all 4 cores to get the CPU and power consumption up a bit. This didn't actually make big numbers so I hung a cheap USB desk fan out of one of the RPi3's USB ports...this added about 0.3A and then I thought I'd open the taps further by charging last night's 4 cell Tomo battery pack out of the back of another USB port in the RPi3 ... the RPi3 has the config.txt file set up with "max_usb_current=1" which is the parameter which enables full 1.2A output on the USB of a Raspberry Pi 2 or3 for those who were not already aware....

    I'm pleased to say that I've got a load that's fluctuating between 1.6 and 1.78 A coming out of Tomo and he's not broken out into a sweat and upset the RPi3.

    The 'DC in/out' test was repeated and that's fine - no power resets or issues. Tomo is very quick to go to sleep though if he detects zero load - I didn't have the microUSB plug in properly and it turned off in a couple of seconds - so make sure you have a good connection on your USB (or always keep a dummy load on Tomo's 2nd USB port as a keep alive?).

    Anyone got any special requests before I hang up my 'geek' gloves for the evening? 'Er indoors thinks I'm rather strange getting so interested and involved in testing "a battery pack" so I need to go and pretend to be human for a bit later to reassure all is well 🙂

    Attached photo shows last night's Tomo on the left charging out of the back of a RPi3 powered by Tomo number 2 on the right. The power supply into Tomo 2 is the standard RPi 3 power pack - I thought I'd feed Tomo with the same power supply that feeds the Pi it has to support.

    1. The RPi 3 power supply is switched off obviously during this test of load under battery drain conditions buy was used at the start of the test switched on and then off and plugged in and pulled out to emulate Pete's unstable domestic Spanish power supply conditions!

      I have no concerns thus far regarding build quality of the unit or any temperature issues during recharge but I will do a further test with a Tomo later in the week being left on charge with no devices connected to the output to ensure that Tomo feeding 100% power to the charge cycle doesn't cause any unusual behaviour or overheating etc.

      Stay tuned to Tomo Television for more exciting updates!

      1. very good testing, thanks! i think i'll order one tomorrow 🙂
        for the wemos, not even a voltage devider to step down to 3.3v from 3.7?
        usually LiFePO4 batteries are better in this, but less used and a little more higher in price... they are at 3.3v exactly

        1. Glad to be of assistance 🙂

          Regarding the 3.7/3.3 thing... I was a bit nervous about it but I've been running over 6 months without issues so I think the ESP is tolerant enough to let me off for as long as it takes for the voltage to drop back a bit over time I guess. I was just using 'what I already had' and it's worked out much better than stepping up 3.7v to 5v and then the ESP stepping it back down again which is what a lot of projects I've seen do... multiplying inefficiencies.

          I'll look out for some LiFePO4 cells though as I *do* like to do things properly when I can - but experimenting is fun too.

          Update on the RPi3 heavy load. I was using different brand 18650s so it's not a scientific comparison plus there were only 2 cells in the Tomo compared with the fully loaded 4 cell Tomo yesterday. I managed about 3600mAh and just like the original test, the battery pack powered back up and powered the RPi3 fine pretty much as soon as I flicked the DC in power back in - to paraphrase Phil Collins - no button press required.

          I'm leaving both Tomos charging now without load, when the 2 cell one is fully charged, I'll put it into full time long term use at home on my main RPi2 and assuming everything continues to work without incident, I'll install the 4 cell Tomo at my holiday chalet where the original need for battery back up came from.

          Let us know if you have any other questions or tests that you'd like me to do but it seems like you're already sold 🙂

  23. Good find Darren!

    I have ordered one Tomo T4 (do not mix up with the Tomo M4!). I have used the first link you posted, but I think it is exactly the same item.

    Also tinkering with "sleeping wemos", for a water tank level. That deserves a separate thread IMHO.

    1. They do look similar... well, mine has not turned up yet so I can't do comparison. I'm hoping this one pans out as it will be great for helping make little computers like the Nanos and Pi more reliable than simply sticking them on the mains - been looking for a reliable solution for ages. There is of course still an argument for sticking a cheap NANO in there to monitor voltage and warn the computer to shut down if the voltage drops but then it would have to also be responsibly for bringing it back up as the voltage could drop to the point where you feel you have to shut down the computer, but never drop enough to cause power cycling on it's own. Still - simple enough. If one bought a unit to handle 4 batteries and used 2 there'd be enough room to put a little circuit inside.

      1. in case of the RPi*, you can just close these 2 pins to force a restart, but they should be used only for power cycling, as they do NOT allow a clean shutdown, so your nano setup is still very useful...

    2. My two Tomos have the dual inputs, so presumably the S4.

      Pete's idea of utilising half the battery compartment to accommodate an additional control board is an interesting one. For my requirements, I'm happy with the standard setup as I've not experienced any regular or long period power cuts at home or at my chalet so I just need a device to mask any brief power cuts and keep an RPi2 alive for the duration and even a 2-cell Tomo setup would meet or exceed that requirement 🙂

      1. Yes of course Darren - every case is different - in mine, I want my little computer to work reliably for long periods unattended. I've reduced writes to a minimum but they are still there of course. If the power trips it could be some hours before someone comes along to reset it -longer it it happens late at night. You can "get away" with a clean power outage most of the time but it would be better for the computer (Pi or whatever) to do a clean shutdown if poss.

Leave a Reply

Your email address will not be published. Required fields are marked *