July 19, 2022
The Pi does draw current when “off,” so if you’re running on a battery, or trying to reduce the amount of power you use to the absolute minimum, you’ll still want some sort of external electrical power switch. Also, DC power lines (5V and 3.3V) stay active when off, which could be a good or bad thing depending on your setup. The following power consumptions were measured on Raspberry Pi Zero 2 W using an AMANKA USB Multimeter:
- 120mA: pi in idle (raspian lite), with all power optimizations
- 50mA: pi shutdown
- 40mA: pi shutdown with firmware modified for WAKE_ON_GPIO=0 and POWER_OFF_ON_HALT=1
On a Pi Zero 2 W, 40mA is the minimum power consumption for a pi in halt (shutdown). Running on a solar powered battery this is still quite a drag: at night (in summer in Austria ~10 hours of no sun) pi in halt still consumes ~400mA overnight. For a completely autonomous solar powered raspberry pi setup, some sort of external electrical power switch, or power cycling circuit, is needed. For the klangnetze agents, a dedicated power cycling circuit was designed to connect the three main hardware components: the solar charger, the voltage regulator and the Raspberry Pi Zero 2 W.
The main function of the power cycling circuit is to cut down power at night, and to fresh reboot the pi at daytime. The circuit is also designed to wait for pi to shutdown before cutting down the current, to avoid SD card corruption. The power cycling circuit is built around a SN74HC03N NAND gate that outputs a logical LO when both its input are HI.
Input 1 is HI when Pi is shutdown, LO when Pi is running. Input 2 is HI when there is no sun, LO when there is sun. Output is LO only when Pi is not running AND there is no sun.
Output is then fed to the Enable pin of the voltage regulator, which cuts current when pulled LO.
Pis have a dedicated overlay to pull a GPIO pin HI when the pi is shutdown. This can be activated by modifying the file /boot/config.txt to include the following line:
This defaults to pin BCM 26. By monitoring the status of this pin, it is then possible to tell whether Pi is running (LO) or shutdown (HI). However, testing again the pi power consumption with dtoverlay=gpio-poweroff results in Pi consuming
- 200mA: pi shutdown
Which on a solar system is very undesirable since, with this overlay enabled, Pi consumes more in shutdown (200mA) than in idle (120mA). In this case, a workardound for a safe shutdown is to consider sunset time. In Austria, between June and September, sun never sets before 7pm. Shutting down Pis at 6pm therefore ensures a safe shutdown. Battery charge level is also taken into consideration, so that Pi is also shut down as soon as low battery (3.3v) is detected.