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 retail 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" - 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. input Set if the gpio pin should be configured as an input. export Set to export the configured pin to sysfs
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.