Could you please provide some more details? We do not have a CarPi Hat unit on hand, so we are unable to test the script directly on the device. We are relying solely on the CarPi Hat GitHub repository you mentioned. We tested the script using raw GPIO, and the shutdown is triggered after 10 seconds when GPIO12 is pulled low (shorted to GND). Also GPIO25 remains HIGH when Raspberry Pi is running.
having loading CarPiHat software issues
Re: having loading CarPiHat software issues
Re: having loading CarPiHat software issues
Another user here. I will try the software as soon I finish the hardware redo. Thanx Again.
Re: having loading CarPiHat software issues
When I plug 12v sw, pi start. No worry for that.
When i turn off +12v. The Pi won't shutdown.
But if I close trixie over software. The pi is totally shut off.
When i turn off +12v. The Pi won't shutdown.
But if I close trixie over software. The pi is totally shut off.
Re: having loading CarPiHat software issues
We could not find any information regarding built-in pull-up or pull-down resistors on the CarPiHat. However, you can try enabling the internal pull-down resistor to test the behavior.
To enable the internal pull-down on GPIO12, replace the following line in the script (sudo nano /usr/local/bin/pi-shutdown.py):
to:
Restart is required after changing the script.
https://gpiozero.readthedocs.io/en/stab ... nputDevice
To enable the internal pull-down on GPIO12, replace the following line in the script (sudo nano /usr/local/bin/pi-shutdown.py):
Code: Select all
ignition = DigitalInputDevice(IGN_PIN, pull_up=None, active_state=True)Code: Select all
ignition = DigitalInputDevice(IGN_PIN, pull_up=False, active_state=True)https://gpiozero.readthedocs.io/en/stab ... nputDevice
pull_up (bool or None) – If True, the pin will be pulled high with an internal resistor. If False (the default), the pin will be pulled low. If None, the pin will be floating.
Re: having loading CarPiHat software issues
thanx for your help but, I have the the same result than before...
Re: having loading CarPiHat software issues
What is the output of pinctrl command when "IGN" is ON and OFF?
Edit:
Looks like in gpiozero, active_state cannot be set with pull_up. Try to use this line:
Edit:
Looks like in gpiozero, active_state cannot be set with pull_up. Try to use this line:
Code: Select all
ignition = DigitalInputDevice(IGN_PIN, pull_up=False)Re: having loading CarPiHat software issues
This is what I was using before using Korni's canbus stuff. now its a bit different
But this should work for you. If its not then you might have the faulty CarpiHat Pro5's that went out.
Version 1 (/usr/local/bin)
Service File (/etc/systemd/system)
To enable and start the service so the script runs every boot
Add this in config.txt
Don't forget to
But this should work for you. If its not then you might have the faulty CarpiHat Pro5's that went out.
Version 1 (/usr/local/bin)
Code: Select all
#!/usr/bin/env python3
"""
CarPi Power Management (IGN monitoring only)
- Uses hardware for actual power shutdown
- Logs major state transitions for diagnostics
"""
import lgpio, time, os, signal, sys
import logging
# --- Logging Setup ---
logging.basicConfig(
filename="/var/log/carpi.log",
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
)
logging.info("CarPi power manager started")
# --- Configuration ---
IGN_PIN = 12 # BCM12 - ignition sense
IGN_LOW_TIME = 10 # seconds ignition must stay low before shutdown
POLL_INTERVAL = 0.1
# --- Setup GPIO ---
h = lgpio.gpiochip_open(0)
lgpio.gpio_claim_input(h, IGN_PIN)
shutdown_initiated = False
timer = 0.0
# --- Cleanup handler ---
def exit_handler(*_):
logging.info("CarPi power manager exiting")
try:
lgpio.gpiochip_close(h)
except:
pass
sys.exit(0)
signal.signal(signal.SIGINT, exit_handler)
signal.signal(signal.SIGTERM, exit_handler)
# --- Main loop ---
try:
while True:
ign = lgpio.gpio_read(h, IGN_PIN)
if ign == 1:
# Ignition ON
if timer > 0:
logging.info("IGN high → reset shutdown timer")
timer = 0.0
else:
# Ignition OFF
if timer == 0:
logging.info("IGN dropped → countdown started")
timer += POLL_INTERVAL
if timer >= IGN_LOW_TIME and not shutdown_initiated:
shutdown_initiated = True
logging.info(
f"Shutdown triggered after {timer:.1f}s of IGN low (hardware will cut power)"
)
os.system("sudo shutdown -h now")
break
time.sleep(POLL_INTERVAL)
except KeyboardInterrupt:
exit_handler()
finally:
exit_handler()
Service File (/etc/systemd/system)
Code: Select all
[Unit]
Description=CarPi Power Management for Raspberry Pi
After=multi-user.target
Before=shutdown.target halt.target reboot.target
[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/local/bin/carpi.py
# Only restart if crash — NOT when intentional CAN sleep or shutdown delay
Restart=on-failure
RestartSec=3
User=root
Environment=PYTHONUNBUFFERED=1
StandardOutput=journal
StandardError=journal
# Allow script to cleanly release GPIO latch before shutdown
ExecStop=/usr/bin/pkill -f carpi.py
KillSignal=SIGINT
TimeoutStopSec=10
[Install]
WantedBy=multi-user.target
Code: Select all
sudo system enable carpi.service
sudo system start carpi.service
Code: Select all
# CANBUS
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=23,spimaxfrequency=1000000
# CarPi
dtoverlay=gpio-poweroff,gpiopin=25,active_low
#dtoverlay=hifiberry-dacplus-stdRe: having loading CarPiHat software issues
Can you tell me more about your new software system to automatic shutdown? Is it present in the korni's github page?
Re: having loading CarPiHat software issues
See https://github.com/SamT-J/CarPiHat/wiki ... tart-GuideHiphouser wrote: Wed Jan 28, 2026 3:28 pm Can you tell me more about your new software system to automatic shutdown? Is it present in the korni's github page?
Re: having loading CarPiHat software issues
Thanx for your link.
I'm using CarPiHat Pro 5, same system like you,
But korni92 have developped a software for Audi RNS-E.
Software listen Canbus traffic to automatic shutdown the Pi.
The solution is nice too, because when you unlock your car, pi booting, and i'll already ready when you start the car. Before ingnition.
I'm using CarPiHat Pro 5, same system like you,
But korni92 have developped a software for Audi RNS-E.
Software listen Canbus traffic to automatic shutdown the Pi.
The solution is nice too, because when you unlock your car, pi booting, and i'll already ready when you start the car. Before ingnition.