A salvaged MacBook fan cools the Raspberry Pi 4 in my station. Its control circuit fits on a small piece of perfboard: a BC547B, four resistors and an electrolytic capacitor. The Pi controls the fan using hardware PWM and reads back its tachometer signal.

A MacBook fan on the Pi
The fan is a four-wire Delta KSB0505HB-8F36, labelled 5 V / 0.40 A. This blower fits my heatsink well and runs quietly at low speed. I adapted the mounting by hand; this is my own experimental build.
The four connections are +5 V, GND, PWM and tachometer. The schematic identifies these functions. It does not establish a universal connector order or wire-colour scheme for other fans.
Complete wiring
| Pi pin | Function | Connection |
|---|---|---|
| 2 | +5 V | Fan supply and positive terminal of C1. |
| 6 | GND | Fan ground, emitter and negative terminal of C1. |
| 33 · GPIO13 | PWM output | Through R1, 2.2 kΩ, to the BC547B base. |
| 1 | +3.3 V | Through R3, 2.2 kΩ, to the tachometer node. |
| 36 · GPIO16 | Tachometer input | Through R4, 2.2 kΩ, to that same node. |
The collector connects to the fan PWM wire; the emitter connects to ground. R2, 10 kΩ, goes directly between base and emitter. For the TO-92 BC547B shown here, viewed with its flat, marked face toward you and the leads pointing down, the order is C on the left, B in the middle, E on the right. See the onsemi BC547 datasheet.
The motor receives a continuous 5 V supply. The transistor pulls only the PWM control wire to ground. This inverts the signal: GPIO HIGH → fan PWM LOW. The software accounts for that inversion.
Tachometer pull-up to 3.3 V
R3 pulls the tachometer node up to 3.3 V; R4 connects it to GPIO16. These two resistors are not a voltage divider. This circuit requires an open-collector tachometer output without an internal pull-up to 5 V. It does not level-shift an actively driven 5 V output. Pi GPIOs use 3.3 V logic and are not 5 V tolerant.
GPIO16 is configured as an input with its internal pull resistors disabled. Speed is calculated from pulse frequency and the number of pulses per revolution: RPM = 60 × f / pulses per revolution. The assumption of two pulses per revolution has not been independently confirmed for this exact fan variant, so the absolute RPM reading remains approximate.
Perfboard components
| Part | Value / type | Purpose |
|---|---|---|
| Q1 | BC547B | NPN transistor for the PWM control wire |
| R1 | 2.2 kΩ · SMD 222 | Base resistor |
| R2 | 10 kΩ · SMD 103 | Base-to-emitter pulldown |
| R3 | 2.2 kΩ · SMD 222 | Tachometer pull-up to 3.3 V |
| R4 | 2.2 kΩ · SMD 222 | Series resistor to the tachometer input |
| C1 | 1000 µF / 25 V | Across +5 V and GND, positive terminal to +5 V |
The capacitor sits close to the fan supply connection. I used a 25 V part because it was in my parts box; it operates at 5 V here. The Pi power supply must also accommodate the fan current.
Quiet running without repeated restarts
At low speed I initially heard noises that coincided with Pi activity. Adding the capacitor alone did not remove them. After switching to hardware PWM on GPIO13 at 21 kHz, the fan ran quietly in the test. The 21 kHz setting is a tested value for this build, not a claimed manufacturer specification.
My fan can sustain a low speed but does not reliably start from rest at the same setting. Automatic control therefore keeps it running at a minimum of 16% and follows a smoothed temperature curve above that. After an intentional stop it briefly receives 35% to start, then settles to the requested setting. Manual control still allows a complete stop. These percentages apply to my particular fan.
On my SX board, the existing D2 LED also connects to GPIO13 through its original 1 kΩ resistor. It can remain connected there and follows the inverted control signal. Its HDMI indicator is now labelled PWM: it shows sampled GPIO levels, not RPM. This shared connection applies to my verified board wiring, not to every HAT.
The rest of the Pi, SXceiver, Si570 and GPS/PPS station is documented in Si570 and GPS/PPS as the SXceiver reference.

