Fan Shim service not starting correctly


I attached the Fan Shim on my RPi 4b 4GB and installed the packages to run the service according to the guideline on the Pimonori website.
When I try to start the service by running the script, I cannot seem to get the services running properly and I cannot get the automatic script to run including the LED and auto start/stop for the fan. The fan is running constantly.

Although all requirements are met, the output that I get on command window cannot pass beyond the bold line below:

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

I tried the following based on the proposed solutions for other support threads:

  1. Checking the connection of the GPIO pinout and slightly bending the pins for better connection with fan shim; not working.
  2. Uninstalled and re-installed the fanshim package; not working
  3. Run the simple Python script to only operate the LED,button and fan manually to check; all working

What could be the solution?

Many thanks for any help in advance.

By default, with no software installed, the fan will run continuously. A low on the fan control pin is what turns it off. Fan Shim BCM 18 Pin 12 Fan Control. It that contact doesn’t make contact with that GPIO pin the fan will never turn off.

As a test you can add this entry to your config.txt, and reboot.
The fan “should” turn on at 55c and off again at 45c. If it then works, you know the hardware is OK, its an issue with the service / software.

Thanks for the suggestion. I tried your suggested entry the config.txt and it works; the fan turns on and off automatically based on cpu temp.

Any suggestions how to solve the service issue?

What should I see as output after running the ./ after the Installing service to: /etc/systemd/system/pimoroni-fanshim.service line?

I just fired up my Pi 4B that has a Fan Shim on it, and was just using the dtoverlay for control. It’s running Bullseye. I’m going to go through the install process and see what happens. I’ll post back when I’m done.

This is what I got installing the service, and my fan turned on at 65c.

pi@raspberrypi:~/fanshim-python/examples $ sudo ./ --on-threshold 65 --off-threshold 45 --delay 2 --nobutton --noled
Setting up with:
Off Threshold:    45 C
On Threshold:     65 C
Low Temp:         45 C
High Temp:        65 C
Delay:            2 seconds
Preempt:          no
Disable LED:      yes
Disable Button:   yes
Brightness:       255
Extended Colours: no

To change these options, run:
sudo ./ --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 Tue 2022-03-01 15:20:26 AST; 21ms ago
   Main PID: 2928 (python3)
      Tasks: 1 (limit: 8987)
        CPU: 11ms
     CGroup: /system.slice/pimoroni-fanshim.service
             └─2928 /usr/bin/python3 /home/pi/fanshim-python/examples/automatic…

Mar 01 15:20:26 raspberrypi systemd[1]: Started Fan Shim Service.
pi@raspberrypi:~/fanshim-python/examples $ 

Thanks for taking the time and running the script.

Unfortunately, as it seems, my run cannot pass beyond the following printed line.

I tired to run through the script and it seems to work fine with line-by-line debugging.

Once I inspect the script by executing line by line, the following line cannot be executed although it does not throw an error; it gets stuck (in a loop?)

systemctl restart --no-pager pimoroni-fanshim.service

I tried to run the systemct restart command for another service installed and it works but it does not work for pimoroni-fanshim.service.

Any thoughts?

Is there a log generated somewhere in the system that I can inspect to dig out the issue?

I have this in my crib sheet

disable service

cd fanshim-python
cd examples
sudo systemctl stop pimoroni-fanshim.service
sudo systemctl disable pimoroni-fanshim.service

enable again

cd fanshim-python
cd examples
sudo systemctl enable pimoroni-fanshim.service
sudo systemctl start pimoroni-fanshim.service

I’m honestly not sure what your issue is? Might be worth while reinstalling Pi OS in case its just something that’s got corrupted or a permissions thing?

Thanks for the help in any case. Much appreciated @alphanumeric.

I should have used Docker or some some sort of containers in the beginning…I do not want to start from scratch just for this while I have quite a number of services with personalised/updated configurations.
I could live with the dtoverlay=gpio-fan,gpiopin=18,temp=55000 addition to the /root/config.txt to run the fan for the time being; which was a very useful hint!

You can change the 55000 to what ever you want, with in reason of course.
65000 is on at 65c and off at 55c. Its always 10c less for the off, that’s the downside. The service will give you more options.