Hardware Status Monitoring?
#8
(03-31-2018, 06:30 PM)NicoD Wrote: I wrote this C program to monitor the CPU temp. Just put it in Geany or another C compiler, save it as a *.c file, I call it tempCheck.c
Then compile it and run it.
Code starts after this.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void sleep_ms(int milliseconds)
{
struct timespec ts;
ts.tv_sec = milliseconds / 1000;
ts.tv_nsec = (milliseconds % 1000) * 1000000;
nanosleep(&ts, NULL);

}

int main()
{
int nanosleep(const struct timespec * req, struct timespec * rem);
FILE *temperature;
double T;
while(1)
{
temperature = fopen("/sys/class/thermal/thermal_zone0/temp", "r");

if(temperature == NULL)
{
printf("Can't measure the cpu temperature");
}
else
{
fscanf(temperature, "%lf", &T);
T /= 1000;
system("clear");
printf("The cpu temperature is %6.3f C.\n", T);
fclose(temperature);
sleep_ms(500);
}
}return 0;
}

For those that don't want to compile a program, this can be done in two lines of bash ;-) :


Code:
temp=$(cat /sys/class/thermal/thermal_zone0/temp)
echo ${temp::-3}.${temp:(-3)} C
  Reply


Messages In This Thread
Hardware Status Monitoring? - by Leapo - 03-20-2018, 12:48 PM
RE: Hardware Status Monitoring? - by evilbunny - 03-20-2018, 09:35 PM
RE: Hardware Status Monitoring? - by pfeerick - 03-21-2018, 05:28 AM
RE: Hardware Status Monitoring? - by Leapo - 03-21-2018, 03:40 PM
RE: Hardware Status Monitoring? - by NicoD - 03-31-2018, 06:30 PM
RE: Hardware Status Monitoring? - by PopcornMaker - 06-25-2019, 04:04 AM
RE: Hardware Status Monitoring? - by bendem - 03-15-2020, 08:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  The state of mainline hardware decoding CounterPillow 17 18,068 01-26-2022, 03:39 PM
Last Post: sigmaris
  Hardware acceleration using FFmpeg gusarg81 0 3,097 08-21-2020, 01:36 PM
Last Post: gusarg81
  hardware-accelerated video transcoding (Plex) on Rock64 mdr 2 8,080 02-07-2019, 03:42 PM
Last Post: mdr
  How to do hardware decoding of video? SuperSaiyanCaleb 9 17,347 08-28-2018, 01:39 PM
Last Post: mcerveny
  H264 hardware encoder not work sueshieh 3 7,151 11-02-2017, 03:57 AM
Last Post: dalmate
  What is name of gpio hardware on a rock64? gene83 6 7,419 10-05-2017, 07:57 AM
Last Post: gene83
  4.4 and Mainline Status Matrices Luke 0 2,679 08-17-2017, 02:32 AM
Last Post: Luke

Forum Jump:


Users browsing this thread: 1 Guest(s)