dauhee
Posts: 59
Joined: Fri Sep 07, 2012 1:50 pm

Controlled shutdown on power loss

Sun Mar 31, 2013 8:43 pm

Hi All,

I'm looking to have a graceful shutdown for my RPi so that it can perform for about 60 seconds after the mains power has discontinued. I've been looking around for weeks and have found 3 different options/concepts:

Option 1) - http://arduino.cc/forum/index.php/topic,70734.0.html - some type of supercapacitor solution to just give an extra minute or so

Option 2) - http://www.seeedstudio.com/depot/lipo-r ... p-992.html - I think this can be used to basically feed the usb in to usb out, and fall back on battery when usb in stops (but not entirely sure)

Option 3) - http://www.ebay.ie/itm/Rechargeable-Ext ... 3a7f2f0ddf - I'm not sure if devices like this can be plugged into mains while also supplying voltage.

Option 1 is ideal as the other 2 are more than needed. Failing that, Option 2, because I could house the board + battery with my pi. Just wondering if anybody has any thoughts/advice/experience on this. My head is whizzing trying to understand heavy electronics from other posts (its straining the cognitive abilities of a programmer). There are other forum entries about RPi and UPS and batteries etc. but nothing with a definitive solution.

Any help would be much appreciated.

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Controlled shutdown on power loss

Sun Mar 31, 2013 9:02 pm

You can use a relay that is driven by 5V from mains. When the mains is removed the relay loses power and it switches to it's 'normal' state where the battery (4x NiMH cell, 5.2V when full, 4.8V when depleted) gives power to the Pi.

However, there's a few nanoseconds that the power is off during switching. To counter this you use a 10,000uF capacitor (or two, to be sure) over the + and ground rails of the Pi.

The Pi can detect if it runs on batteries through the GPIO pins (if it does not detect mains power) and gracefully shut down. 4 NiMH AA 2000mAh cells will power the Pi for about four hours, so you could also use 4 AAA cells if you only need it for a short while.

I tested this and it works. Be sure NOT to use regular AA or AAA cells (like Alkaline) for they have higher voltage and may damage the Pi. Also make sure to use the latest type of NiMH cell that stay charged for a year (Eneloop and the like) for the old type will self-discharge in about two weeks.

Good luck.

Edit: Found the schematic:
Image

dauhee
Posts: 59
Joined: Fri Sep 07, 2012 1:50 pm

Re: Controlled shutdown on power loss

Sun Mar 31, 2013 10:43 pm

thanks poing that sounds good. Would you have information such as the parts list? I'm a bit unsure about how this would be wired up. I have the 5v adapter but don't know how to wire it up.

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Controlled shutdown on power loss

Sun Mar 31, 2013 11:07 pm

Be advised the schematic is for use with an Anker 10,000 mAh battery with internal charging and protection circuitry and meant for a different purpose: keeping a Pi working 24/7 while switching between mains and battery. With the NiMH batteries the 5V IN of the battery should be left out!

Another possible problem is that the Pi will still draw some power after it's shut off so the batteries will deplete. Not sure if this is a problem, but deep-discharging of batteries is never a good idea. You should have some voltage checking gizmo between the battery and the Pi to protect the battery.

Parts I used are something like this: http://www.ebay.com/itm/5V-DC-SONGLE-Po ... 33734b845a

and something like: http://www.ebay.com/itm/4x-10-000uF-16V ... 337cd2d843

To see if the Pi is still on mains power you need a resistor, I'd look elsewhere on the site to find out exactly which one. And be cautious with my advise, I'm a electronics newbie myself :?

dellboy
Posts: 7
Joined: Fri Nov 09, 2012 4:45 pm

Re: Controlled shutdown on power loss

Fri Apr 05, 2013 7:58 pm

FYI, i asked the same type question on another forum:

http://www.raspberrypi.org/phpBB3/viewt ... 63&t=39477

similar solution proposed.....

dauhee
Posts: 59
Joined: Fri Sep 07, 2012 1:50 pm

Re: Controlled shutdown on power loss

Fri Apr 19, 2013 7:20 pm

I got a lipo rider pro board from seeedstudio. its perfect. takes mains when available and goes to battery otherwise. has connection for solar power also if so desired.

I would have liked it to have more than the 1 amp however as usb devices could consume more than the 300mA remainder. So over-clocking isn't a good idea. However, it works :)

slado
Posts: 21
Joined: Thu Aug 16, 2012 6:23 am

Re: Controlled shutdown on power loss

Fri Aug 15, 2014 8:27 pm

This might be be a solution for your shutdown problem:

www.juice4halt.com

The module works without batteries, the power is stored in supercapacitors and keeps the RPI alive for about 1 minute after power failure. This should be enough time for a shutdown. Moreover the supercapacitors protect the RPI from short term power failures or brown outs.

dauhee
Posts: 59
Joined: Fri Sep 07, 2012 1:50 pm

Re: Controlled shutdown on power loss

Sat Aug 16, 2014 12:46 pm

That is perfect! Hopefully it will be out soon.

The problem with my lipo rider solution is even after detecting power removal and performing shutdown, battery power still drains.

Thank you!

Return to “Automation, sensing and robotics”