# Controlling Various Computer Hardware (Fans, etc.)

## ColinAnderson

```
colin@magic-wand colin $ sensors

w83697hf-isa-0290

Adapter: ISA adapter

VCore:     +1.69 V  (min =  +0.65 V, max =  +0.52 V)       ALARM

+3.3V:     +3.30 V  (min =  +0.21 V, max =  +3.43 V)

+5V:       +4.95 V  (min =  +0.06 V, max =  +0.22 V)       ALARM

+12V:     +11.57 V  (min =  +6.16 V, max =  +0.69 V)       ALARM

-12V:      +0.66 V  (min = -13.73 V, max = -14.23 V)       ALARM

-5V:       +5.12 V  (min =  +2.40 V, max =  -4.48 V)       ALARM

V5SB:      +5.55 V  (min =  +5.25 V, max =  +5.20 V)       ALARM

VBat:      +3.24 V  (min =  +0.16 V, max =  +0.20 V)       ALARM

fan1:        0 RPM  (min = 6887 RPM, div = 2)              ALARM

fan2:     3183 RPM  (min = 23275 RPM, div = 2)              ALARM

temp1:       +30 C  (high =   +64 C, hyst =  -108 C)   sensor = thermistor

temp2:     +40.5 C  (high =   +75 C, hyst =   +70 C)   sensor = thermistor

alarms:

beep_enable:

          Sound alarm disabled

eeprom-i2c-0-50

Adapter: SMBus Via Pro adapter at 5000

Memory type:            DDR SDRAM DIMM

Memory size (MB):       512
```

How do I go about controlling certain things, specifically the fans?  Any help would be appreciated.  Just so you know, I'm planning on writing a simple script to control the chassis fans (fan1) depending upon the system temperature.  Mainly to reduce noise levels.  Turn them off when the temperature is within a certain range, and on when it's warmer.   :Smile: 

----------

## curtis119

app-misc/ksensors   	 KSensors - a nice lm_sensors frontend for KDE

 sys-apps/lm-sensors   	 Hardware Sensors Monitoring by lm_sensors

 x11-misc/xsensors   	 A hardware health information viewer, interface to lm-sensors

 x11-plugins/gkrellm-sensors   	 A GKrellm plugin for monitoring lm_sensors

 x11-plugins/wmalms   	 wmalms X-windows hardware sensors applet

 x11-plugins/wmmsens   	 Window Maker dock app for monitoring your motherboard's hardware sensors

x11-plugins/wmsensormon 	WindowMaker DockApp: Monitors sensors using lm_sensors

here is the HOW-TO from tldp.org

http://www.tldp.org/HOWTO/K7s5a-HOWTO-3.html

here are afew related forum threads:

https://forums.gentoo.org/viewtopic.php?t=161972&highlight=lmsensors

https://forums.gentoo.org/viewtopic.php?t=54450&highlight=lmsensors

https://forums.gentoo.org/viewtopic.php?t=180499&highlight=lmsensors

https://forums.gentoo.org/viewtopic.php?t=101573&highlight=lmsensors

https://forums.gentoo.org/viewtopic.php?t=52815&highlight=lmsensors

https://forums.gentoo.org/viewtopic.php?t=178465&highlight=lmsensors

https://forums.gentoo.org/viewtopic.php?t=174924&highlight=lmsensors

And here is a good guide for installing/configuring i2c and lm_sensors written by one of the developers of lm_sensors:

http://khali.linux-fr.org/devel/i2c/

----------

## ColinAnderson

Well, I have lm-sensors-2.6.5 and everything installed, and from what you can see it's working.  I just wanted to know how I might go about controlling certain things, mainly the fans (turning them on and off).  Is this possible?  And if it his, how?  I'm looking through those documents, and maybe I'm missing everything, but I don't see much regarding controlling the devices.

GKrellM is pretty much out of the question as I'm not using a graphical environment in this setup -- it's a file server I administer via SSH from my laptop.   :Smile:   Thanks for your help so far!

----------

## curtis119

lmsensors can control your fans. It does it automatically. Setting it up correctly is something I've never attempted. Read these threads:

https://forums.gentoo.org/viewtopic.php?t=101573&highlight=lmsensors

