3

I am working a problem that seems to be fairly popular with the Raspberry Pi community. In essence, I am designing a circuit that will utilize a DS3231, a 555 timer, and a load switch to cut power from the pi when it is off as well as schedule the next time power will be re-applied.

On to my point, How long do I need to wait after a "sudo shutdown -h now" to safely pull power? I am determining the time delay of a 555 timer to propagate the low-going edge of a GPIO pin to the enable of the load switch.

I have also read about the UART TX pin being active in certain states of the OS, namely a halt where the SD card might still be doing something but an active high GPIO might already be pulled back low again. I can't find anything about that right now to figure out if I can leverage this as a final check. I will also have a DS3231 in the circuit to be able to schedule the next wakeup of the pi (we have a headless situation where the pi needs to have programmable control over when it wakes back up).

Questions:

1) How long do I need to wait after a shutdown command before I can safely remove power?

2) Is using a GPIO pin with the python library RPI.GPIO the best solution for this?

3) Is there any other pin like the UART TX that will provide any information as a final analog circuitry check to ensure the power loss won't result in any damage to the SD card?

Once I have this circuit finalized and tested, I'll be uploading my schematics along with PCB layout to the community.

1

Many people seem to be concerned about managing Pi power (although unless running from battery this seems pointless).

There is no simple answer to the question you asked; the ACT LED flashes 10 times before extinguishing when shut down correctly. This indicates that often the delay can be quite long, but is not readily detectable.

There is one method which "Drives a GPIO high or low on poweroff", built into recent firmware which can be used - I believe this was included to control power circuitry. NOTE read the instructions carefully as there is some interaction with other services.

Name:   gpio-poweroff
Info:   Drives a GPIO high or low on poweroff (including halt). Enabling this
        overlay will prevent the ability to boot by driving GPIO3 low.
Load:   dtoverlay=gpio-poweroff,<param>=<val>
Params: gpiopin                 GPIO for signalling (default 26)

        active_low              Set if the power control device requires a
                                high->low transition to trigger a power-down.
                                Note that this will require the support of a
                                custom dt-blob.bin to prevent a power-down
                                during the boot process, and that a reboot
                                will also cause the pin to go low.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.