Make your Raspberry Pi 4 cool and quiet with a simple DIY fan setup.

Learn how to install a fan on a Raspberry Pi 4 using a step-by-step guide that will keep your device running smoothly at all times. …


Updated September 17, 2023

Need help with your Raspberry Pi?
Contact Me!

Do you love silly Raspberry Pi Projects?
Check out my this YouTube Channel!


Learn how to install a fan on a Raspberry Pi 4 using a step-by-step guide that will keep your device running smoothly at all times.

Step 1: Gather your materials

  • Raspberry Pi 4 (obviously)
  • 5V DC fan (ideally with a 4-pin PWM header for better control)
  • Soldering iron and solder
  • Wire cutters
  • Small phillips screwdriver or similar tool
  • Micro USB power supply (for testing)
  • Raspberry Pi 4 case (optional, but recommended)

Step 2: Prepare the fan First, you’ll need to identify the 5V and GND pins on your fan. These are usually labeled with a red and black wire respectively. Using wire cutters, trim off any extra wires that may be connected to the fan.

Next, you’ll want to solder two jumper wires to the 5V and GND pins of the fan. Make sure to strip about half an inch of insulation from each end of the wires before soldering them to the fan terminals.

Step 3: Prepare the Raspberry Pi 4 Locate the GPIO header on your Raspberry Pi 4, which is a row of pins along the edge of the board. You’ll be connecting the fan power wires to this header.

If you don’t already have one, it’s recommended to purchase or build a case for your Raspberry Pi 4. This will help protect the fan and other components from dust and debris that may cause issues with cooling.

Step 4: Connect the fan Using your soldering iron, connect one end of each jumper wire to the appropriate pins on the GPIO header:

  • Red (5V) wire: Pin 2 or 4 (depending on your Pi’s model)
  • Black (GND) wire: Pin 6

Here’s a quick reference for pinout locations:

    3.3V - Pin 1
    GPIO2 - Pin 3
    GPIO3 - Pin 5
    5V - Pin 4 / Pin 2 (depending on model)
    GND - Pin 6
    GPIO4 - Pin 7

Step 5: Configure the software Once your fan is connected, you’ll need to configure the software to control its speed. Open a terminal and enter the following command:

sudo nano /boot/config.txt

Scroll down to the bottom of the file and add the following line:

dtoverlay=pwm-fan,gpiopin=18

This will enable PWM control on GPIO pin 18, which is connected to the fan by default. If you chose a different pin for your fan, replace “18” with the appropriate number.

Save and exit the file (Ctrl + X, Y, Enter)

Step 6: Test your setup Power on your Raspberry Pi 4 using the micro USB power supply. You should hear the fan spin up as soon as it boots up. To test different speeds, you can use the pwm-fan command in the terminal:

sudo pwm-fan 0 - Stops the fan sudo pwm-fan 100 - Sets the fan speed to 100% (maximum)

You can adjust the percentage between 0 and 100 as desired. Remember that running your fan at maximum speed all the time is not recommended, as it may cause unnecessary wear and tear on the motor and shorten its lifespan.

Conclusion With a few simple steps and inexpensive components, you can add a fan to your Raspberry Pi 4 for better cooling and quieter operation. This is an essential upgrade for anyone who uses their Pi 4 for extended periods or in a high-heat environment. By following these instructions, you’ll have a well-cooled, quieter, and more reliable device.

Happy hacking!