Advertisement
dhruvag2000

temperature_read.c

Oct 30th, 2021
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. #include <stdio.h>      // for printf()
  2. #include <unistd.h>     // for sleep()
  3.  
  4. int main() {
  5.  
  6.         FILE *fp;
  7.         char buff[8];
  8.  
  9.         while(1) {
  10.         fp = fopen("/sys/class/hwmon/hwmon0/temp1_input", "r");
  11.         fscanf(fp, "%s", buff);
  12.         printf("temperature = %s\n", buff );
  13.         sleep(2);
  14.         fclose(fp);
  15.         }
  16.         return 0;
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement