Monitor Your CPU & GPU Temps Remotely

General mintyPi-related chat goes here. Share ideas, ask questions that don't fit into the hardware/software help forums, etc.
Post Reply
User avatar
AdmiralP
Posts: 14
Joined: Wed Dec 27, 2017 8:49 am
Has thanked: 5 times
Been thanked: 3 times

Monitor Your CPU & GPU Temps Remotely

Post by AdmiralP » Wed Jan 10, 2018 3:47 pm

I know a lot of people use a thermal pad in their build. One of the main reasons this is done is because there is no easy way to measure the temps of the Pi. Let me be clear: I don’t think there is anything wrong with it. I’m also certain that it is doing no harm.
However, I thought this little utility might help people looking to shave even a little bit off of their project costs. It will also be useful for those experimenting with different overclocks.

Awhile back I threw together this short script to monitor my Pi 3 because I was regularly seeing the thermometer icon appearing on the top-right of the screen. I had added a fan/heatsink combo, and used this little tool to monitor the temp via SSH as I ran a variety of different tasks. The script (as you can see) was largely created by Vivek Gite, so many thanks to Vivek.

Once you have it setup you can constantly monitor both the CPU & GPU temps from your computer.

The first thing you will need to do is configure SSH. This will not only make it easier to create the script, but will be necessary to monitor temps during use. I use mRemoteNG (https://mremoteng.org/), but you can use PuTTY or any other preferred software that will let you use SSH.

Create the script:

Code: Select all

cd /bin
sudo nano pitemp.sh
Insert the following into the script:

Code: Select all

#!/bin/bash
# Script: my-pi-temp.sh
# Purpose: Display the ARM CPU and GPU  temperature of Raspberry Pi 2/3 
# Author: Vivek Gite <www.cyberciti.biz> under GPL v2.x+
# -------------------------------------------------------
cpu=$(</sys/class/thermal/thermal_zone0/temp)
echo "$(date) @ $(hostname)"
echo "-------------------------------------------"
echo "GPU => $(/opt/vc/bin/vcgencmd measure_temp)"
echo "CPU => $((cpu/1000))'C"
Now we need to make the script executable:

Code: Select all

sudo chmod +x pitemp.sh
Next you can execute the file in one of two ways. The first will give you the current temp and leave it at that. The second will monitor the temp every X amount of seconds.

To execute the script one time simply type:

Code: Select all

pitemp.sh
To execute it on an infinite loop every X seconds type:

Code: Select all

watch –n”X” pitemp.sh
Replace the “X” with the number of seconds you want it to use as a refresh rate.
"ACCOUNTABILITY: A word leaders start to use right before the scapegoating begins."
- Despair.com

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest