cron would not be suitable as all tasks get killed before the shutdown has completed. But that is exactly what the gpio-poweroff overlay is for.Can you have a output pin held high, that reliably goes to a low state, or floats, when the pi shuts down? Can a cron job execute at power down to make an i/o pin low and be the very last task?
To use (for example) GPIO 21 / PIn 40 you would put
Code:
dtoverlay=gpio-poweroff,gpiopin=21,active_low
During startup that pin will go high (3.3V) for 100ms, then low for 100ms, then go high and stay there until a clean shutdown has completed. Then it will go low.
You can use almost any GPIO pin.
No actual coding required. It is already done for you.
One note: Normally the Pi would go into a low power state when it shuts down. It can't do that if this overlay is enabled as it has to hold the pin in the requested state. But if you're going to remove power anyway that's fine. It also displays a warning message on the screen, but that can safely be ignored.
Statistics: Posted by rpdom — Tue Apr 30, 2024 7:41 am