[arm-allstar] Troubleshooting Fan Control Script
Danny K5CG
k5cg at hamoperator.org
Tue Nov 7 20:40:50 EST 2023
Hi Chris,
Just from a cursory look at your script it looks OK, but you mentioned pin 4 and 6, pin 4 is +5 and pin 6 is ground and if your fan is connected there then it will surely run continuously. I don't think you need anything connected there.
Pin 8 which is GPIO 14 should be the FAN output so connect it to pin 6- an 8+.
Now, have a look in /boot/config.txt, look for dtoverlay=w1-gpio,gpiopin=# <- # is where your temp sensor needs to connect.
Mine is
dtoverlay=w1-gpio,gpiopin=3
and gpiopin=3 is on header pin 5. Adjust yours as needed.
Report back.
73
Danny, K5CG
HH 550-000-0609
SKCC 14257
----- Original Message -----
From: "ARM Allstar" <arm-allstar at hamvoip.org>
To: "ARM Allstar" <arm-allstar at hamvoip.org>
Cc: ve3rwj at winsystem.org
Sent: Tuesday, November 7, 2023 11:45:43 AM
Subject: [arm-allstar] Troubleshooting Fan Control Script
Hi.
I'm trying to troubleshoot a fan control script running on a Pi 4. The fan
runs continuously no matter what I do.
The fan has two connectors, a larger one plugged into pins 4 and 6, (power
and ground). The second connector, which checks temperature, is connected to
pin 8 (GPIO 14?)
The Pi is no longer on my desk here, but I added a line to the script to
print the temperature each time it loops. Presumably, if I get things right,
I should be able to turn the fan off and watch the temperature go up. turn
it back on and watch the temperature lower again. Currently, the fan is
running all the time and temp is about 46C.
What should I change in my script or try at the command prompt next?
Script follows:
#! /bin/bash
#
# CPU temp monitor/fan control script. VE3RWJ 2023-11-04
#
hi=60
lo=50
fanstate=unknown
FAN_BIT=14
function fan_on
{
gpio write $FAN_BIT 1
}
function fan_off
{
gpio write $FAN_BIT 0
}
while true ; do
temp=$(/opt/vc/bin/vcgencmd measure_temp | awk -F= '{j=$2 - 0; print j}' |
cut -b -2)
echo $temp
[ $temp -ge $hi ] && fanneeded=on
[ $temp -le $lo ] && fanneeded=off
if [ "$fanstate" != "$fanneeded" ] ; then
[ "$fanneeded" = "on" ] && fan_on
[ "$fanneeded" = "off" ] && fan_off
fanstate=$fanneeded
fi
sleep 5
done
_______________________________________________
ARM-allstar mailing list
ARM-allstar at hamvoip.org
http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar
Visit the BBB and RPi2/3/4 web page - http://hamvoip.org
More information about the ARM-allstar
mailing list