Fanshim/RPI4 does not react from python

The fan works (i.e. turns), but with no led.
I installed the python API, try it and the fan does not react at all. All commands below give no errors, but do nothing:
>>> from fanshim import FanShim
>>> fanshim = FanShim()
>>> fanshim.set_fan(False)
>>> fanshim.set_light(0, 255, 0)

Also, it is supposed to have a button. Where is it ?
I certainly missed something… Could somebody help?


The “small” button is on the circuit board edge next to the LED. You press it from the side.
With no software installed the fan will just run contiguously as long as the Pi is powered up. The LED will not work and should be off. Pressing the button should boot the Pi up if it was shutdown and left powered up. A config.txt edit will let you use it to do a proper shut down. Add the following line to your config.txt file.dtoverlay=gpio-shutdown
Running sudo pip install fanshim should get everything you need to make it work manually via python code.
Another way to do it is as follows
git clone
cd fanshim-python
sudo ./
And if you want to setup auto mode do this
cd examples
sudo ./ --on-threshold 65 --off-threshold 55 --delay 2

OK, thanks for your answer.
I previously read carefully the tutorial and installed fanshim through pip3.
Meanwhile, I discovered the command gpio readall gives an error, so I upgraded gpio to version 2.52 (see here). Now gpio readall gives a correct result.

But the fan still does’t react. I can see that the gpio works as expected: when I run fanshim.toggle_fan(), I can see with gpio -g read 18 that its value is changing consistently.

I tried also using user root without success.

I suspect a configuration problem, and in fact there was one with the outdated wiringpi package. But it was not sufficient. Any idea ?

Right now I’m just running my Fan Shim with no software installed. My temps are a nice consistent 40c.
I did set everything up when I got it to verify everything worked. I seem to remeber the sudo pip install fanshim not working for me for some reason.
The getting started with git clone worked though. And when I installed the daemon for autorun everything worked. LED changed color as the temperature rose, and the fan turned on and off as it should. I have yet to try and do any of the manual change commands.
It could be a connection issue. If you haven’t already I’d remove and reinstall it. I’d also have a look at the GPIO pins for any bent or out of alignment pins.

I don’t think I installed the Fan Shim software after reinstalling Buster on my Pi 4. Latter on today when I get a chance I’ll run the installer and see what happens. I’ll do the sudo pip first. I have a feeling that should actually be sudo pip3 as there is no python 2 in Buster. It’ll be an hour or so before I get a chance to tinker with the Pi4. I’ll post back how it goes for me.

Ok, I had a look see in my Pimoroni folder and no fan shim folder. That means the software hasn’t been installed.
I first ran the sudo pip install fanshim, no error messages etc.
I then opened Idle 3 and ran
from fanshim import FanShim
fanshim = FanShim()
That got me a no module named fanshim error.
I then ran sudo pip3 install fanshim
It downloaded and installed some things, plasma for the LED etc.
Rerunning the above fanshim.set_fan(False) py file then worked, the fan stopped. And I stopped there. I may go and see if I can turn the LED on, I just rebooted so the fan would turn on again.
LED worked, I took the fanshim.set_fan(False) line out and replaced it with fanshim.set_light(255, 0, 0) and it lit up Red. The fan stopped though, not sure why? I added fanshim.set_fan(True) and reran my py file and it turned back on and the LED is still red.

I am happy for you, I don’t have your luck. But I progress!
I reinstalled fanshim from GitHub, and now I can control the LED. But stop/start the fan still not working.

Ok, best guess is the fan control pad isn’t making contact with GPIO 18 (physical pin 12).
Try holding the fan shim down, or bending that pin slightly. If the fan starts working correctly thats the issue. That pin is pulled low (grounded) to turn the fan off. If its high or an open circuit, the fan runs.

Congratulations, you won! I have bending pin 12 slightly and it worked.
Now I have to do some mechanic to establish the contact durably.

Many thanks!

Thats good to hear. I soldered mine to a female header, I can unplug it if need be. I just mounted the fan lower in its holder by leaving those spacer nuts out. I have a heatsink on my Pi 4B, the fan wasn’t going to work in the stock location anyway.
If you go that route using a stacking header will let plug a Hat in on top of it.