PWM Fan Control on the Jetson

Image not Found

I have used the Jetson AGX Xavier Devkit for a few weeks and noticed that when the clock on the jetson is at MAX 0, the PWM fan will run at its maximum speed, and it might produce some annoying noise. To decrease the RPM (Rotations per minutes) of the PWM fan embedded on the Jetson Xavier in the meanwhile keeping its clock at MAX 0, we need to manually overwrite the parameters in the pwm fan config file. For convenience, to control the pwm fan with the instant change of the CPU temperature on the Jetson AGX Xavier DevKit, I wrote an auto-control script for it.

You may find more info in the Repo .

This fan control script has three modes 0 , 1 , 2 and its set to different value of pwm. The default pwm values associated with mode 0 , 1 , 2 are 80, 150 , 255 accordingly. You may modify the pwm value associated with the mode in the script on your own need.

Check out the demo below:

The script is written in python as shown below:

 1#!/usr/bin/python
 2import time
 3
 4while True:
 5    fo = open("/sys/class/thermal/thermal_zone0/temp","r")
 6    thermal = int(fo.read(10))
 7    mode=0
 8    pwm=50 #default
 9    fo.close()
10
11#    print thermal
12
13    thermal = thermal / 1000
14    if (thermal < 40):
15        mode = 0
16        pwm = 80
17    elif (thermal >= 40 and thermal < 60):
18        mode = 1
19        pwm = 150
20    else:
21        mode = 2
22        pwm = 255
23
24    pwm = str(pwm)
25    print ("current temp: " + str(thermal))
26    print ("current fan mode: " + str(mode))
27    print ("current pwm: " + str(pwm))
28
29    fw=open("/sys/devices/pwm-fan/target_pwm","w")
30    fw.write(pwm)
31    fw.close()
32
33    time.sleep(10) #print the result for every 10s

How To Use

Download the repository from my github repo
1$ git clone https://github.com/miooochi/fan-control/
Modify Parameters

open the .sh or .py file and modify the pwm value based on your own need, save & exit

1$ cd fan-control
2$ gedit fan.sh
Run it automatically when the device is booted at startup
1$ sudo chmod +x fan.sh
2$ sudo scp fan.sh /etc/init.d
3$ sudo crontab -e
4# add @reboot /etc/init.d/fan.sh at the very top lane
5$ sudo reboot

Test it out, and enjoy !


You May Also Like