Switching Power Remotely

RPi900 offers several ways of reducing power consumption, an important requirement in battery-powered installations. In one configuration, the DNT900 radio is able to control power to the Raspberry Pi, allowing it to be switched off and on remotely. Conversely, the Raspberry Pi is also able to control the radio’s sleep mode.

Controlling Power to the Raspberry Pi

Use GPIO5 of the radio module to control power to the Raspberry Pi. Enable this configuration by connecting jumper J7 using the supplied shunt:

Jumper J7 connected

(When the jumper is left open, power is permanently applied and GPIO5 is available for other uses.)

Switching power to the remote Raspberry Pi is then a simple matter of setting the GPIO5 register on the radio. With the DNT900 line discipline loaded on the base station, perform one-time setup for GPIO5 as follows:

$su
#echo 0x20 > /sys/class/dnt900/0x00165E/GPIO_Dir    # set GPIO5 as an output
#echo 0x20 > /sys/class/dnt900/0x00165E/GPIO_Init   # Raspberry Pi power initially on (0x00 for off)
#echo 0x01 > /sys/class/dnt900/0x00165E/MemorySave  # save settings

(Where 0x00165E is the MAC address of the remote radio.) Then, to toggle power to the Raspberry Pi:

#echo 0 > /sys/class/dnt900/0x00165E/GPIO5  # power down the Raspberry Pi
#echo 1 > /sys/class/dnt900/0x00165E/GPIO5  # boot up the Raspberry Pi

Of course, you shouldn’t remove power to the remote Raspberry Pi without first shutting it down. How you achieve this depends on the manner of your communication with the Pi. However, if the Raspberry Pi becomes unresponsive for some reason, toggling the power allows you to reboot it remotely.

Sleeping the Radio

The RPi900 design applies permanent power to the DNT900 radio, but a hardware sleep mode allows the radio to effectively power down, consuming only 50 μA. The attached Raspberry Pi can control this sleep mode using one of its general purpose input/output pins, GPIO18.

There are many ways to control GPIOs on the Raspberry Pi. For scripting, I recommend the built-in GPIO driver. In the following example, GPIO18 is set up as an output, and its value switched high to put the radio into sleep mode:

$su
#echo 18 > /sys/class/gpio/export             # set up GPIO18
#echo out > /sys/class/gpio/gpio18/direction  # set function to output
#echo 1 > /sys/class/gpio/gpio18/value        # set value to high (radio enters sleep mode)
#echo 0 > /sys/class/gpio/gpio18/value        # set value to low (radio wakes up)

Sleep mode is only available when the radio is configured as a remote. (Base and router radios must stay awake to route packets through the radio network.) A remote Raspberry Pi could use the sleep mode to periodically wake the radio in order to send data, before returning it to sleep.