7. Hardware Sensors

7.1. Kernel 2.4

Many distros include the i2c and lm_sensors packages, but as of this writing (Sep 2003) these distros don't support the vt1211. So you must compile and install it yourself. Problems have been reported using i2c and lm_sensors with kernel version 2.4.22. These instructions do not apply to kernel 2.4.22.

Before building anything you must remove any pre-existing lm_sensors libraries and utilities. On Red Hat systems you can remove these binaries using this command:

bash# rpm -e --nodeps lm_sensors

Next we need to create a symlink in /usr/src. The i2c and lm_sensors packages expect to find the source at /usr/src/linux, so if it doesn't already exist then create the link:

bash# cd /usr/src
bash# ln -s linux-2.4.18-14 linux

If you haven't done so already, fix the shared library list.

i2c and lm_sensors require that the linux source be configured. If you built your kernel from source then it will already be done. If you installed your source from a package, such as the red hat kernel-source package, then the source has not be configured and you must configure and the source and make the dependency files. But you don't need to compile the source. Here is what you have to do:

bash# cd /usr/src/linux
bash# cp /boot/config-2.4.18-14 .config
bash# make menuconfig
(exit, save configuration)
bash# make dep

Now download the i2c-2.7.0 and lm_sensors-2.7.0 tarballs. The following commands will extract, make, and install the i2c package.

bash# tar -xzvf i2c-2.7.0.tar.gz
bash# cd i2c-2.7.0
bash# make all
bash# make install
bash# cd kernel
bash# rm -f /lib/modules/2.4.18-14/kernel/drivers/i2c/*
bash# cp *.o /lib/modules/2.4.18-14/kernel/drivers/i2c/

Those last two commands replace the redhat i2c kernel modules with your new modules. Do the same thing for lm_sensors:

bash# tar -xzvf lm_sensors-2.7.0.tar.gz
bash# cd lm_sensors-2.7.0
bash# make all
bash# make install
bash# cd kernel/busses
bash# cp *.o /lib/modules/2.4.18-14/kernel/drivers/i2c/
bash# cd ../chips
bash# rm -f /lib/modules/2.4.18-14/kernel/drivers/sensors/*
bash# cp *.o /lib/modules/2.4.18-14/kernel/drivers/sensors/

Before we go any farther, add the following line to your /etc/modules.conf file:

alias char-major-89 i2c-dev

Now you have built the modules and tools and installed them in the filesystem. But you have to insert the modules in order to use them. The big question: which modules do you use? As far as I can tell, all the VIA mini-itx boards use the i2c-core, i2c-isa and i2c-proc modules:

bash# depmod -a
bash# modprobe i2c-core
bash# modprobe i2c-isa
bash# modprobe i2c-proc

These modules enable communication on the i2c bus. Now you have to insert the module for the sensor chip. There are two modules: vt8231 and vt1211. All VIA mini-itx boards use the vt1211 sensor. The difference is that EPIA boards have the 1211 chip built into the 8231, while the M series boards have a separate 1211 chip. Look at your board: if you see a 1211 chip, then use the vt1211 module. If you don't them use the vt8231 module:

bash# modprobe vt1211
-- or --
bash# modprobe vt8231 

You can read the sensors directly from the /proc/sys/dev/sensors/vt1211-isa-6000 directory:

# cat /proc/sys/dev/sensors/vt1211-isa-6000/temp1
255.0 0.0 98.0

You can obtain a more user-friendly readout using the sensors command:

bash# sensors
vt1211-isa-6000
Adapter: ISA adapter
Algorithm: ISA algorithm
VCore1: +1.98 V (min = +0.00 V, max = +0.00 V) ALARM
+5V: +4.78 V (min = +4.73 V, max = +5.24 V) 
+12V: +12.08 V (min = +10.77 V, max = +13.15 V) 
+3.3V: +3.35 V (min = +3.13 V, max = +3.45 V) 
fan1: 0 RPM (min = 3006 RPM, div = 2) ALARM
fan2: 0 RPM (min = 3006 RPM, div = 2) 
MB1 Temp: +190.0C (limit = +60C, hysteresis = +55C) ALARM
Proc Temp: +46.5C (limit = +65C, hysteresis = +60C) 
MB2 Temp: +0.0C (limit = +0C, hysteresis = +0C) ALARM
vid: +0.00 V

