Skip to content

Instantly share code, notes, and snippets.

@enrialonso
Created October 9, 2021 23:20
Show Gist options
  • Save enrialonso/c918c47e412237187b4703c2662aa72f to your computer and use it in GitHub Desktop.
Save enrialonso/c918c47e412237187b4703c2662aa72f to your computer and use it in GitHub Desktop.
Get temperature of CPU Raspberry PI 4 from bash script

Get temperature of CPU Raspberry PI 4

#!/bin/bash
cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
cpuTemp1=$(($cpuTemp0/1000))
cpuTemp2=$(($cpuTemp0/100))
cpuTempM=$(($cpuTemp2 % $cpuTemp1))

echo CPU temp"="$cpuTemp1"."$cpuTempM"'C"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment