Introduction: RaspberryPi 3 Temperature Monitor

Picture of RaspberryPi 3 Temperature Monitor

With the new RaspberryPi model 3 there is a lot talk about heat and heatsinks on the forums.

Some people have reported temperatures as high as 100 Celsius when running it in a high temperature environment, heavy graphic applications, in an enclosure, or overclocking. Pimoroni has added an opening above the CPU in their Pibow 3 Coupé case to improve ventilation.

This is a simple command line program to measure the temperature of any model RaspberryPi.

I have only had my model 3 for a few days and most of my testing has been using the GPIO. I have only seen it go as high as 55 Celsius.

Step 1: The Program

Open the terminal and compile the program with the command: gcc -o temp temp.c

Run the program with the command: ./temp

You can put it in the path so you don't need to type the "./" and run it from anywhere with the command:

sudo mv temp /usr/bin/temp


/***********************************************************
 * Filename: temp.c
 *
 * A program to measure the processor temperature on the 
 * RaspberryPi.
 * 
 * Compile with the command: gcc -o temp temp.c
 *
 * Execute with the command: ./temp
 *
 **********************************************************/
#include <stdio.h>
#include <fcntl.h>

int infile;

float temp1;

int main()
{
   FILE *infile;
   infile = fopen("/sys/class/thermal/thermal_zone0/temp", "r");

   fscanf(infile, "%f",&temp1);

   temp1/=1000;  
   printf("%.1f C\n", temp1);

   return 0;
}

Comments

tmcgough (author)2017-10-07

For us lazy americans... Here is the printf for F.

printf("%.1f F\n", (temp1*1.8)+32);

JRV31 (author)2016-04-24

A big thank you goes out to whoever posted a link to this instructable at

https://lockerdome.com/6391315667620929/8550823982705684

JRV31 (author)2016-03-24

Thank you whoever posted a link to this instructable at

https://lockerdome.com/6391315667620929/8550823982705684

andyk75 made it! (author)2016-03-20

Tried it and works perfectly! :-)

Maybe I should consider more c-programming in future. I concentrated mostly on shell-scripts in the past. But this is so easy. Done in less than a minute!

In fact, I deleted the " C" to facilitate further processing of the result!

andyk75 (author)2016-03-13

Very simple but efficient! I have to try this!

Thanks for sharing!

About This Instructable

3,761views

14favorites

License:

Bio: Most of my instructables will be tutorials for Atmel microcontrollers, Arduino, or Raspberrypi. I try to show concepts that you can use in your own ... More »
More by JRV31:Non-slip SoxMoonLight7400 Quad Nand Gate Simulation
Add instructable to: