Openwrt argon one V2 金属外壳风扇控制

在 /boot/config.txt 启用 I2C(ARM I2C)

先看看现在有没有 i2c 相关行:

1
grep -nE 'i2c|dtparam=i2c' /boot/config.txt || true

然后追加(或确保存在)这一行:

1
2
3
echo 'dtparam=i2c_arm=on' >> /boot/config.txt
sync
reboot

如果你发现里面已经有 dtparam=i2c_arm=off 或重复行,建议你用 vi /boot/config.txt 手动改成 on,避免冲突。

OpenWrt 安装 I2C 组件并确认 /dev/i2c-1

重启回来后:

1
2
opkg update
opkg install i2c-tools kmod-i2c-dev kmod-i2c-bcm2835

检查:

1
2
ls -l /dev/i2c-*
i2cdetect -l

正常情况你会看到类似 i2c-1。

探测 Argon ONE V 的 I2C 地址(常见是 0x1a)

1
i2cdetect -y 1

如果网格里出现 1a,就说明壳子的控制 MCU 在 bus=1、addr=0x1a 上,基本可以直接控风扇了。

手动控风扇验证(立刻见效)

多数 Argon ONE / V2 / V 系列是写一个 0–100 的百分比值(十六进制)来控制。

1
2
3
4
5
6
7
8
# 100%
i2cset -y 1 0x1a 0x64

# 关闭
i2cset -y 1 0x1a 0x00

# 50%
i2cset -y 1 0x1a 0x32

如果这里风扇转起来了,说明链路 OK。

做成自动温控(OpenWrt procd 自启动)

写 daemon

/usr/sbin/argon-fan-daemon.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
cat >/usr/sbin/argon-fan-daemon.sh <<'EOF'
#!/bin/sh
BUS=1
ADDR=0x1a
THERM=/sys/class/thermal/thermal_zone0/temp
INTERVAL=5

pct_to_hex() {
P="$1"
[ "$P" -lt 0 ] && P=0
[ "$P" -gt 100 ] && P=100
printf "0x%02X" "$P"
}

set_fan_pct() {
HEX="$(pct_to_hex "$1")"
i2cset -y "$BUS" "$ADDR" "$HEX" 2>/dev/null
}

last=-1
while true; do
t_milli="$(cat "$THERM" 2>/dev/null)"
[ -z "$t_milli" ] && sleep "$INTERVAL" && continue
t_c=$((t_milli / 1000))

if [ "$t_c" -ge 70 ]; then pct=100
elif [ "$t_c" -ge 65 ]; then pct=75
elif [ "$t_c" -ge 60 ]; then pct=50
elif [ "$t_c" -ge 55 ]; then pct=25
elif [ "$t_c" -ge 50 ]; then pct=10
else pct=0
fi

if [ "$pct" -ne "$last" ]; then
set_fan_pct "$pct"
last="$pct"
fi

sleep "$INTERVAL"
done
EOF

chmod +x /usr/sbin/argon-fan-daemon.sh

写 init.d

/etc/init.d/argon-fan

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
cat >/etc/init.d/argon-fan <<'EOF'
#!/bin/sh /etc/rc.common
START=95
USE_PROCD=1

start_service() {
procd_open_instance
procd_set_param command /usr/sbin/argon-fan-daemon.sh
procd_set_param respawn
procd_close_instance
}
EOF

chmod +x /etc/init.d/argon-fan
/etc/init.d/argon-fan enable
/etc/init.d/argon-fan start

查看是否在跑:

1
ps | grep argon-fan | grep -v grep