For people who have been using Hudiy for a long time, or something similar like Cr***S**ft or the dead Openauto pro.
Do you use a safe shutdown mechanism to avoid data corruption?
My take:
- Hudiy does not write that much to storage
- Use an SSD or NVMe (is it good in a car with vibrations??) instead of an SD card
Can corruption still happen?
Safe shutdown needed ?
Re: Safe shutdown needed ?
I have Hudiy installed in my car for almost 4 months now and I didn't add any safe shutdown mechanism. I don't think it is necessary at all. I turn on/off my headunit few times a day and it still works perfectly fine. No filesystem corruption or issues with startup. Pi5 with nvme in my setup is connected directly to the "accessory" power line and when I turn the key to 0 the power is simply cut off.
Re: Safe shutdown needed ?
Cutting power to a Raspberry pi without going through a normal shutdown process is analogous to russian roulette with your SD card or SSD. The cylinder may contain more blanks but there is a bullet with your name on it. You have 3 options, don't do a normal shutdown and wait for corruption problems, or run a system in read only mode. You could use a RAM disk to do this but you can't change any settings permanently without going through hoops. The safest and easiest option is to do a normal system shutdown. I used a relay, transistor, and resistor along with a gpio pin to power down my Pi.
As you can see, I opted for a solution that requires as few components as possible but does require a few lines of code. The key component here is a DSP1-L2-DC12V-F relay. This is a bi-stable latching relay. The theory of operation is simple. Pressing the momentary start button (labeled re-start) will energize the relay and latch it in the on position. I omitted the restart button and instead utilized the crank engine signal. The latching relay powers the 12 to 5 volt buck which is directly connected to the power the Pi.
It's important to note that the source of power for the pi, is a constant 12 volt source. When the ignition is turned off, the pi will continue to run. However, if we use one of the gpio pins to detect when the power has failed we can instruct the pi to turn itself off. Essentially, once powered up, the pi controls its own destiny. I used a separate relay to determine when the ignition was turned off. When this is detected, a python script does a sudo shutdown now. There's a line in the config.txt file that reads:
dtoverlay=gpio-poweroff,gpiopin=10,active_delay_ms=5000,inactive_delay_ms=4000.
This causes the gpio pin 10 to go high when the python script initiates the shutdown. The pi itself doesn't have nearly enough current to shut itself off so I use a 2N3904 transistor. The pi turns on the transistor which pulls the relay back to the off position. This cuts all power to the pi. The result is that this circuit uses no power when the pi is off and the power is not cut until the pi is shutdown normally.
I went this route because I wanted a smart system. I have a number of switches and relays that report the status of the driver's door, the backup camera, and runs an internal timer. If the ignition is turned off but I don't open the driver's door, the pi continues to stay active until a timer has expired or until the driver's door has been opened whichever comes first. This is the behavior in modern cars.
You can do other things too. For example, I drive a manual transmission. If I am waiting for my girlfriend to do some shopping, I shut the engine off and put the car in reverse (an old habit of mine). Since I am not going anywhere, I don't want to see the backup camera view. The pi will continue running for 15 minutes. All of this can be done with a simple python script.
By the way, I am using pin 10 not 37 as shown in the image).
It's important to note that the source of power for the pi, is a constant 12 volt source. When the ignition is turned off, the pi will continue to run. However, if we use one of the gpio pins to detect when the power has failed we can instruct the pi to turn itself off. Essentially, once powered up, the pi controls its own destiny. I used a separate relay to determine when the ignition was turned off. When this is detected, a python script does a sudo shutdown now. There's a line in the config.txt file that reads:
dtoverlay=gpio-poweroff,gpiopin=10,active_delay_ms=5000,inactive_delay_ms=4000.
This causes the gpio pin 10 to go high when the python script initiates the shutdown. The pi itself doesn't have nearly enough current to shut itself off so I use a 2N3904 transistor. The pi turns on the transistor which pulls the relay back to the off position. This cuts all power to the pi. The result is that this circuit uses no power when the pi is off and the power is not cut until the pi is shutdown normally.
I went this route because I wanted a smart system. I have a number of switches and relays that report the status of the driver's door, the backup camera, and runs an internal timer. If the ignition is turned off but I don't open the driver's door, the pi continues to stay active until a timer has expired or until the driver's door has been opened whichever comes first. This is the behavior in modern cars.
You can do other things too. For example, I drive a manual transmission. If I am waiting for my girlfriend to do some shopping, I shut the engine off and put the car in reverse (an old habit of mine). Since I am not going anywhere, I don't want to see the backup camera view. The pi will continue running for 15 minutes. All of this can be done with a simple python script.
By the way, I am using pin 10 not 37 as shown in the image).
Re: Safe shutdown needed ?
Greetings;
Thankyou kind stranger.
This works a charm: while on UPS the system can execute graceful shutdown from anywhere and still fully disconnect from power. Brilliant.
Cheers.
Thankyou kind stranger.
This works a charm: while on UPS the system can execute graceful shutdown from anywhere and still fully disconnect from power. Brilliant.
Cheers.
-
trashcanhead
- Posts: 1
- Joined: Sun Oct 05, 2025 9:20 pm
- Location: Smithville, Missouri
Re: Safe shutdown needed ?
I don't mind making another circuit if that's what it takes but does anyone know how to run/convert the script from the mausberrycircuits switch to work on hudiy? It works on openautopro but i cannot get it to work properly with hudiy. I have tried the regular code every way i can think but it wont install properly since the weblink went down.
i have the code from my old files and the wayback machine script if it would help.
i have the code from my old files and the wayback machine script if it would help.
-
Sambolini94
- Posts: 21
- Joined: Tue Aug 12, 2025 7:02 pm
Re: Safe shutdown needed ?
I use the CarPiHAT Pro 5 with built in DAC for both audio out and shutdown and peripheral connections, then use a shutdown script as a service on the pi (already written and provided by the HAT developers) to control boot up and shutdown.
I used to use an sd card but these get corrupted very easily so now on my PI 4, I use an M2 NVME SSD plugged into the 3.0 usb port on my pi. Never had any corruption issues or power control problems either!!! The HAT is extremely worth it for about £100 sits ontop of the Pi but does take up the 40 pin GPIO header.
My next step is to connect my car unlock/ lock trigger wires to a sub system and then move my ACC wire from car to that system so it boots on unlocking the car and turns off when the car get's locked that way a more OEM feel to some degree.
The only gripe I have with HUDIY is the way it boots as it is not quite as seamless as OpenAuto Pro.
I used to use an sd card but these get corrupted very easily so now on my PI 4, I use an M2 NVME SSD plugged into the 3.0 usb port on my pi. Never had any corruption issues or power control problems either!!! The HAT is extremely worth it for about £100 sits ontop of the Pi but does take up the 40 pin GPIO header.
My next step is to connect my car unlock/ lock trigger wires to a sub system and then move my ACC wire from car to that system so it boots on unlocking the car and turns off when the car get's locked that way a more OEM feel to some degree.
The only gripe I have with HUDIY is the way it boots as it is not quite as seamless as OpenAuto Pro.
Re: Safe shutdown needed ?
I would like to share my idea, that maybe somebody could find usefull as well.
I wanted to get rid of as many batteries as possible, while maintin a "safe" shutdown, but also get rid of electricity in the whole circuit.
For the pracitcal issues, I couldnt get a CarPiHat so I went DIY way.
I rely on.:
FINDER relay;
- TVS diode is connected on coil (A1, A2) - just in case of voltage spikes
- redirects 12V to SIG. input on CRM relay
- closing contact (COM, NO) for GPIO on Raspberry Pi - Raspberry pi has a python script that watches if the contact is closed or opened. Once the IGNITION is turned off, the python script for shutdown executes and Pi is about to sleep.
CRM relay;
This relay has many functions, I am using a DELAY function. When 12V is provided to SIG. input, the delay will activate relay after 20 seconds passed. The same goes for the off state - when 12V is taken from SIG. input, after 20 seconds the relay is deactivated.
This relay also makes a bypass for itself and powers the whole circuit. After IGNITION is off (The relay keeps powering itself, untill the countdown of 20 seconds is done after removing 12V from SIG. input).
Rectifier diode is set on coil of this relay (A1) so that it wont be powering FINDER relay after IGNITION is turned off.
This setup works for me very well. The only downside is the 20seconds delay on startup (which I dont really mind, since I let the car to have a little warmup so that oil reaches the other parts of the engine). Also if I will try to startup my car after 20seconds passed, the Pi will die in the middle of the booting, since while starting, the car shutsdown everything.
So far, everything works like a charm. No problems for me.
Hope it is understandable, even the drawings.
I wanted to get rid of as many batteries as possible, while maintin a "safe" shutdown, but also get rid of electricity in the whole circuit.
For the pracitcal issues, I couldnt get a CarPiHat so I went DIY way.
I rely on.:
- 2x relays; 1. FINDER relay (simple relay), 2. CRM relay (with additional features as timing)
1x convertor
1x rectifier diode
1x TVS diode
FINDER relay;
- TVS diode is connected on coil (A1, A2) - just in case of voltage spikes
- redirects 12V to SIG. input on CRM relay
- closing contact (COM, NO) for GPIO on Raspberry Pi - Raspberry pi has a python script that watches if the contact is closed or opened. Once the IGNITION is turned off, the python script for shutdown executes and Pi is about to sleep.
CRM relay;
This relay has many functions, I am using a DELAY function. When 12V is provided to SIG. input, the delay will activate relay after 20 seconds passed. The same goes for the off state - when 12V is taken from SIG. input, after 20 seconds the relay is deactivated.
This relay also makes a bypass for itself and powers the whole circuit. After IGNITION is off (The relay keeps powering itself, untill the countdown of 20 seconds is done after removing 12V from SIG. input).
Rectifier diode is set on coil of this relay (A1) so that it wont be powering FINDER relay after IGNITION is turned off.
This setup works for me very well. The only downside is the 20seconds delay on startup (which I dont really mind, since I let the car to have a little warmup so that oil reaches the other parts of the engine). Also if I will try to startup my car after 20seconds passed, the Pi will die in the middle of the booting, since while starting, the car shutsdown everything.
So far, everything works like a charm. No problems for me.
Hope it is understandable, even the drawings.
- Attachments
-
- VOLOVOLO-FOR-FORUM [1] conv 1.png (223.42 KiB) Viewed 190 times