Lm sensors
This guide describes how to access and display temperature, fan speeds and power voltage information available on most motherboards. The application that makes this possible is lm_sensors.
- See the lm_sensors website for a problematic hardware list.
- Using lm_sensors on IBM ThinkPads is especially not advised.
Refer to your hardware's specific wiki page or the forum for more information.
[edit] Setup
To use sensors, there are two components you will require, the userspace tools, lm_sensors, and some kernel modules.
The usual install procedure goes as follows:
- Install all of the modules into the kernel
- Install lm_sensors
- Use the lm_sensors auto-detect script to determine required modules
- Un-install non-required modules
- Configure sensor names and properties
[edit] Kernel
Unless you know exactly which drivers are needed (You can check supported chipsets at lm_sensors home page), activate everything under 'I2C support' and 'Hardware Monitoring Support' for now. The sensors-detect will let you know which ones you need:
| Linux Kernel Configuration: Sensor Kernel modules |
Device Drivers --->
<M> I2C support --->
<M> I2C device interface
I2C Hardware Bus support --->
# Activate everything
<M> Hardware Monitoring Support --->
# Activate everything
|
[edit] Radeon Cards
See the radeon guide for information.
[edit] Userspace
Install lm_sensors:
If you would like to use monitoring programs, add the USE flag lm_sensors to your /etc/make.conf:
You may have to update your system. Programs like ksysguard utilize lm_sensors:
[edit] Detection
Log in as root and run:
Go through the detection process. At the end sensors-detect writes a new /etc/conf.d/lm_sensors. There you find most modules you need; the rest can be removed again from the kernel. Some modules are not automatically detected, such as coretemp for more recent processors.
You start sensor monitoring by starting the init script:
sensors shows you now the temp, fan speed etc. If you see nothing, look at the troubleshooting section.
If you want to start at sensor monitoring at boot time, add lm_sensors to your runlevel:
[edit] Configuration
By default, lm_sensors does not use any English names for any of the sensors - or it may only have English names for some of them. You can change the names, as well as disable sensors, and change the mathematics that are used by editing the configuration file /etc/sensors.conf. This file contains a lot of comments.
The easiest way change your settings, is to run sensors, and note down the top line returned (the sensor chip), then edit /etc/sensors.conf, and search for the first part of the name. For example, if your sensor chip is a w83781d-isa-0290, a search for w83781d, will return something like:
| Code: Search Result |
|
chip "lm78-*" "lm78-j-*" "lm79-*" "w83781d-*" |
then below this line, will be the config lines for that chip.
An example config is:
chip "lm78-*" "lm78-j-*" "lm79-*" "w83781d-*"
label in0 "VCore 1"
label in1 "VCore 2"
label in2 "+3.3V"
label in3 "+5V"
label in4 "+12V"
label in5 "-12V"
label in6 "-5V"
label temp1 "CPU temp"
label fan2 "CPU fan"
ignore fan1
ignore fan3
ignore temp2
ignore temp3
compute in3 ((6.8/10)+1)*@ , @/((6.8/10)+1)
compute in4 ((28/10)+1)*@ , @/((28/10)+1)
compute in5 -(210/60.4)*@ , -@/(210/60.4)
compute in6 -(90.9/60.4)*@ , -@/(90.9/60.4)This configuration sets some English names, sets ignore on the unused fans, and contains the default calculations for some of the voltages. Most of these values were not changed, except the addition of the labels for CPU temp and CPU fan, and the ignore lines for the fans and temps not in use.
[edit] pwmconfig
Once you have lm sensors properly configured, run pwmconfig to test and configure speed control of your fans:
Follow the instructions in pwmconfig to set up basic speeds.
The default configuration options should create a new file, /etc/fancontrol.
Follow the instructions in pwmconfig to set up speeds.
[edit] Tweaking
echo "255" > /sys/class/hwmon/hwmon0/device/pwm1 to spin up the fan all the way until things cool down. Basically, you should know what you're doing before fooling with the configuration file.If you want more control, you will probably need to tweak the generated configuration. Here is a sample configuration file:
INTERVAL=10 DEVPATH=hwmon0=devices/platform/coretemp.0 hwmon2=devices/platform/w83627ehf.656 DEVNAME=hwmon0=coretemp hwmon2=w83627dhg FCTEMPS=hwmon0/device/pwm1=hwmon0/device/temp1_input FCFANS= hwmon0/device/pwm1=hwmon0/device/fan1_input MINTEMP=hwmon0/device/pwm1=20 MAXTEMP=hwmon0/device/pwm1=55 MINSTART=hwmon0/device/pwm1=150 MINSTOP=hwmon0/device/pwm1=105
- INTERVAL: how often the daemon should poll cpu temps and adjust fan speeds. Interval is in seconds.
The rest of the configuration file is split into (at least) two values per configuration option. Each configuration option first points to a PWM device which is written to which sets the fan speed. The second "field" is the actual value to set. This allows you to monitor and control multiple fans and temperatures (if your pc supports it).
- FCTEMPS: The temperature input device to read for cpu temperature. The above example corresponds to
/sys/class/hwmon/hwmon0/device/temp1_input. - FCFANS: The current fan speed, which can be read (like the temperature) in
/sys/class/hwmon/hwmon0/device/fan1_input - MINTEMP: The temperature (°C) at which to SHUT OFF the cpu fan. Efficicent CPU's often will not need a fan while idling. Be sure to set this to a temperature that you know is safe. Setting this to 0 is not reccommended, use a sane value.
- MAXTEMP: The temperature (°C) at which to spin the fan at it's MAXIMUM speed. This should be probably be set to perhaps 10 or 20 degrees (°C) below your CPU's critical/shutdown temperature. Setting it closer to MINTEMP will result in higher fan speeds overall.
- MINSTOP: The PWM value at which your fan stops spinning. Each fan is a little different. Power tweakers can:
and then watch the cpu fan. When it stops, use this value.
- MINSTART: The PWM value at which your fan starts to spin again. This is often a higher value than MINSTOP as more voltage is required to overcome inertia.
There are also two settings fancontrol needs to verify the configuration file is still up to date. The lines start with the setting name and a equality sign, followed by groups of hwmon-class-device=setting, seperated by spaces. You need to specify each setting for each hwmon class device you use anywhere in the config, or fancontrol wont work.
- DEVPATH: Sets the physical device. You can determine this by executing the command
- DEVNAME: Sets the name of the device. Try
[edit] fancontrol
Try to run fancontrol:
[edit] Fine tune fan speed
If you'd like to see how various pwm values translate into fan RPM. As you can see, this script assumes that you have fancontrol running and disables it for you, then re-enables it when you're finished. Enjoy.
#!/bin/bash
clear
#################################################
# change the following lines to match your system
#################################################
pwmcontrol=/sys/class/hwmon/hwmon4/device/pwm1
fanrpmread=/sys/class/hwmon/hwmon4/device/fan1_input
# do not edit below this line
#################################################
log=`pwd`/fandata.log
echo "PWM,RPM" > $log
echo "This script will set your PWM to values from full power down to 0 decreasing in"
echo "approx 5 % steps and pausing 10 sec between steps to allow the fan RPM to catch"
echo "up to the new settings. Data are logged to ${log}"
echo "which can be used to generate a graph or use as-is."
collectdata() {
array=( 255 242 230 217 204 191 178 165 152 139 126 113 100 87 74 48 22 0 )
for item in ${array[*]}
do
echo $item > $pwmcontrol
sleep 10s
rpm=`cat ${fanrpmread}`
echo $item,$rpm >> $log
echo "PWM: ${item} RPM: ${rpm}"
done
}
/etc/rc.d/fancontrol stop
echo "1" > ${pwmcontrol}_enable
collectdata
echo "0" > ${pwmcontrol}_enable
/etc/rc.d/fancontrol start
Run this script:
[edit] Monitoring
If you would like regular status reports, you will need a monitoring daemon.
[edit] Sensord
sensord is a daemon that logs the monitoring output from lm_sensors to syslog. To enable building lm_sensors with sensord, enable the sensord USE flag:
Then run:
To start sensord and add it to start at boot:
Unfortunately, this adds unwanted clutter to /var/log/messages. Assuming that you are using the gentoo's default logger syslog-ng, the following recipe will filter out the events into their own log file /var/log/sensord:
...
destination sensord { file("/var/log/sensord"); };
filter f_sensord { facility(daemon) and program("sensord"); };
log { source(src); filter(f_sensord); destination(sensord); };
...
It's recommended that each line be placed in the appropriate area in the file for consistency sake. It is evident what this means after reviewing the syslog-ng.conf file. Daemon is now the default facility that is used by sensord. This used to be local4. Additional information is in the man page for sensord.
If you have added rules to the syslog-ng.conf file and want to enable them and start logging to /var/log/sensord immediately, restart syslog-ng (this should automatically also restart sensord):
For more information on configuration of sensord, such as changing the logging interval time or reporting facility, refer to the manual pages on the sensord command.
[edit] Graphical Sensor Monitors
[edit] KDE
- SuperKaramba
- KSim
- KSensors
- Kima
- KSysGuard
[edit] Gnome
- hardware-monitor
- ComputerTemp
- GAI Temp
[edit] Other
[edit] Troubleshooting
[edit] "My sensors do not show up!" or "My sensors are not detected!"
- Check the bug reports. If this won't help, you can try experimenting with the modules and their parameters or send the lm_sensors' guys a bug report.
[edit] My sensors always show 10 degrees too much!
- You may need to edit /etc/sensors.conf as appropriate.
[edit] My sensor data needs to be divided by 2!
- Edit /etc/sensors.conf and find uncommented compute temp for cpu appropriate for your chip, then replace 2 with 1 after the letters @* in the same line.
[edit] sensors-detect spits out No i2c device files found. Use prog/mkdev/mkdev.sh to create them!
- Try running modprobe i2c-dev; sensors-detect, if that fails, try google.
[edit] sensors-detect is unable to find some modules! Why are these modules missing?
- Make sure you activated the according option when configuring the kernel and be sure to read point 1.!
[edit] The w83627hf module triggers high fan speed.
- Try to solve this by modprobe w83627hf init=0
[edit] sensord won't start. In /var/log/syslog it says 'GPIO5 disabled, no VID function'
- Add ignore vid to /etc/sensors.conf.
[edit] Sensor device detected by sensors-detect but not displayed with sensors
- You might need correct I2C adapter layer driver which provides access to I2C bus to which sensor device is connected (e.g. some manufacturers connect sensor device on the same I2C bus which used by graphic card driver). Please check kernel configuration.