Run the following command in the terminal:
vcgencmd measure_temp
This will output the temperature in Celsius, e.g.:
temp=45.0'C
You can directly read the temperature from the system file:
cat /sys/class/thermal/thermal_zone0/temp
The output will be in millidegrees Celsius, e.g., 45000 means 45.0°C. To convert it to degrees Celsius, divide by 1000:
echo "$(cat /sys/class/thermal/thermal_zone0/temp) / 1000" | bc
You can also use Python to read and display the temperature:
with open("/sys/class/thermal/thermal_zone0/temp") as f:
temp = int(f.read()) / 1000
print(f"Temperature: {temp}°C")
If you're running a desktop environment, tools like Pi Apps or the Raspberry Pi Configuration utility may display the temperature.
Use a script or monitoring tool like Pi-hole, Node-RED, or Grafana with Prometheus to track and graph the temperature over time for better visibility.
Note: Ensure good ventilation or heatsinks if temperatures consistently exceed 70°C, as prolonged high temperatures can throttle performance.