You might notice that MB1 temp is freakishly high. This is common. The proc temperature seems reliable. MB2 temp is not implemented. You need to edit the vt1211 section of /etc/sensors.conf like this:

 # Sensors configuration file used by 'libsensors'
chip "vt1211-*" "vt8231-*"
# set uch1-2 to temp mode, uch3-5 to voltage mode
#
set config 12
ignore in0
ignore in1
ignore temp2
ignore temp4
ignore temp5
ignore temp6
ignore temp7


label in2 "VCore1"
label in3 "+5V"
label in4 "+12V"
label in5 "+3.3V"

label temp3 "CPU Temp"
#
# All voltage calculations have the form
# ((@ * 100) - 3) / (K * 95.8), (@ * K * 0.958) + .03
# where K = R2 / (R1 + R2).
# Use the following K values based on input voltage.
# This of course assumes the mobo has the resistors
# recommended by Via in the datasheet.
# Voltage K
# VCore 1.0
# 2.5 0.8333
# 3.3 (in5 internal) 0.6296
# 3.5 (3.3V ext.) 0.5952
# 5.0 0.4167
# 12.0 0.1754
#
compute in2 ((@ * 100) - 3) / (0.5952 * 95.8), (@ * 0.5952 * 0.958) + .03
compute in3 ((@ * 100) - 3) / (0.4167 * 95.8), (@ * 0.4167 * 0.958) + .03
compute in4 ((@ * 100) - 3) / (0.1754 * 95.8), (@ * 0.1754 * 0.958) + .03
compute in5 ((@ * 100) - 3) / (0.6296 * 95.8), (@ * 0.6296 * 0.958) + .03

set vrm 9.1
set in2_min vid * 0.97
set in2_max vid * 1.03
set in3_min 5.0 * 0.95
set in3_max 5.0 * 1.05
set in4_min 12.0 * 0.90
set in4_max 12.0 * 1.10
set in5_min 3.3 * 0.95
set in5_max 3.3 * 1.05
compute temp3 (@*@*0.0046)-(@*0.088)-0.748, (@*0.9686)+65

set temp3_hyst 60
set temp3_over 65

set fan1_min 3000
set fan2_min 3000

You can put the modprobe commands in your /etc/rc.d/rc.local file to ensure that the sensors drivers are loaded when you start your machine. Or on some distros you can edit the sysconfig files. Create a /etc/sysconfig/lm_sensors file containing the following:

MODULE_0=i2c-core
MODULE_1=i2c-proc
MODULE_3=i2c-isa
MODULE_4=vt1211

Or substitute vt8231 if you have an EPIA board. Now copy the lm_sensors-2.7.0/prog/init/lm_sensors.init file to /etc/rc.d/init.d/lm_sensors

7.2. Linux 2.6

As of December 2004, the vt1211 sensor chip has not been ported to the linux 2.6 kernel. However Lars Ekman has ported the driver. You can download the code and a new sensors.conf file from his vt1211 module for 2.6 kernel page. The page includes installation instructions.

7.3. Notes

When you build i2c and lm_sensors the compiler will look at /lib/modules/running_kernel_version/build to find the source tree for the target kernel. So you need to do two things: first, build i2c and lm_sensors while running the target kernel. Second, make sure the build symlink points to the correct directory for your source tree.

7.4. Hard Drive Temperature Sensor

This isn't really an EPIA issue - it's about hard drives. But many EPIA boards are used in silent PCs. Because these silent PCs have no fans, it can get pretty hot inside the case and the hard drive can get very hot. The manufacturer's datasheet specifies the maximum operating temperature of the hard drive. You should never exceed that temperature - in fact, you should keep well under the maximum temperature. But how do you know how hot your hard drive is? You need a hard drive temperature sensor.

