Last active
May 24, 2021 21:54
-
-
Save xzeldon/c2ca353d3e852ae89214c12ee511eb47 to your computer and use it in GitHub Desktop.
Raspberry Pi 4 CPU temperature monitoring (Ubuntu Server LTS 20.04)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
int main(int argc, char *argv[]) | |
{ | |
FILE *fp; | |
while(1) | |
{ | |
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); | |
sleep(1); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment