Reading the Raspberry Pi Temperature

In this guide, we will be showing you how to read the temperature of the Raspberry Pi using a simple command.

Raspberry Pi Temperature

Monitoring the temperature of your Raspberry Pi can be a critical task. This is especially true when you are using the device in areas with little airflow.

Officially the Raspberry Pi’s processor is built to withstand temperatures from -40°C to 85°C.

As the Raspberry Pi’s temperature gets closer to its upper limit, the system will automatically begin to throttle the processor to try and help the board cool back down.

This throttling makes it crucial to manage your Raspberry Pi’s temperature to stop the device from losing performance. The throttling can be extra problematic when you are trying to overclock your device.

Reading the temperature of your Raspberry Pi’s processing core is a simple task and can be done using a single command.

Getting the Raspberry Pi Temperature Using the Terminal

Luckily for us, the Raspberry Pi’s processor features an inbuilt temperature probe that we can access.

To be able to retrieve the temperature of the Raspberry Pi, you will need terminal access.

Once you have access to the terminal through SSH or physical access, then you can proceed.

1. To retrieve the temperature of your Raspberry Pi, we can utilize the following command.

/opt/vc/bin/vcgencmd measure_temp

2. From this command, you should get a result like we have below with specifying the temperature of your Raspberry Pi.

temp=42.0'C

One thing that you will notice is that all results from this command are provided in degrees centigrade.

3. If you are in a country that uses Fahrenheit, then you can convert this number by using the following formula (celsius * 1.8) + 32

Alternatively, you can utilize the following command, which will automatically retrieve the value and convert the Raspberry Pi’s temperature to Fahrenheit for you.

/opt/vc/bin/vcgencmd measure_temp | awk -F "[=\']" '{print($2 * 1.8)+32}'

Creating an Alias to Retrieve the Pi’s Temperature

If you check the Raspberry Pi’s temperature often and would like to simplify the command, you can make use of bash aliases.

1. Let’s go ahead and start creating the bash aliases file within the pi user’s home directory by running the command below.

nano /home/pi/.bash_aliases

2. Within this file, enter the following line.

alias temp='/opt/vc/bin/vcgencmd measure_temp'

What this line does is make it so that whenever we type in the word temp, the temperature of the Raspberry Pi will be outputted to the command line.

Once you have entered this line, please save the file by pressing CTRL + X then Y followed by ENTER

3.Before you can use this new alias you need to quit out of the current session and open a new one.

Once you have exited out of the terminal session and gone back in, you will now be able to use the temp command to get your Raspberry Pi’s temperature.

temp

Reducing your Temperature

If you are having trouble with maintaining your Raspberry Pi at reasonable temperatures, here is a quick couple of tips on how to help.

Add a heatsink

Adding a heatsink is one of the easiest ways of reducing the temperature of your Raspberry Pi’s processor.

Heatsinks work by increasing the amount of surface area from which heat can dissipate.

Increasing Airflow

One of the other best ways of improving your Pi’s temperatures is to increase the airflow around the board.

Airflow is one of the best and cheapest ways of efficiently removing heat from your Raspberry Pi.

The easiest way of increasing airflow is to make sure you don’t put the Pi in too much of a closed space as well as using a case that has proper ventilation

Using a fan

Adding a fan to your case is another way of reducing the temperatures of your Raspberry Pi.

The advantage of a fan, of course, is that it helps quickly remove heat from around the device and drag in cooler air.

The most significant disadvantage of using a fan, of course, is the extra noise it will produce.

At this point, you should now have an idea on how to retrieve the temperature of your Raspberry Pi’s processor using a simple command.

If you have any questions or feedback, then feel free to drop a comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *