Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using lm-sensors to get temperature

Tags:

c++

c

I've done an app to communicate with an arduino board that shows the info i send in a LCD. The problem is that i want to send the CPU temp, i know the best is use lm-sensors (i'm using linux) but don't know how, it doesn't have any example, so, does somebody know how to use it or where i can get an example?

like image 214
samkpo Avatar asked Apr 14 '12 02:04

samkpo


People also ask

How can I check the temp of my CPU?

There are multiple programs to choose from, with the best tools for checking CPU temperature, including Core Temp (opens in new tab), NZXT's CAM (opens in new tab), AIDA64, HWiINFO, or HWMonitor.

How do I monitor temperature in Linux?

Navigate to the Menu bar of the Linux system, and search for Psensor. You will find the installed Psensor application in it. Click on it to open it and try using it. You will see the graph and statistics of the CPU in the Psensor temperature monitor window.


1 Answers

If the lm_sensors modules are already loaded, the temperatures should be accessible in files from sysfs (for example: /sys/class/hwmon/hwmon0/device/temp1_input) that you can read with standard C/C++ file functions.

http://www.kernel.org/doc/Documentation/hwmon/sysfs-interface

like image 68
alexisdm Avatar answered Nov 15 '22 11:11

alexisdm