pandroid
Posts: 16
Joined: Wed May 15, 2013 11:54 am

Safe Shut Down

Tue Feb 26, 2019 7:50 pm

I'm amazed that no one seems to have produced a hat/phat that simply allows the PI to shutdown gracefully in the event the power is turned off. There seem to be a number of amateur efforts to do this, and a number of commercial efforts that get close, but no cigar.

If someone could point me at a commercially available solution to this, I would be very grateful.

(or does nobody care?)

echmain
Posts: 285
Joined: Fri Mar 04, 2016 8:26 pm

Re: Safe Shut Down

Tue Feb 26, 2019 8:38 pm

Do you mean a UPS? If so, there are some Pi-specific commercial products. Pi Juice is the one I'm interested in. But it's kind of expensive and out of stock everywhere.

pandroid
Posts: 16
Joined: Wed May 15, 2013 11:54 am

Re: Safe Shut Down

Tue Feb 26, 2019 8:44 pm

echmain wrote:
Tue Feb 26, 2019 8:38 pm
Do you mean a UPS? If so, there are some Pi-specific commercial products. Pi Juice is the one I'm interested in. But it's kind of expensive and out of stock everywhere.
No, I dont mean a proper UPS. I mean a shim that will hold the power for 30 seconds or so while the Pi shuts down.

echmain
Posts: 285
Joined: Fri Mar 04, 2016 8:26 pm

Re: Safe Shut Down

Tue Feb 26, 2019 9:26 pm

pandroid wrote:
Tue Feb 26, 2019 8:44 pm
echmain wrote:
Tue Feb 26, 2019 8:38 pm
Do you mean a UPS? If so, there are some Pi-specific commercial products. Pi Juice is the one I'm interested in. But it's kind of expensive and out of stock everywhere.
No, I dont mean a proper UPS. I mean a shim that will hold the power for 30 seconds or so while the Pi shuts down.
Hold the power? How?

Anyway, a UPS will do exactly this and not for just 30 seconds, more like hours so you'll have plenty of time to save your work and do a proper shutdown. And I believe they can be set to do a proper shutdown even if you aren't present when the power cuts out.

User avatar
Imperf3kt
Posts: 3245
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Safe Shut Down

Tue Feb 26, 2019 9:42 pm

I think what the OP means is a UPS hat that automatically shuts down the Pi in the event of a power outage.

I recall a few, but no specific models come to mind.
55:55:44:44:4C
52:4C:52:42:41

W. H. Heydt
Posts: 11492
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Safe Shut Down

Tue Feb 26, 2019 11:24 pm

pandroid wrote:
Tue Feb 26, 2019 8:44 pm
echmain wrote:
Tue Feb 26, 2019 8:38 pm
Do you mean a UPS? If so, there are some Pi-specific commercial products. Pi Juice is the one I'm interested in. But it's kind of expensive and out of stock everywhere.
No, I dont mean a proper UPS. I mean a shim that will hold the power for 30 seconds or so while the Pi shuts down.
The MoPoser UPS can do that with some supercaps instead of batteries as the standby power.

W. H. Heydt
Posts: 11492
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Safe Shut Down

Tue Feb 26, 2019 11:26 pm

Imperf3kt wrote:
Tue Feb 26, 2019 9:42 pm
I think what the OP means is a UPS hat that automatically shuts down the Pi in the event of a power outage.

I recall a few, but no specific models come to mind.
That's one of the features of the MOPower units. It will either shut down toe Pi on low battery condition, or can be set to shut down as soon as the power drops. As I just noted, one can use supercaps for short term power...just long enough to shut down the Pi.

pandroid
Posts: 16
Joined: Wed May 15, 2013 11:54 am

Re: Safe Shut Down

Wed Feb 27, 2019 4:30 pm

The Mopower units seem to be battery backup devices - not sure how they trigger the Pi to shutdown. The supercaps idea is probably the right one - I've seen a couple of people try it, but no one seems to do a ready made commercial version.

W. H. Heydt
Posts: 11492
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Safe Shut Down

Wed Feb 27, 2019 7:22 pm

pandroid wrote:
Wed Feb 27, 2019 4:30 pm
The Mopower units seem to be battery backup devices - not sure how they trigger the Pi to shutdown. The supercaps idea is probably the right one - I've seen a couple of people try it, but no one seems to do a ready made commercial version.
The MoPower units have a microcontroller on them, plus there is associated software that runs on the Pi. The MoPower can use a variety of batteries (NOT Li Ion or LiPO) or supercaps. Mosespi posted a link the results of his test with supercaps some time ago. There is some data here: https://www.raspberrypi.org/forums/view ... p?t=162440

pandroid
Posts: 16
Joined: Wed May 15, 2013 11:54 am

Re: Safe Shut Down

Wed Feb 27, 2019 8:45 pm

OK, spotted the wrong MoPower! However cant see why this is beter than the Pimoroni MoPi2 which is cheaper. No one seems to do the supercaps stuff in commercial format. (i.e I have to acquire the caps, do my own PCB etc).

Andyroo

Re: Safe Shut Down

Wed Feb 27, 2019 9:31 pm

You could look at https://modberry.techbase.eu/tag/supercap/ but at €90 it’s not cheap! Even this one https://juice4halt.com is over 70...

This old one failed https://www.indiegogo.com/projects/juic ... berry-pi#/ to get funding but he may have pilot boards available

To be honest I would go for a battery solution along the lines of a router standby unit with USB output as most power outs are brownouts and a simple daemon looking for no internet for a few minutes and a simple shutdown would do.

rln
Posts: 176
Joined: Wed Apr 09, 2014 1:43 pm
Location: Sweden
Contact: Website

Re: Safe Shut Down

Thu Feb 28, 2019 9:25 pm

One can also use an alternate Linux distro. There are several that work fine having the power unplugged whenever.
Author of the robust Nard distro http://www.nard.se

User avatar
Imperf3kt
Posts: 3245
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Safe Shut Down

Fri Mar 01, 2019 12:44 am

rln wrote:
Thu Feb 28, 2019 9:25 pm
One can also use an alternate Linux distro. There are several that work fine having the power unplugged whenever.
Not really.
Can you name which distro you are thinking of. Is it one that is read only?
55:55:44:44:4C
52:4C:52:42:41

rln
Posts: 176
Joined: Wed Apr 09, 2014 1:43 pm
Location: Sweden
Contact: Website

Re: Safe Shut Down

Fri Mar 01, 2019 6:59 am

Not really. Can you name which distro you are thinking of. Is it one that is read only?
OK, here is a list:
  • Tiny Core Linux (runs from RAM)
  • Nard SDK (runns from RAM. I'm involved. Has never ever failed due to a power cut.)
  • OpenWRT (using Overlayfs)
  • Raspbian wih read-only root
Of course there are downsides of having to switch distro. But for the most sensitive applications, which usually involves placing the Pi somewhere far away remotely and unattended, it might be well worth it.
Author of the robust Nard distro http://www.nard.se

pandroid
Posts: 16
Joined: Wed May 15, 2013 11:54 am

Re: Safe Shut Down

Fri Mar 01, 2019 10:38 am

Read only distro isn’t really an option since the App (which is aboard a boat) writes to a database.

Heater
Posts: 14471
Joined: Tue Jul 17, 2012 3:02 pm

Re: Safe Shut Down

Fri Mar 01, 2019 12:18 pm

Put your database on a different media. A USB stick or whatever.

Better still send your data out over the net to a database elsewhere.
Memory in C++ is a leaky abstraction .

User avatar
thagrol
Posts: 2238
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Safe Shut Down

Fri Mar 01, 2019 5:08 pm

Heater wrote:
Fri Mar 01, 2019 12:18 pm
Put your database on a different media. A USB stick or whatever.
That won't help. The main cause of corruption on abrupt shutdown (unflushed write caches) is present on almost all file systems, regardless of the physical way the storage is connected.

It's made worse on SD card due to their internal workings. Even if linux has flushed its caches the card can still be writing and doing housekeeping (e.g. to support wear leveling) wjen power is removed.

Putting the dabase on a different server may help depending on how you do it. Running the database engine on the server and sending writes as remote operations should be OK. Running the engine locally using files on a network share is likely to still be problematic. You won't get disk corruption but you could still get a corrupted database if power is pulled at the wrong moment.
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

Andyroo

Re: Safe Shut Down

Fri Mar 01, 2019 5:31 pm

pandroid wrote:
Fri Mar 01, 2019 10:38 am
Read only distro isn’t really an option since the App (which is aboard a boat) writes to a database.
In Tiny core you can flag some directories to allow writes or issue a command line to update data on the SD Card - not that this would help if the power goes at the same mo you are committing data to card.
thagrol wrote:
Fri Mar 01, 2019 5:08 pm
...
Putting the dabase on a different server may help depending on how you do it. Running the database engine on the server and sending writes as remote operations should be OK. Running the engine locally using files on a network share is likely to still be problematic. You won't get disk corruption but you could still get a corrupted database if power is pulled at the wrong moment.
Commit / Rollback should help in this situation but its a real pain to test :lol:

Return to “General discussion”