Simple Raspberry Pi Fan

Add a 1.2A fan to a raspberry pi 3 and a script to turn it on and off as required.

An easy way to add a fan is to simply connect the fan leads to a 3.3V or 5V pin and to ground. Using this approach, the fan will run all the time.

It is much more interesting to turn the fan on when it reaches or surpasses a high temperature threshold, and then turn it off when the CPU was cooled below a low temperature threshold.

The other Raspberry Pi fan guide is required if you do not have a 1.2A fan.

This guide can be used if you have:

    • Raspberry Pi 3B+, 4 or Zero

    • 5v 1.2A Fan <<< be sure it is 1.2A or less. 1.6A and 2.0A fans will not work

Update:

I haven't tried the Noctua fan, but Christopher Barnett does deep technical evaluations. I ran across the YouTube video below and thought this should be added as an option:

Background:

See Raspberry Pi Fan for a more complete description

Step 1. Get the simple-fan.py script

In the steps below, I am using pi as the username. Please edit the downloads and change the user name from pi to your username, as well as, the home directory from /home/pi to your home directory.

If you are using a different username and home directory, make the changes accordingly.

Login to your raspberry pi with one of the following:

$ ssh pi@♣ip-address♣

$ shh pi@♣hostname♣.local

And then you can download the script using:

$ sudo wget "https://raw.githubusercontent.com/dumbo25/rpi-fan/master/simple-fan.py"

Make the script executable.

$ sudo chmod +x simple-fan.py

$ sudo chown root:root simple-fan.py

I turn the fan on on at 65 C. If the start temperature is set too low, the fan will turn on cool the CPU down, and by the time the fan is turned off the temperature is almost back up to start temperature. Try 45 C to see this effect. I am not sure what the optimal temperature is.

Step 2. Create a service to start the simple-fan.py on reboot

The directions are contained within the script

Or download the script using:

$ sudo wget "https://raw.githubusercontent.com/dumbo25/rpi-fan/master/simple-fan.service"

$ sudo cp simple-fan.service /lib/systemd/system/.

The script also contains the pins to use. Be sure to connect the pins from the fan to the GPIO pins

Red Fan pin goes to GPIO 3.3v (pin 01 or 17)

Black Fan pin goes to GPIO GPIO_PIN defined in the script (physical pin 37 or GPIO 26)

Step 3. Start fan automatically using

After any changes to /lib/systemd/system/simple-fan.service:

$ sudo systemctl daemon-reload

$ sudo systemctl enable simple-fan.service

$ sudo systemctl start simple-fan.service

$ sudo reboot

Ensure the run-fan.service in systemd is enabled and running:

$ systemctl list-unit-files | grep enabled | grep simple

$ systemctl | grep running | grep simple-fan

$ systemctl status simple-fan.service -l

If there are any issues with starting the script using systemd, then examine the journal using:

$ sudo journalctl -u simple-fan.service


Troubleshooting:

In general, this just works. However, if the fan is not 1.2 Amp or lower, then it will not work and external components are required.

The service may have issues. Check the value is set correctly for the OS. Raspberry Pi uses Restart=on-failure