I don't have a Raspberry Pi laying around at the moment and I would like to detect if my Raspberry Pi is shuted down. My Idea is that maybe after the Pi shutted down the Voltage at the 3V3 pin will drop and I can detect this. And if this still works when the Pi is getting powered via the 5V Pin. Unfortunatly the Raspberry Pi Schematic is not completly available so I am not able to check this right now.
The Pi has 3 "components" the CPU, GPIO and Video Core which are relatively independent. Even when the Pi is shutdown the Video Core continues to run, and the GPIO pins retain their state; only the CPU is not running.
The 3.3V is supplied by separate circuitry and will be present while ever the Pi is connected to a 5V supply.
The best way to reliably detect Pi shutdown is to use the
gpio-poweroff service built into recent firmware which "Drives a GPIO high or low on poweroff" - this was included to control power circuitry. NOTE read the instructions carefully as there is some interaction with other services. You MUST remove power if this is used.
Name: gpio-poweroff Info: Drives a GPIO high or low on poweroff (including halt). Using this overlay interferes with the normal power-down sequence, preventing the kernel from resetting the SoC (a necessary step in a normal power-off or reboot). This also disables the ability to trigger a boot by driving GPIO3 low. The GPIO starts in an inactive state. At poweroff time it is driven active for 100ms, then inactive for 100ms, then active again. It is safe to remove the power at any point after the initial activation of the GPIO. Users of this overlay are required to provide an external mechanism to switch off the power supply when signalled - failure to do so results in a kernel BUG, increased power consumption and undefined behaviour. Usage: 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. input Set if the gpio pin should be configured as an input. export Set to export the configured pin to sysfs active_delay_ms Initial GPIO active period (default 100) inactive_delay_ms Subsequent GPIO inactive period (default 100) timeout_ms Specify (in ms) how long the kernel waits for power-down before issuing a WARN (default 3000).
As GPIO retain their state, other methods of detecting state are unpredictable - the Pi sets the state of the poweroff pin before finally shutting down (and flashes the ACT LED 10 times).
The Pi4 puts the power management chip into a low power state when off - turning off the 3.3V supply and effectively totally shutting down the SoC. This low power on the Pi4 can be disabled e.g. to use the soft reboot option, but requires modified firmware.
This howchoo post shows how to connect an LED to show the status of the Pi. The LED is steady on when the Pi is running, and off after shutdown.
Add this line to /boot/config.txt, and reboot
Connect the TxD pin (GPIO pin 8) to the positive lead of a 2 or 3 volt LED. Connect a ground pin (e.g. GPIO pin 6) to a 330 ohm resistor, then to the negative lead of the LED.