OpenEnergyMonitor Community

Powering down a headless Pi with no network connection

Carrying on from my comments on the Wifi config on Pi Zero using emonSD - #4 by pb66 thread I found myself pondering on the fact that the emonSD IS still partially writable, so if you find yourself with a headless Pi without a functional network connection it is unwise to just “pull the plug” on it as it could be terminal for the SD card.

The emonPi has a push button next to the LCD, so it’s not a problem for the emonPi. However any other Pi based setups and emonBases may have issues, especially if it doesn’t even have an Ethernet socket you can run a lead to. In particular, the Pi Zero’s which do not have an Ethernet socket on board.

This got me thinking that if a Pi is running a emonSD you could use a jumper wire to mimic the emonPi’s shutdown trigger, as the GPIO pin is still monitored on the emonSD even if it’s not an emonPi (I think!).

Better still. Why not monitor the GPIO pin7 when it’s not being used? This pin is connected to the reset line of the emonPi or RFM69Pi or a serial-direct connected emonTx for the purpose of resetting that board for uploading sketches. In the case of a emonPi and a emonTx there is also a dedicated reset button on the device, that button is therefore also connected to the Pi via GPIO pin7. A simple quick push resets the emonPi/emonTx and that could be ignored by the Pi, but a longer hold of the emonPi/emonTx reset button could initiate a controlled shutdown of the Pi to avoid damaging the SDcard.

Adding a reset button to the RFM69Pi in future revisions might be possible/considered, but in the interim the same pin that’s used on the emonPi (GPIO23 p16) can be used with a simple push button (or link wire) connected to +3.3v (the emonPi’s RPi reset button seems to be set up the other way round to the empnPi board and emonTx reset buttons). And it’s monitored and actioned by the script.

Whilst all my own SDcard images are (currently) fully read-only, so it’s less of a problem, I often have a serial-direct emonTx connected so to extend the functionality of the button already there would make sense and be as easy as writing a little script.

Just a thought for possible future consideration, mainly for the 4 CT emonBase using emonTx and Pi Zero W and possibly the STM32 based monitor idea’s being toyed with at the moment.