Raspberry Pi Boards are a great gateway for learning about how to get to grips with computers, at a price that makes it hugely accessible and a size that fits right in your hand. Raspberry Pi boards are chock a block full of features and connectivity methods. A full set of GPIO pins, WiFi, Bluetooth, Ethernet, a camera connector, onboard LEDs, HDMI ports and multiple USB to name only a few. When your project is running on battery power (with the PiJuice HAT for example) you will want to have the smallest amount of power being utilised by the Raspberry Pi so that the system will last as long as possible. Thus this guide will go through a number of methods to disable or stop powering certain onboard features so as to save power and extend the battery life of your project. By disabling certain features it also adds a level of security to your Raspberry Pi preventing nefarious agents avenues to mess with your projects.
All these settings work and have been tested with a Raspberry Pi 4 Model B by me. All these settings should be backward compatible with previous Raspberry Pi Generations as well.
The best way to disable most features is to access the Raspbian terminal and type commands directly to it. Most of these features can also be disabled by altering the | /boot/config.txt | file. This guide will go through the following below with the features that draw the most power talked about first.
If you find yourself in a situation where you have disabled too many features or if you just want to return it all back to normal quickly whip out that micro-SD card and re-flash Raspberry Pi OS to it. None of these changes will cause any damage to your Raspberry Pi and are quick to revert. Another method of lowering power consumption is by throttling the CPU. This can be done in situations where simple scripts that do not require heavy CPU, GPU and RAM are being utilised. These settings will require some tweaking to meet the exact needs of your project, check out the guide here on how to tweak these settings, and unless drastically altered do not result in huge power savings.
If you happen to be holding a Raspberry Pi board and not quite sure what it is? Then check out this guide Raspberry Pi Generations to identify it. As always if you have any questions, queries or things to add please let us know your thoughts!
The most power-hungry devices that you can add to any Raspberry Pi are usually connected by USB. Powerbanks being recharged, Hard-drives, USB dongles and all various kinds of devices (like a USB Fridge) will sap the power from the system. This results in the onboard chip that powers all these connections requiring a lot of internal power as well. If your project does not require any of these features it is possible to turn off this onboard chip saving a substantial amount of power (~100mA). Worth noting if you disable USB connections you will disable Ethernet as well, you also cannot turn off a specific USB port. All or none. Also before doing this make sure you have connected via SSH or another method as if you're using the device directly with a keyboard and mouse as soon as you disable the USB ports you will no longer be able to use either peripheral.
To shut off Power for USB Ports first install an application called uhubctl by typing the following into the Terminal. This works briefly then the power switches back on to the ports, investigations are underway to find a solution.
sudo apt-get install uhubctl 2.2.0
This will take some time to install and you will need to type Y and press enter to proceed with the installation process. Once this is complete you can then type this to disable all the USB functionality and stop power going to the chip (note the difference between lowercase L and 1).
sudo while (true) do uhubctl -l 1-1 -p 2 -a 0 -r 1
The other method which will work with Raspberry Pi 3+ and earlier models can be seen below. If you use this on a Raspberry Pi 4 Model B it will stop receiving inputs from your peripherals but it will continue to provide them power. Thus it will continue to provide the onboard chip power and not save energy.
To shut off power for USB ports and Ethernet type the following into the Raspberry Pi Terminal and press enter.
echo '1-1' | sudo tee /sys/bus/usb/drivers/usb/unbind
To turn the power back on for USB ports and Ethernet type the following into the Raspberry Pi Terminal and press enter.
echo '1-1' | sudo tee /sys/bus/usb/drivers/usb/bind
Disabling WiFi not only lower the overall power usage but also improves security for your Raspberry Pi. There are a number of ways to do this. The easiest way is to utilise the program | rfkill |. Type the following into the terminal and press enter for each line. Then on reboot it will be disabled.
sudo apt install rfkill
sudo rfkill block wifi
If you want to re-enable WiFi simply type the following into the terminal.
sudo rfkill unblock wifi
Once again there are a number of ways to do this. The easiest way is to utilise the program | rfkill | again. Type the following into the terminal and press enter for each line (if you have already installed rkill you will not need to reinstall it). Then on reboot it will be disabled.
sudo apt install rfkill
sudo rfkill block bluetooth
If you want to re-enable Bluetooth simply type the following into the terminal.
sudo rfkill unblock bluetooth
Whenever you are remotely accessing the Raspberry Pi using SSH or running it headless then likely there will be no need to run anything through the onboard HDMI ports. This means you can disable power to these ports which will give a small improvement to battery life (~20mA). Type the following into the terminal to disable power to the HDMI ports. As soon as you press enter it will be disabled.
sudo /opt/vc/bin/tvservice -o
If you want to re-enable HDMI connection simply type the following into the terminal.
sudo /opt/vc/bin/tvservice -p
Disable On-Board LEDs
The LEDs are a very small power draw and give a good indication visually on the board as to what the Raspberry Pi Board is doing. However, if you have the Raspberry Pi tucked away in a hidden place or covered in a case then likely there will be no need to run the LEDs as nobody will see them. It also means a running Raspberry Pi will appear to be not powered which could make for some sweet stealthy spy electronic projects. So by disabling power to the LEDs you will gain a small improvement to overall battery life (<2mA potential saving per LED). To do this edit the /boot/config.txt file and add the following lines (when using a Raspberry Pi 4 Model B). Save the file and then on reboot the lights will be disabled. To return the LED lights to normal remove the added lines.