[arm-allstar] Troubleshooting Fan Control Script

Danny K5CG k5cg at hamoperator.org
Tue Nov 7 20:43:41 EST 2023


Part 2, if you want to turn it on from the command line;

gpio write 14 1

and off would be;

gpio write 14 0



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