This circuit is the basic principle on which my Pi power-off system operates:
The main point being that GPIO14 (Tx) goes continuously low when the Pi is powered down.
When it’s high it’s pulsing, but the power-off system uses programmed hysteresis (a delay!), and this simple indicator doesn’t need nowt! Simply due to the fact that the pulsing is too fast for the human eye to notice.
I use this circuit for headless Pi devices to confirm that they’re ready to have the power pulled, as being a dad I’m so often distracted!!
This is the code which I have used, slightly adapted, and it works!
I now have a working programme for the PICAXE which monitors the logic level of GPIO14 (TXD0, physical pin 8) on the Raspberry Pi, amongst other things. Building a test model up on breadboard with a PICAXE 14M2, I included a power-off button (this works alongside the previously mentioned Python script), a reset button, and the control circuit for the relay. And the AA-cell-eating relay! There are of course solid-state relays available, but I’m switching UK mains which is around 240 V rms (should be 230, but it isn’t) and I want it to be OFF off. Completely and absolutely switched the chuff off, with a nice big air-gap between the contacts!
I also like the old-fashioned click of the relay 🙂
I have no intention of trying to reinvent a perfectly good wheel.
Also, I haven’t yet learned to code in Python — and I don’t class myself as much of a coder anyway!
This is the code with excellent tutorial that I plan to put into my Raspberry Pi:
There are now many tutorials, Instructables posts, and even devices which help with adding a physical shutdown button to the Raspberry Pi. I want to build something that will completely and utterly shut-the-chuff-off i.e. switch the mains off. I aim to use a PICAXE microcontroller to handle this shutting off via a relay, but the PICAXE needs to know when it is safe to proceed.
I used a handheld oscilloscope to measure the voltage levels of the GPIO pins while the Pi was running, versus it being shutdown with the power still connected. The ONLY pin with a significant change in voltage is GPIO14 (TXD0) on physical pin 8. It drops from around 3.4 V to around 1.3 mV, so I’m hoping that I can use this to indicate to the PICAXE that the Pi has shutdown, or is in the process of shutting down and programme a delay of, say 10 seconds.
This could also work as a fail-safe such that only IF the level is low for this entire duration will it proceed with the switch-off.
40-pin GPIO of the Raspberry Pi 2.