Code: Select all
cat /sys/class/thermal/thermal_zone0/tempWhat’s 38459 supposed to mean?mallets wrote: ↑Thu Sep 19, 2019 4:02 amworks for me. I'm still searching for the CPU freq value though.Code: Select all
cat /sys/class/thermal/thermal_zone0/temp
It's a prime number!Pimaxin wrote: ↑Thu Sep 19, 2019 9:17 amWhat’s 38459 supposed to mean?mallets wrote: ↑Thu Sep 19, 2019 4:02 amworks for me. I'm still searching for the CPU freq value though.Code: Select all
cat /sys/class/thermal/thermal_zone0/temp
If that is the value returned from that command for you, it means your CPU temperature is currently 38.459°CPimaxin wrote: ↑Thu Sep 19, 2019 9:17 amWhat’s 38459 supposed to mean?mallets wrote: ↑Thu Sep 19, 2019 4:02 amworks for me. I'm still searching for the CPU freq value though.Code: Select all
cat /sys/class/thermal/thermal_zone0/temp
Code: Select all
cat /sys/class/thermal/thermal_zone0/tempCode: Select all
#!/bin/bash
temp=$(</sys/class/thermal/thermal_zone0/temp)
temp_f=`echo "$temp/1000" | bc -l`
printf "CPU Temp: %.3f°C\n" $temp_f
Code: Select all
#include <stdio.h>
int main(int argc, char *argv[])
{
FILE *fp;
int temp = 0;
fp = fopen("/sys/class/thermal/thermal_zone0/temp", "r");
fscanf(fp, "%d", &temp);
printf(">> CPU Temp: %.2f°C\n", temp / 1000.0);
fclose(fp);
return 0;
}
Code: Select all
$ gcc temp.c -o temp
Code: Select all
$ sudo mv ./temp /usr/local/bin/
Code: Select all
aturfer@pi4:~$ temp
>> CPU Temp: 42.35°C
Code: Select all
echo ">> CPU Freq:" $(($(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)/1000))MHz
Code: Select all
lscpu | grep -i mhz
Simple and sexy. One more request how can we get a continuous updates.aturfer wrote: ↑Sat Jun 06, 2020 11:12 pmFor those who feel like compiling something, create file temp.c with the following:
Compile with:Code: Select all
#include <stdio.h> int main(int argc, char *argv[]) { FILE *fp; int temp = 0; fp = fopen("/sys/class/thermal/thermal_zone0/temp", "r"); fscanf(fp, "%d", &temp); printf(">> CPU Temp: %.2f°C\n", temp / 1000.0); fclose(fp); return 0; }
Then copy to directory in your path:Code: Select all
$ gcc temp.c -o temp
Run from anywhere:Code: Select all
$ sudo mv ./temp /usr/local/bin/
Code: Select all
aturfer@pi4:~$ temp >> CPU Temp: 42.35°C