Stufin
Home Quick Cart Profile

Raspberry Pi 4 Official Case Fan

Buy Now on Stufin

Dimensions

30mm x 30mm x 10mm (H x W x D)

Voltage

5V

Current

0.2A

Power Consumption

1W

Noise Level

25 dBA (idle), 35 dBA (max)

RPM

5000 RPM (max)

Connector

2-pin

Cable Length

150mm

Weight

20g

Conclusion

The Raspberry Pi 4 Official Case Fan is a reliable and efficient cooling solution designed specifically for the Raspberry Pi 4. Its compact design, low noise operation, and energy efficiency make it an ideal accessory for users who want to ensure their Raspberry Pi 4 operates at optimal temperatures.

Pin Configuration

  • Raspberry Pi 4 Official Case Fan Documentation
  • Pinout Explanation:
  • The Raspberry Pi 4 Official Case Fan has a 3-pin connector that connects to the Raspberry Pi's GPIO header. Here's a detailed explanation of each pin:
  • Pin 1: VCC (5V Power)
  • Function: Provides 5V power to the fan from the Raspberry Pi's power supply.
  • Connection: Connect to a 5V power source on the Raspberry Pi's GPIO header (e.g., Pin 2 or Pin 4).
  • Pin 2: GND (Ground)
  • Function: Provides a ground connection for the fan.
  • Connection: Connect to a ground pin on the Raspberry Pi's GPIO header (e.g., Pin 6, Pin 9, Pin 14, Pin 17, Pin 20, Pin 25, Pin 30, or Pin 34).
  • Pin 3: PWM (Pulse-Width Modulation)
  • Function: Controls the fan's speed using PWM signals from the Raspberry Pi.
  • Connection: Connect to a PWM-capable GPIO pin on the Raspberry Pi's GPIO header (e.g., Pin 12, Pin 13, Pin 18, or Pin 19).
  • Connection Structure:
  • To connect the Raspberry Pi 4 Official Case Fan to your Raspberry Pi, follow these steps:
  • 1. Connect Pin 1 (VCC) to a 5V power source:
  • Connect Pin 1 to Pin 2 or Pin 4 on the Raspberry Pi's GPIO header.
  • 2. Connect Pin 2 (GND) to a ground pin:
  • Connect Pin 2 to any of the ground pins on the Raspberry Pi's GPIO header (e.g., Pin 6, Pin 9, Pin 14, Pin 17, Pin 20, Pin 25, Pin 30, or Pin 34).
  • 3. Connect Pin 3 (PWM) to a PWM-capable GPIO pin:
  • Connect Pin 3 to a PWM-capable GPIO pin on the Raspberry Pi's GPIO header (e.g., Pin 12, Pin 13, Pin 18, or Pin 19).
  • Example Connection Diagram:
  • Here's an example connection diagram:
  • Raspberry Pi 4 Official Case Fan Connector:
  • Pin 1 (VCC) Raspberry Pi GPIO Pin 2 (5V)
  • Pin 2 (GND) Raspberry Pi GPIO Pin 6 (GND)
  • Pin 3 (PWM) Raspberry Pi GPIO Pin 12 (PWM)
  • Important Notes:
  • Make sure to connect the fan to a PWM-capable GPIO pin to control the fan's speed.
  • Use a suitable power supply to ensure the Raspberry Pi and fan have enough power.
  • Be cautious when handling the fan's power cables and GPIO connections to avoid damage or electrical shock.

Code Examples

Raspberry Pi 4 Official Case Fan Documentation
Overview
The Raspberry Pi 4 Official Case Fan is a high-quality, compact fan designed specifically for the Raspberry Pi 4 case. It provides efficient cooling for the Raspberry Pi 4, ensuring stable performance and prolonging the lifespan of the board.
Technical Specifications
Dimensions: 30mm x 30mm x 7mm
 Power Consumption: 5V, 0.2A
 Noise Level: 20dBA
 Airflow: 3.4 CFM
 Connector: 2-pin JST-PH (compatible with Raspberry Pi 4 GPIO)
Programming and Control
The Raspberry Pi 4 Official Case Fan can be controlled and monitored using the Raspberry Pi's GPIO pins. Here are some code examples to demonstrate how to use the fan in different contexts:
Example 1: Basic Fan Control using Python
In this example, we will use Python to control the fan's ON/OFF state.
Code:
```python
import RPi.GPIO as GPIO
import time
# Set up GPIO library
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
# Define fan pin
fan_pin = 17
# Set fan pin as output
GPIO.setup(fan_pin, GPIO.OUT)
try:
    while True:
        # Turn fan ON
        GPIO.output(fan_pin, GPIO.HIGH)
        print("Fan is ON")
        time.sleep(5)
# Turn fan OFF
        GPIO.output(fan_pin, GPIO.LOW)
        print("Fan is OFF")
        time.sleep(5)
except KeyboardInterrupt:
    # Clean up GPIO
    GPIO.cleanup()
```
Example 2: Temperature-based Fan Control using Python
In this example, we will use Python to control the fan based on the Raspberry Pi's temperature.
Code:
```python
import RPi.GPIO as GPIO
import time
import os
# Set up GPIO library
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
# Define fan pin
fan_pin = 17
# Set fan pin as output
GPIO.setup(fan_pin, GPIO.OUT)
try:
    while True:
        # Get temperature from Raspberry Pi
        temp = int(os.popen("vcgencmd measure_temp").read()[5:-3])
# Turn fan ON if temperature exceeds 60C
        if temp > 60:
            GPIO.output(fan_pin, GPIO.HIGH)
            print("Fan is ON (Temperature: {}C)".format(temp))
        else:
            GPIO.output(fan_pin, GPIO.LOW)
            print("Fan is OFF (Temperature: {}C)".format(temp))
time.sleep(5)
except KeyboardInterrupt:
    # Clean up GPIO
    GPIO.cleanup()
```
Example 3: Fan Control using systemd Service (Raspbian OS)
In this example, we will create a systemd service to control the fan based on the Raspberry Pi's temperature.
Code:
Create a file `/etc/systemd/system/fan_control.service` with the following contents:
```bash
[Unit]
Description=Fan Control Service
[Service]
User=root
ExecStart=/usr/bin/python /home/pi/fan_control.py
Restart=always
[Install]
WantedBy=multi-user.target
```
Create a file `/home/pi/fan_control.py` with the following contents:
```python
import os
import time
while True:
    # Get temperature from Raspberry Pi
    temp = int(os.popen("vcgencmd measure_temp").read()[5:-3])
# Turn fan ON if temperature exceeds 60C
    if temp > 60:
        os.system("gpio -g write 17 1")
        print("Fan is ON (Temperature: {}C)".format(temp))
    else:
        os.system("gpio -g write 17 0")
        print("Fan is OFF (Temperature: {}C)".format(temp))
time.sleep(5)
```
Enable and start the service:
```bash
sudo systemctl enable fan_control.service
sudo systemctl start fan_control.service
```
These examples demonstrate how to control the Raspberry Pi 4 Official Case Fan using Python and systemd services. You can modify the code to suit your specific requirements and applications.