Many recent hard drives include built-in temperature sensors which can be read using the S.M.A.R.T. data facility. The hddtemp utility can read the SMART temperature information for supported hard drives. To install the hddtemp utility, download both the hddtemp utility and the database file.. Then install as follows:

bash$ tar -xjf hddtemp-0.3-beta8.tar.bz2 
bash$ cd hddtemp-0.3-beta8
bash$ ./configure
bash$ make
bash$ su
Password:
bash# make install
bash# mv hddtemp.db /usr/share/misc
bash# /usr/local/sbin/hddtemp /dev/hdc
/dev/hdc: ST340014A: 52°C

hddtemp install to /usr/local/sbin, which might not be in the path, so you may need to specify the full filename to run the utility, as shown above. You could also read the S.M.A.R.T. temperature information using the smartmontools utility from sourceforge. Here is a useful script - run it and every 60 seconds it will print out a time index, the CPU temperature, and the HD temperature. Pipe it to a file and you can import it to a spreadsheet in comma delimited format.

#!/bin/bash
t=0
echo Time , CPU Temp , HD Temp
while [ "true" = "true" ] ; do
  cputemp=`sensors | grep Proc | sed 's/.*: +\(.\{2,10\}\)C.*/\1/'`
  hdtemp=`/usr/local/sbin/hddtemp /dev/hdc | sed 's/.*: \(.\{2,10\}\)°.*/\1/'`
  echo $t","$cputemp","$hdtemp
  sleep 60
  t=`expr $t + 1`
done

7.5. I2C Connector

This information was posted to VIA Arena Linux Forum by Helmut Wollmersdorfer.

The VIA EPIA ME6000 has a I2C Connector on the motherboard. This is what the User Manual says about the connector:

Table 6. EPIA M I2C Connector Pin-out

PinSignal
1+3.3 V
2+3.3 V
3EL-ON
4SMBCK
5SMBDT
6GND

Maybe pin 3 is for controlling electro luminescent displays, which are back light foils for LCD. So maybe there is an undocumented feature of EPIA boards, which is able to control LCD displays _and_ the backlight over I2C.

My trial was to connect a Dallas/Maxim DS1621 temperature sensor. The pins of the DS1621 are as follows:

Table 7. DS1621 Pins

PinSignalDescription
1SDA2-Wire serial data input/output
2SCL2 wire serial clock
3ToutThermostat Output Signal
4GNDGround
5A2Chip Address Input
6A1Chip Address Input
7A0Chip Address Input
8VddPower Supply Voltage

Now connect the DS1621 to the I2C connector according to the chart below. Note that the address pins A0-A2 give zero-bits if connected to GND, and one-bits if connected to Vdd. This feature is for specifying an address of the sensor if more than one is connected to the bus.

Table 8. EPIA I2C/DS1621 Cross connect

I2C ConnectorDS1621
PinLabelPinLabel
1+3.3 V8Vdd
4SMBCK2SCL
5SMBDT1SDA
6GND4GND
5A2
6A1
7A0

Next install lm-sensors, on my Debian Sarge 2.6.8-1-386 I did it with

bash# apt-get install lm-sensors
bash# sensors -v
sensors version 2.8.7 with libsensors version 2.8.7

Now the relevant modules need to inserted (via insmod or modprob), here is the relevant part of

bash# lsmod
Module         Size     Used by
ds1621         8452     0
i2c_isa        2304     0
vt1211         15876    0
i2c_sensor     2944     2 ds1621,vt1211
i2c_viapro     6924     0
i2c_dev        9984     0
i2c_core       22416    6 ds1621,i2c_isa,vt1211,i2c_sensor,i2c_viapro,i2c_dev

Sensors-detect did not detect the DS1621, but it works now:

bash# sensors
ds1621-i2c-0-48
Adapter: SMBus Via Pro adapter at 0500
temp: +26.00°C (low = +15.0°C, high = +10.0°C) ALARM (LOW,HIGH)