[arm-allstar] Shari Node Fan Control?

David McGough kb4fxc at inttek.net
Mon May 31 03:32:34 EDT 2021


Chris,

Here is a simple, example bash script that monitors the CPU/SoC temp and
would trigger the fan, with the addition of the gpio commands. Right now, 
it just echos "fan on" or "fan off" for testing.

###################################################################################
#!/bin/bash
#
#       Simple CPU temp monitor script.  KB4FXC 2021-05-30
#

hi=60
lo=50
fanstate=unknown

function fan_on
{
        echo "fan on"
}

function fan_off
{
        echo "fan off"
}

while true ; do

        temp=$(/opt/vc/bin/vcgencmd measure_temp | awk -F= '{j=$2 - 0; print j}')

        [ $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
###################################################################################


73, David KB4FXC


On Mon, 31 May 2021, Chris Smart wrote:

> Thanks David.
> 
> 
> Where can I learn to write that? Just look at other example scripts?
> 
> 
> Sorry, I warned you I was new. 😁
> 
> 
> 73
> 
> chris
> 
> 
> 
> On 2021-05-31 1:24 a.m., David McGough wrote:
> > Chris,
> >
> > Controlling the fan should be very easy to accomplish using the "gpio"
> > command included with HamVoIP.
> >
> > You can retrieve the current CPU/SoC temperature using this command:
> >
> > /opt/vc/bin/vcgencmd measure_temp
> >
> >
> > A little script to monitor the temperature and turn the fan
> > on/off, as needed, wouldn't be more than a few lines of code.
> >
> >
> > 73, David KB4FXC
> >
> >
> > On Mon, 31 May 2021, "Chris Smart via ARM-allstar" wrote:
> >
> >> I'm guessing others would find it useful as well.
> >>
> >>
> >>
> >>
> >> On 2021-05-31 1:11 a.m., "Steve Agee via ARM-allstar" wrote:
> >>> *It appears this is a feature of the "Raspberry Pi OS" but perhaps it
> >>> is a simple bash shell script that could be copied and placed in to
> >>> HAMVOIP. Perhaps someone can take a look and post an update.
> >>>
> >>> N5ZUA
> >>> *
> >>> On 5/30/2021 12:20 PM, "Chris Smart via ARM-allstar" wrote:
> >>>> With a Pi 4, case and fan, the instructions online for the fan talk
> >>>> about instructing the fan to only come on when a particular
> >>>> temperature is reached.
> >>>>
> >>>>
> >>>> Is that something easily done with whatever comes in the standard
> >>>> Hamvoip image? Here's a link to the instructions.
> >>>>
> >>>> https://www.buyapi.ca/product/case-fan-heatsink-for-raspberry-pi-4-case/
> >>>>
> >>>>
> >>>> Be gentle please. I'm new to Linux and doing everything from the CLI.
> >>>>
> >>>>
> >>>> Chris
> >>>>
> >>>>
> >>>> _______________________________________________
> >>>>
> >>>> 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
> >>> _______________________________________________
> >>>
> >>> 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
> >> _______________________________________________
> >>
> >> 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