Fan Shim never seems to switch off at its "off" threshold/

Hi,

I’ve fitted a FanShim to my Pi4 (Python 3.9.2) and it spins very nicely. However, it seems to be ignoring the “go off now” temperature threshold.

Per the instructions at: Getting Started with Fan SHIM I’ve installed the Python library, and configured the automatic “come on at / go off at” service - which is active.

No errors were reported during install or in operation, but despite setting the “off at” temperature to 40deg and the Pi4 temperature reported as 33.1deg - the fan is still/permanently on.

I’ve tried a reboot. The fan service launched successfully after the Pi came back up, but again - fan is permanently on.

Does anyone have any ideas?

Thanks

fanshim-python/examples $ sudo ./install-service.sh --on-threshold 50 --off-threshold 40 --delay 5
Setting up with:
Off Threshold:    40 C
On Threshold:     50 C
Low Temp:         40 C
High Temp:        50 C
Delay:            5 seconds
Preempt:          no
Disable LED:      no
Disable Button:   no
Brightness:       255
Extended Colours: no

To change these options, run:
sudo ./install-service.sh --off-threshold <n> --on-threshold <n> --delay <n> --brightness <n> --low-temp <n> --high-temp <n> --venv <python_virtual_environment> (--preempt) (--noled) (--nobutton) (--extended-colours)
Or edit: /etc/systemd/system/pimoroni-fanshim.service


Checking for rpi.gpio >= 0.7.0 (for Pi 4 support)
rpi.gpio >= 0.7.0 already installed
Checking for Fan SHIM
Fan SHIM already installed
Checking for psutil >= 5.6.7
psutil >= 5.6.7 already installed

Installing service to: /etc/systemd/system/pimoroni-fanshim.service
● pimoroni-fanshim.service - Fan Shim Service
     Loaded: loaded (/etc/systemd/system/pimoroni-fanshim.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2023-03-06 16:01:58 GMT; 19ms ago
   Main PID: 2005 (python3)
      Tasks: 1 (limit: 1830)
        CPU: 13ms
     CGroup: /system.slice/pimoroni-fanshim.service
             └─2005 /usr/bin/python3 /home/steveharman/fanshim-python/examples/automatic.py --on-…

Mar 06 16:01:58 raspberrypi systemd[1]: Started Fan Shim Service.
steveharman@raspberrypi:~/fanshim-python/examples $ /usr/bin/vcgencmd measure_temp
temp=33.1'C

One likely scenario is that GPIO 18 isn’t making a good connection.
Fan SHIM at Raspberry Pi GPIO Pinout
That pin has to be pulled low for the fan to turn off.

Aha! Thanks. I shutdown the Pi, removed the Fan Shim, and re-seated it making sure all the GPIO pins were making good contact with the fan. So far it isn’t spinning all the time.

So either I broke it, or it’s behaving as it should! :-)

The default fail safe mode is fan on. It won’t turn off without being commanded too by software. This lets you use it without having to install any software. It’s on all the time, but it works.

Thanks. I have the “on at certain temp, off at another” service active so I’ll perhaps experiment setting the ON value lower than the Pi’s current operating temperature and see what happens.

Here is some info I saved to a text file on the fan shim.

Fan Shim BCM 17 Pin 11 Button
Fan Shim BCM 18 Pin 12 Fan Control

To use the Fan Shim Button as a shutdown button add the following to config.txt
dtoverlay=gpio-shutdown,gpio_pin=17,active_low=1,gpio_pull=up

The following entry to config.txt can be used to turn the fan on at 55c and back off at 35c.
dtoverlay=gpio-fan,gpiopin=18,temp=55000

apt install git python3-pip

git clone GitHub - pimoroni/fanshim-python: Python library for the Fan SHIM for Raspberry Pi
cd fanshim-python
sudo ./install.sh

install service

cd examples
sudo ./install-service.sh --on-threshold 55 --off-threshold 40 --delay 2
–nobutton to turn button off and
–noled to turn the LED off.

change service

sudo systemctl stop pimoroni-fanshim.service
sudo ./install-service.sh --on-threshold 75 --off-threshold 60 --delay 5

disable service

sudo systemctl stop pimoroni-fanshim.service
sudo systemctl disable pimoroni-fanshim.service

enable again

sudo systemctl enable pimoroni-fanshim.service
sudo systemctl start pimoroni-fanshim.service

Python

from fanshim import FanShim
fanshim = FanShim()

Fan
Turn the fan on with:
fanshim.set_fan(True)
Turn it off with:
fanshim.set_fan(False)
You can also toggle the fan with:
fanshim.toggle_fan()
You can check the status of the fan with:
fanshim.get_fan() # returns 1 for ‘on’, 0 for ‘off’

LED
Fan Shim includes one RGB APA-102 LED.
Set it to any colour with:
fanshim.set_light(r, g, b)
Arguments r, g and b should be numbers between 0 and 255 that describe the colour you want.
For example, full red:
fanshim.set_light(255, 0, 0)