# Fan Shim service not starting correctly

**URL:** https://forums.pimoroni.com/t/fan-shim-service-not-starting-correctly/18981
**Category:** Support
**Created:** [March 1, 2022, 4:23pm UTC](https://forums.pimoroni.com/t/fan-shim-service-not-starting-correctly/18981 "2022-03-01T16:23:36Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Signum](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/signum/32/8576_2.png) [@Signum](https://forums.pimoroni.com/u/Signum)
#### Post date: [March 1, 2022, 4:23pm UTC](https://forums.pimoroni.com/t/fan-shim-service-not-starting-correctly/18981/1 "2022-03-01T16:23:36Z")

</div>

Hi,

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 _install-service.sh_ 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.

---

<div class="post-metadata">

### Author: ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)
#### Post date: [March 1, 2022, 4:54pm UTC](https://forums.pimoroni.com/t/fan-shim-service-not-starting-correctly/18981/2 "2022-03-01T16:54:52Z")

</div>

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.  
`dtoverlay=gpio-fan,gpiopin=18,temp=55000`  
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.

---

<div class="post-metadata">

### Author: ![Signum](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/signum/32/8576_2.png) [@Signum](https://forums.pimoroni.com/u/Signum)
#### Post date: [March 1, 2022, 5:18pm UTC](https://forums.pimoroni.com/t/fan-shim-service-not-starting-correctly/18981/3 "2022-03-01T17:18:19Z")

</div>

> [@alphanumeric](#):
>
> `dtoverlay=gpio-fan,gpiopin=18,temp=55000`

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 _./install-service.sh_ after the _ **Installing service to: /etc/systemd/system/pimoroni-fanshim.service** _ line?

---

<div class="post-metadata">

### Author: ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)
#### Post date: [March 1, 2022, 6:54pm UTC](https://forums.pimoroni.com/t/fan-shim-service-not-starting-correctly/18981/4 "2022-03-01T18:54:05Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)
#### Post date: [March 1, 2022, 7:16pm UTC](https://forums.pimoroni.com/t/fan-shim-service-not-starting-correctly/18981/5 "2022-03-01T19:16:36Z")

</div>

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

```auto
pi@raspberrypi:~/fanshim-python/examples $ sudo ./install-service.sh --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 ./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 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 $ 

```

---

<div class="post-metadata">

### Author: ![Signum](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/signum/32/8576_2.png) [@Signum](https://forums.pimoroni.com/u/Signum)
#### Post date: [March 2, 2022, 9:51am UTC](https://forums.pimoroni.com/t/fan-shim-service-not-starting-correctly/18981/6 "2022-03-02T09:51:25Z")

</div>

Thanks for taking the time and running the script.

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

> [@alphanumeric](#):
>
> ```auto
> Installing service to: /etc/systemd/system/pimoroni-fanshim.service
> 
> ```

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

Once I inspect the install-service.sh 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?

---

<div class="post-metadata">

### Author: ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)
#### Post date: [March 2, 2022, 11:44am UTC](https://forums.pimoroni.com/t/fan-shim-service-not-starting-correctly/18981/7 "2022-03-02T11:44:28Z")

</div>

I have this in my crib sheet

disable service

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

```

enable again

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

---

<div class="post-metadata">

### Author: ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)
#### Post date: [March 2, 2022, 9:33pm UTC](https://forums.pimoroni.com/t/fan-shim-service-not-starting-correctly/18981/8 "2022-03-02T21:33:11Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Signum](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/signum/32/8576_2.png) [@Signum](https://forums.pimoroni.com/u/Signum)
#### Post date: [March 3, 2022, 11:52am UTC](https://forums.pimoroni.com/t/fan-shim-service-not-starting-correctly/18981/9 "2022-03-03T11:52:57Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)
#### Post date: [March 3, 2022, 12:18pm UTC](https://forums.pimoroni.com/t/fan-shim-service-not-starting-correctly/18981/10 "2022-03-03T12:18:18Z")

</div>

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.
