This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to safe-shutdown a RPI
#1
Hi all,

I'm looking for some guidance to find a valid solution for the a safe-shudown. Using the main electric board I can switch-on the RPI with no issue. As you understand the other way is not safe as it just cut the main power. Unfortunately, the main electric board switches are old and don't offer control to connect to a GPIO, or I did not understand it. I found a few HAT that allows via a watchdog to safely shutdown the RPI (PIJuice, PIVoyager, Zero2Go) but not sure if it is the best approach. Physical buttons on the RPI are not helpful as the RPI is not easily accessible.


How do you guys did it?

My current setup include the following:
- step-down 12v-5v 10A
- RPI4B
- Seatalk1
Reply
#2
I use 2 x buck converters, 2x diodes, a resistor and a relay board.  

with a connection to both the constant 12v and the switched 12v from the 'main electric board'.  
   

When the switched power is on the 3.3V board and the 5V board get power, once the Pi has booted GPIO Pin 40 becomes 3.3V and trips the relay.  This makes the 5V board connected to both switched and constant power.

when the switched power is turned off, the 3.3V supply goes to zero, but the 5V supply remains powered.  the 3.3V board being unpowered is sensed at pin38 and this causes the Pi to shutdown, once down Pin 40 is de-energised and the relay released uncoupling the power

cost of the parts is about $10, there are 2 lines of code needed to be added

video demonstration below: 

https://youtu.be/45IxpEa0ZcM
Reply
#3
Why hardware? If you have remote access to the RPi using a keyboard, you can shutdown using the GUI or command line.
Reply
#4
(2021-03-10, 01:59 AM)EarlWer Wrote: Why hardware? If you have remote access to the RPi using a keyboard, you can shutdown using the GUI or command line.

because breakers 'accidently' get switched off by well intentioned crew members or in the heat of moment when trying to exit the boat. this just ensures there are no corrupt SD cards
Reply
#5
Question: what about a USB connected SSD? It could be corrupted but could it also be damaged or even destroyed?
Reply
#6
I made the shutdown circuit like this. Also, a script is monitoring the "halt pin" status and shut down RPi when the power switch is OFF (and "halt pin" goes down to 0)
After the power switch turns OFF, the power is still ON for about 1 min, enough time for RPi to safe halt

   

Of course, the power regulator can be a different one, i used this for an RPi0w
- SV Haimana
Reply
#7
(2021-03-16, 01:19 PM)sebba Wrote: I made the shutdown circuit like this. Also, a script is monitoring the "halt pin" status and shut down RPi when the power switch is OFF (and "halt pin" goes down to 0)
After the power switch turns OFF, the power is still ON for about 1 min, enough time for RPi to safe halt



Of course, the power regulator can be a different one, i used this for an RPi0w

Good idea!  I like the way you have used a Capacitor to trigger a transistor to keep the permanent 12V hot until the Pi is down, well until Capacitor is drained
Reply
#8
Thanks
Yeah, I think this is the simplest way to have a safe shutdown.
Of course, it require pi to halt in less than 1 min, but this should be fine in most cases.

LE: I made an annotation mistake in diagram: R5 should be 100k and R6 to be 22k.
- SV Haimana
Reply
#9
Yes, I thought your voltage divider was backwards.

I used a second Power supply instead of a voltage divider because I was a little worried about the variation on the 12v line. With your voltage divider you get 2.1v at 12v and 2.6v at 14.5 - does that work? Is that enough for the Pi to see it as high/low?
Reply
#10
yes, it is! u can also add a 3v3 zenner diode there, even recommended, for more safety
- SV Haimana
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)