Fanshim not working

Hi all

I just installed a fanshim on my pi4.
it turns on when I boot up the pi, but then it seems not to respond to my commands :(

pi@raspberrypi:~ $ ./fanshim.sh 

No argument specified, setting ON to 55C and OFF to 45C
Setting up with:
Off Threshold: 45 C
On Threshold: 55 C
Low Temp: 45 C
High Temp: 55 C
Delay: 2 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 --on-threshold --delay --brightness --low-temp --high-temp --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 Wed 2020-09-02 21:19:27 CEST; 26ms ago
Main PID: 4339 (python3)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/pimoroni-fanshim.service
└─4339 /usr/bin/python3 /home/pi/automatic.py --on-threshold 55 --off-threshold 45 --low-temp 45 --high-temp 55 --delay 2 --brigh…

Sep 02 21:19:27 raspberrypi systemd[1]: Started Fan Shim Service.
pi@raspberrypi:~ vim /etc/systemd/system/pimoroni-fanshim.service pi@raspberrypi:~ ./temperature.py
temp=59.0’C
Fan status is: 0
pi@raspberrypi:~ $ ./temperature.py
temp=64.0’C
Fan status is: 0

Basically I’m setting the fan to turn on between 45 and 55, but as you can see the fan stays off even when the temp is 59 or 64 degree. the led doesn’t turn on at all…

if I use automatic.py script, I can see the led working and the fan turning on and off…

Usually its a contact issue, one or more pins not making a good contact.
If the fan is turning on off and the LED coming on via the automatic.py thats likely not the issue.

The full install procedure goes something like this, make sure you are in the correct directory when you run them.

git clone https://github.com/pimoroni/fanshim-python
cd fanshim-python
sudo ./install.sh

Then to install the service you do the following. As far as I know the above needs to be installed for this to work

cd fanshim-python
cd examples
sudo ./install-service.sh --on-threshold 55 --off-threshold 40 --delay 2

other options are as follows
–nobutton to turn button off and
–noled to turn the LED off.

If you want to change the service

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

To disable the 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

Hi and thanks for the asnwer

In the end I was able to solve the issue.
I was calling the install-service.sh script from another script located into another directory.
The generated .py file was then using a wrong base directory file.

Now in my script I cd into the the fanshim/examples directory before calling the install-service.sh script and everything works good :)


You can see how the temperature is correctly changing here according to the threshold I set :)

Ok, good stuff, now you get to have some fun with working code. =)