https://forums.gentoo.org/viewtopic.php?t=54450&highlight=lmsensors

https://forums.gentoo.org/viewtopic.php?t=52815&highlight=lmsensors

lmsensors doc page:

http://secure.netroedge.com/~lm78/docs.html

there is a script in the lmsensors package called fancontrol that can control the fan. Here is an article showing how to do it directly through the /proc interface instead. You can write any script you want instead of using the builtin fancontrol script:

http://www.lula.org/pipermail/lula/2004-January/002289.html

----------

## ColinAnderson

I really do appreciate your help, but I'm still not getting anywhere.  I'm having trouble understanding where in these threads and documentations it explains how to control fan speed, or turn the fans on or off.

The /proc interface article was nice, but I guess I do not have PWM available as it does not exist in anywhere within /proc.  If you could give me an example of how to turn the fans on or off or something of that nature that I can see, it would greatly help me.

----------

## Gestalt73

Hello!

What's really great about this is that I just finished configuring this about 5 minutes ago.

If you're using a 2.4 kernel, I think everything just works.  try running pwmconfig, then fancontrol.  I assume that you have successfully installed lm-sensors, and are able to run 'sensors' and get data

if you're using a 2.6 kernel, it takes a little bit more work.

The good news:  the command pwmconfig will write a settings file for you called /etc/fancontrol that fancontrol will use to  adjust your fans for you based on temp readings.

The not so great news:  it looks like the fan and temp device names have changed in 2.6 so you will need to update the pwmconfig script to look for the new names.

you can open up /usr/sbin/pwmconfig in your favorite editor and change the following:

LINE 66:  */pwm[1-9]  to */fan[1-9]_pwm

LINE 67:  */pwm[1-9] to */fan[1-9]_pwm

LINE 75:  */fan_input[1-9] to */fan[1-9]_input

LINE 361 */temp_input[1-9] to */temp[1-9]_input

If you want the whole pwmconfig file let me know.

After that, I was able to run the pwmconfig script which wrote out a settings file for fancontrol.

Alan

----------

## curtis119

Thank you so much Gestalt73! I was trying to point him in the right direction. I have never really attempted to do what he was asking. Thanks.

----------

## Gestalt73

 -- VERY IMPORTANT -- 

Make sure that your fancontrol settings are appropriate for your system.  That means setting up fancontrol and testing its behaviour under load.  open up gkrellm or ksensors or sensors and watch temp and fan speed changes during games, compiles etc.  It would be a pity if you accidentally fried your cpu because your max_temp was set too high and your cpu fan wasn't permitted to run at full speed.  

In case you or anyone else is interested I pieced together an inet.d script to automatically start and stop fancontrol:

```
nano -w /etc/init.d/fancontrol
```

```
#!/sbin/runscript

# Copyright 1999-2004 Gentoo Technologies, Inc.

# Distributed under the terms of the GNU General Public License v2

# Modified fancontrol script

opts="${opts} reload"

depend() {

        need lm_sensors

}

start() {

        ebegin "Starting fancontrol"

        start-stop-daemon --start --quiet --background --exec /usr/sbin/fancontrol

        result=$?

        eend $result

}

stop() {

        ebegin "Stopping fancontrol"

        start-stop-daemon --stop --signal 1 --quiet --pidfile /var/run/fancontrol.pid

        result=$?

        eend $result

}

reload() {

        ebegin "Reloading fancontrol"

        killall -HUP fancontrol &>/dev/null

        result=$?

        eend $result

}

```

And finally:

```
rc-update add fancontrol default

/etc/init.d/fancontrol start
```

So far this works for me.

Alan

----------

## Tuti

Thanks for the init script, Gestalt! I've been trying to come up with my own script, but I coundn't get it to terminate properly  ... but i'm a n00b.

One thing that's cool about fancontrol is that it actually doesn't need lm_sensors at all if you use a 2.6 kernel - most hw sensors can be compiled in the kernel. If you want to use the pwmconfig script to write the config file, you might have to edit the code and rename some of the references to /sys/busses/i2c/...

----------

## ColinAnderson

Thanks so much!  Both of you.   :Smile: 

