Having a proper FAN connection on board was one of the reasons to buy an Organe Pi 3B.
Unfortunatetely that does not function when using other distrubution than the one the manufacturer supplies. And those are outdated.
I tried to figure out to create a working PWM FAN control by modifying the many existing dtb’s or adding dtbo’s as overlay but figuring out which opi3b dtb could be used became to complicated.
To be honest: all opi3b dtb’s I could find were very different and I could never find a logic link to the PWM fan definition on the board I have, so I gave up.
But creating a simple on/off control based on the temperature was fairly easy.
I created this script to switch the FAN on or off depending on the temperature. I did not use any fancy tricks for error detection, availability of resources etc, but hardcoded most items. But it works very well!
nano /usr/bin/fancontrol.sh
// paste the following code:
#!/bin/bash
#OP3B shell script to switch FAN on or of with temperature
INTERVAL=3
#Init GPIO's FAN (pin 22) if not set
if [ ! -e /sys/class/gpio/gpio22 ]; then
echo 22 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio22/direction
fi
#Poll temperature every INTERVAL seconds
while true; do
temp=$(cat /sys/devices/virtual/thermal/thermal_zone0/temp)
#Enable/disable the FAN depending on the cpu temperature: on when above 50 degrees celcius and off when cooled down below 45
if [ $temp -gt 50000 ];then
echo 1 > /sys/class/gpio/gpio22/value
elif [ $temp -lt 45000 ];then
echo 0 > /sys/class/gpio/gpio22/value
else
:
fi
sleep ${INTERVAL}
done
//save it with ctrl-x
Place the above script somewhere on your system: I used /usr/bin
Then make this script a system service:
chmod +x /usr/local/bin/fancontrol.sh
nano /etc/systemd/system/fancontrol.service
//past the following code
[Unit]
Description=Fancontrol Script
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/fancontrol.sh
[Install]
WantedBy=multi-user.target
// save it with ctrl-x
Then:
systemctl daemon-reload
and:
systemctl enable fancontrol.service
systemctl start fancontrol.service
systemctl status fancontrol.service
Thats it!
You can check if it works as intended using some benchmark program.