How to Check CPU Temperature and Usage on Raspberry Pi?


Monitoring your Raspberry Pi's CPU temperature and usage helps prevent overheating and optimize performance. Here are the best methods:
1. Check CPU Temperature
Method 1: vcgencmd
(Built-in Command)
bash
vcgencmd measure_temp
Example Output:
text
temp=45.6'C
Method 2: Read from /sys/class/thermal
bash
cat /sys/class/thermal/thermal_zone0/temp | awk '{printf "%.1f°C\n", $1/1000}'
Example Output:
text
47.2°C
Method 3: Install sensors
(for Advanced Monitoring)
bash
sudo apt install lm-sensors
sensors
(Note: May require additional configuration for RPi.)
2. Check CPU Usage
Method 1: top
(Real-Time Monitoring)
bash
top
Press
q
to exit.Look for
%Cpu(s)
at the top.
Method 2: htop
(Enhanced Version)
bash
sudo apt install htop
htop
Shows per-core usage in color.
Press
F10
to exit.
Method 3: mpstat
(Detailed Stats)
bash
sudo apt install sysstat
mpstat 1 # Updates every second
Example Output:
text
%usr %nice %sys %iowait %irq %soft %steal %idle
20.1 0.0 3.2 1.5 0.0 0.1 0.0 75.1
3. Automated Monitoring (Logging & Alerts)
Log Temperature to a File
bash
while true; do vcgencmd measure_temp >> cpu_temp.log; sleep 5; done
(Runs every 5 seconds. Stop with Ctrl+C
.)
Set Up High-Temp Alerts
bash
#!/bin/bash
TEMP=$(vcgencmd measure_temp | cut -d= -f2 | cut -d\' -f1)
if (( $(echo "$TEMP > 80" | bc -l) )); then
echo "Warning: High CPU temperature! ($TEMP°C)" | mail -s "RPi Overheat Alert" your@email.com
fi
(Run as a cron job every few minutes.)
4. GUI Tools (For Desktop Users)
RPi-Monitor (Web Dashboard)
bash
sudo apt install raspimon
- Access via
http://your-pi-ip:8888
Conky (Desktop Widget)
bash
sudo apt install conky
conky
(Displays CPU temp, usage, RAM, and more.)
5. Safe Temperature Ranges for Raspberry Pi
Status | Temperature Range | Action |
Normal | < 60°C | No action needed. |
Warm | 60°C - 80°C | Improve cooling (add heatsink/fan). |
Critical | \> 80°C | Throttling occurs. Shut down if persistent. |
(Throttling starts at 80°C*; Pi may shut down at **85°C**.)*
Cooling Tips for Raspberry Pi
Passive Cooling: Use a heatsink (works for light loads).
Active Cooling: Add a 5V fan (GPIO-powered or USB).
Case Ventilation: Ensure proper airflow in the enclosure.
Undervolting: (Advanced) Reduce power usage with
vcgencmd
.
Final Thoughts
For quick checks: Use
vcgencmd measure_temp
andhtop
.For long-term logging: Use cron jobs + email alerts.
For overheating issues: Improve cooling and check background processes (
top
).
Subscribe to my newsletter
Read articles from ampheo directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
