One of the big problems some people have with using the Raspberry Pi, is that if it loses power unexpectedly, the kernel can be corrupted. You can verify the user community’s frustration by googling “raspberry pi shutdown recovery”, or just go to this link and read the post: Turning off Raspberry PI without proper shutdown
In this webpage, I demonstrate a solution I created to solve the problem.
Design Goals for this project:
- Prevent corruption of the linux kernel on a Raspberry PI if power is lost by initiating a and sustaining a controlled shutdown sequence
- Sense when power is restored, and automatically reboot the Raspberry Pi without human intervention
- Provide an economical battery backup that will provide power to the Raspberry PI for a few minutes, so that a reboot might be able to be prevented if power is restored before the battery backup is drained
- Keep cost low by using a variety of “off-the-shelf” UPS systems, including such things as battery cases that provide extra power to cell phones.
The next figure shows a block diagram of the design. Any UPS can work, so long as it provides enough amperage to run the Arduino and the PI.
Schematic of the solution. The TXB0108 Level Shifter can be purchased from a variety of places. I got mine at Adafruit.
Timing is a always a little tricky. This is how I chose to sequence mine.
That is about all there is to it. It works like a champ.