Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetson Nano A02 fix - Сooler was not spin when overheated #16

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions automagic-fan.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ Description=Automagic fan control

[Service]
Type=simple
ExecStartPre=/bin/sleep 5
Restart=always
RestartSec=5
ExecStart=/usr/bin/python3 -u /usr/local/bin/automagic-fan/fanctl.py
ExecStopPost=/bin/sh -c '/bin/echo 0 > /sys/devices/pwm-fan/target_pwm'
User=root
StandardOutput=journal+console
Restart=always

[Install]
WantedBy=multi-user.target
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"FAN_OFF_TEMP":20,
"FAN_MAX_TEMP":50,
"UPDATE_INTERVAL":2,
"MAX_PERF":1
"MAX_PERF":1,
"INVERSED_PIN":false
}
7 changes: 6 additions & 1 deletion fanctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
FAN_MAX_TEMP=config["FAN_MAX_TEMP"]
UPDATE_INTERVAL=config["UPDATE_INTERVAL"]
MAX_PERF=config["MAX_PERF"]
INVERSED_PIN=config["INVERSED_PIN"]
except:
print("error loading /etc/automagic-fan/config.json.\nPlease check your config file.\nProceeding with default settings.")
FAN_OFF_TEMP=20
FAN_MAX_TEMP=50
UPDATE_INTERVAL=2
MAX_PERF=0
INVERSED_PIN=true

if MAX_PERF>0:
print("Maximizing clock speeds with jetson_clocks")
Expand All @@ -34,7 +36,10 @@ def read_temp():

def fan_curve(temp):
spd=255*(temp-FAN_OFF_TEMP)/(FAN_MAX_TEMP-FAN_OFF_TEMP)
return int(min(max(0,spd),255))
spd=int(min(max(0,spd),255))
# DEBUG
# print(255-spd if INVERSED_PIN else spd)
return 255-spd if INVERSED_PIN else spd

def set_speed(spd):
with open("/sys/devices/pwm-fan/target_pwm","w") as file:
Expand Down