Tricks to improve Raspberry Pi performance and power consuption
Last Updated on 15th September 2020 by peppe8o
Raspberry Pi is an extraordinary board, useful for several home and educational projects. Even if it has an excellent operating system with Raspberry PI OS Lite, there are some ways to get the best from your board, expecially if you plan to use it as a server.
Below you can find a list of tricks to improve Raspberry PI performances and reduce power consumption.
These tricks don’t include overclock (both CPU and RAM) because this could lead to hardware damages hardly repairable.
1. Using the correct input power
Even if Raspberry Pi can use a common smartphone power supply, it is vital to check the power offered by different power supplies available. Some chargers can only provide low ampere, so these power supplies may appear correctly working but they could strongly afflict performances.
Below, is what reported in Raspberry Pi official docs:
“The Raspberry Pi 3 is powered by a +5.1V micro USB supply. Exactly how much current (mA) the Raspberry Pi requires is dependent on what you connect to it. We have found that purchasing a 2.5A power supply from a reputable retailer will provide you with ample power to run your Raspberry Pi. You can purchase the official Raspberry Pi Power Supply from our website, and you can learn more about the differing power requirements of the various models of the Raspberry Pi on our FAQ page.
Typically, the model B uses between 700-1000mA depending on what peripherals are connected; the model A can use as little as 500mA with no peripherals attached. The maximum power the Raspberry Pi can use is 1 Amp. If you need to connect a USB device that will take the power requirements above 1 Amp, then you must connect it to an externally-powered USB hub.
The power requirements of the Raspberry Pi increase as you make use of the various interfaces on the Raspberry Pi. The GPIO pins can draw 50mA safely, distributed across all the pins; an individual GPIO pin can only safely draw 16mA. The HDMI port uses 50mA, the camera module requires 250mA, and keyboards and mouse can take as little as 100mA or over 1000mA! Check the power rating of the devices you plan to connect to the Pi and purchase a power supply accordingly.”
So, be careful about using the correct Power Supply, especially if you are going to run power-consuming services.
2. Installing ZRAM
zram, formerly called compcache, is a useful module for creating a compressed block device in RAM, like well-known RAM-Disks, but with on-the-fly “disk” compression. The block device created with zram can then be used for swap or as a general-purpose RAM disk.
The RPI ZRAM from novaspirit improves this feature automatically detecting the number of CPU cores to allocate to ZRAM computation, disabling the existing swap and enabling ZRAM swap.
You can find more info in ZRAM project GitHub page. Below are the instructions to install RPI_ZRAM:
Download the script and copy it to /usr/bin/ folder
sudo wget -O /usr/bin/zram.sh https://raw.githubusercontent.com/novaspirit/rpi_zram/master/zram.sh
make file executable
sudo chmod +x /usr/bin/zram.sh
edit /etc/rc.local file to run the script on boot
sudo nano /etc/rc.local
add line before exit 0
/usr/bin/zram.sh &
3. Reduce GPU RAM
Raspberry PI shares RAM with its graphical card. So, if you plan to use your Raspberry as server then you probably prefer to assign the lowest RAM amount to GPU. Below are the instructions to manage this:
Enter the Raspberry Pi Software configuration tool:
sudo raspi-config
Go to Advanced Options -> Memory Split and set this value to the minimum (16).
4. Disable HDMI
Leaving the HDMI circuit on a board that we can manage by ssh connection (so, without display and/or keyboards) is power wasting. Raspberry Pi Foundation states that HDMI circuits can consume up to 25mA.
As we said before, power management can be crucial for our boards. So you can turn it off with a simple command:
/usr/bin/tvservice -o
If you want this to be applied also at boot time, add this command to the end of your/etc/rc.local (before the line “exit 0”).
4. Disable Bluetooth Module
One more module unused in headless installations. This is really rare that you will need Bluetooth on when using your RPI in headless mode. You can disable Bluetooth module by editing the config.txt file:
sudo nano /boot/firmware/config.txt
and appending at the end:
dtoverlay=disable-bt
This should save an additional 60 mA to your RPI power consumption.
5. Use Fast MicroSD Card
SD cards for Raspberry PI are something similar to Hard Disks for Personal Computers. SD cards differ from others in Read/Write speed. A faster SD card means something like when you change your PC Hard Drive with an SDD: it is similar to a generation jump.
Prefer at least class 10 micro SD cards.
Let me know if you want to suggest other tricks!
What’s Next
If you are interested in more Raspberry PI projects, take a look at my Raspberry PI tutorials.
Enjoy!
Great guide.
I think there is more to put into this guide. If running on a pi where there is no Bluetooth and wireless or Don’t use it then a guide for how to disable and what that can be disabled would be nice.
Disable Wifi module too.
Do u really consider Sandisk Ultra a “fast” card…..?!?!?!? Try Extreme Plus/Pro
😉
Would like to know how to make it a faster GUI WEB browser PC, not necessarily a file server.
Hi Bill,
I suppose you are wishing how to get a faster desktop environment. In this sense solutions are only managing correctly GPU memory sharing and using a very fast SD card, avoiding any unnecessary browser addons. I have an RPI 4 model B used as desktop computer and I get the most performance improvement when I also disabled desktop animations (with the Foundation Pixel DE). Also trying some light OS (like Puppy Linux) could be a way.
I still haven’t prepared a list of performance optimizations for this scope, but feel free to share your experience.
Best regards,
Giuseppe