Everytime I attempted to run the pwmconfig script, it exited telling me there were no pwm modules found, so I figured my motherboard didn't support it.  However, my motherboard is brand new (ASUS) as I just built this computer last week.   :Smile:   So I figure it ought to have pwm.  The sensors driver (winbond w83627hf or something) supports pwm, so I figure the motherboard should as well.

I'll see if that will sort some things out when I get home (at work at the moment).

----------

## ColinAnderson

I changed the configuration file, and it apparently detected PWM properly.  However, it would not let me write a configuration file becuase I wasn't root ... but I WAS ROOT.  So, haven't figured that out.  I changed the section where it detects root so that it always thinks I'm root ... but it never successfully changes the fans anyway, so it doesn't matter.  It only reports that there is no correclation.   :Sad:   It makes me sad.

```
root@magic-wand colin # pwmconfig

This program will search your sensors for pulse width modulation (pwm)

controls, and test each one to see if it controls a fan on

your motherboard. Note that many motherboards do not have pwm

circuitry installed, even if your sensor chip supports pwm.

We will attempt to briefly stop each fan using the pwm controls.

The program will attempt to restore each fan to full speed

after testing. However, it is ** very important ** that you

physically verify that the fans have been to full speed

after the program has completed.

Found the following PWM controls:

   1-0290/fan1_pwm

   1-0290/fan2_pwm

Found the following fan sensors:

   1-0290/fan1_input     current speed: 2755 RPM

   1-0290/fan2_input     current speed: 3229 RPM

Warning!!! This program will stop your fans, one at a time,

for approximately 5 seconds each!!!

This may cause your processor temperature to rise!!!

If you do not want to do this hit control-C now!!!

Hit return to continue:

Testing pwm control 1-0290/fan1_pwm ...

  1-0290/fan1_input ... speed was 2755 now 2777

    no correlation

  1-0290/fan2_input ... speed was 3229 now 3229

    no correlation

No correlations were detected.

There is either no fan connected to the output of 1-0290/fan1_pwm,

or the connected fan has no rpm-signal connected to one of

the tested fan sensors. (Note: not all motherboards have

the pwm outputs connected to the fan connectors,

check out the hardware database on http://www.almico.com/forumindex.php)

Did you see/hear a fan stopping during the above test (n)? n

Testing pwm control 1-0290/fan2_pwm ...

  1-0290/fan1_input ... speed was 2755 now 2789

    no correlation

  1-0290/fan2_input ... speed was 3229 now 3229

    no correlation

No correlations were detected.

There is either no fan connected to the output of 1-0290/fan2_pwm,

or the connected fan has no rpm-signal connected to one of

the tested fan sensors. (Note: not all motherboards have

the pwm outputs connected to the fan connectors,

check out the hardware database on http://www.almico.com/forumindex.php)

Did you see/hear a fan stopping during the above test (n)? n

Testing is complete.

Please verify that all fans have returned to their normal speed.

The fancontrol script can automatically respond to temperature changes

of your system by changing fanspeeds.

Do you want to set up its configuration file now (y)? n

root@magic-wand colin #
```

Any ideas?  Or am I just out of luck?

----------

## tnt

 *ColinAnderson wrote:*   

> I changed the configuration file, and it apparently detected PWM properly. 

 

In wich way did you change your configuration?

I have the same problem:

```
[root@beta 1-0290]# pwmconfig

This program will search your sensors for pulse width modulation (pwm)

controls, and test each one to see if it controls a fan on

your motherboard. Note that many motherboards do not have pwm

circuitry installed, even if your sensor chip supports pwm.

We will attempt to briefly stop each fan using the pwm controls.

The program will attempt to restore each fan to full speed

after testing. However, it is ** very important ** that you

physically verify that the fans have been to full speed

after the program has completed.

/usr/sbin/pwmconfig: There are no pwm-capable sensor modules installed
```

 :Rolling Eyes: 

----------

## KozmoNaut

Ahh, sheer blissful silence. My system hasn't been able to run the fans at anything but max speed as soon as I booted up Gentoo, but fancontrol handles it now.

With no load on the system, the CPU is 35-40C and the fan runs at 1500rpm. On full load (2x burnp6 running) the CPU is 55C and the fan runs at 2200rpm (which is appearantly the max speed for a P4 fan).

I love it. And the init script rocks, too!

----------

