DIY: Build a Custom Temperature‑Controlled Cooling Fan for Small Electronics Projects
Ever had a tiny board or a little enclosure that started to feel like a sauna? I’ve been there—my first 3D‑printed case for a Raspberry Pi Zero got so hot that the LEDs flickered and the CPU throttled. That’s why a fan that only spins when it’s really needed can be a game‑changer. It saves power, cuts noise, and keeps your gadgets happy. Let’s walk through a simple, low‑cost way to build a temperature‑controlled fan that you can drop into any small project.
Why a Temperature‑Controlled Fan Matters
Most hobbyists just slap a 5 V fan on a board and leave it running all the time. It works, but it also draws power even when the device is idle. In battery‑run projects that extra milliwatt adds up fast. A temperature‑controlled fan, on the other hand, stays off until the heat climbs past a set point, then kicks in just enough to bring things back to a safe range. The result is longer battery life, less noise, and a cooler, more reliable device.
Parts You’ll Need
You don’t need a PhD in electronics to pull this together. Here’s a short shopping list that you can find on most online stores or at a local electronics shop.
The Fan
A 5 V brushless or DC fan with a low current draw (around 100 mA) works well for most small enclosures. Look for a fan with a built‑in bearing for quieter operation. I like the 40 mm “mini‑blade” fans because they fit in tight spaces and still move enough air.
Temperature Sensor
The classic choice is the LM35 or the more modern digital sensor like the DS18B20. The LM35 gives an analog voltage that changes by 10 mV per degree Celsius, which is easy to read with an Arduino‑compatible board. If you prefer a digital readout, the DS18B20 talks over a single wire and is very accurate.
Microcontroller
A tiny board such as an Arduino Nano, ESP8266, or even a ATTiny85 will do. I usually reach for the Nano because it has enough pins for a sensor, a fan driver, and a few extra LEDs for status.
Power Supply
If your project already runs on 5 V, you can power the fan and the controller from the same source. Otherwise, a small USB power bank or a 5 V regulator from a Li‑ion cell works fine. Just make sure the supply can handle the extra 150 mA when the fan spins.
Miscellaneous
- A small MOSFET (e.g., IRLZ44N) or a logic‑level N‑channel transistor to switch the fan on and off.
- A 10 kΩ pull‑up resistor for the DS18B20 (if you use it).
- A few jumper wires, a breadboard or a tiny perf board for a permanent build.
- Heat‑shrink tubing or electrical tape for safety.
Wiring the Circuit
-
Connect the sensor – For the LM35, hook the VCC pin to 5 V, GND to ground, and the output pin to an analog input on the Nano (A0 works well). If you use the DS18B20, connect VCC to 5 V, GND to ground, and the data line to a digital pin (D2 is a good choice) with a 10 kΩ pull‑up to 5 V.
-
Set up the fan driver – The MOSFET’s drain goes to the fan’s negative lead, the source to ground, and the gate to a digital output pin (D3). The fan’s positive lead connects straight to 5 V. Adding a 100 µF electrolytic capacitor across the fan’s leads helps smooth out any voltage spikes.
-
Power everything – Tie the Nano’s VIN (or the 5 V pin if you’re using a regulated source) to the same 5 V rail that powers the fan. Keep the ground lines common; a single ground point reduces noise.
-
Optional status LED – Connect an LED with a 220 Ω resistor from another digital pin (D4) to ground. This will blink when the fan is active, giving you a quick visual cue.
Double‑check all connections, especially the MOSFET orientation. A reversed MOSFET will keep the fan dead or, worse, short the supply.
Writing the Simple Control Code
Below is a minimal sketch for the Arduino Nano. It reads the temperature, compares it to a threshold, and toggles the fan.
// Pin definitions
const int sensorPin = A0; // LM35 analog pin
const int fanPin = 3; // MOSFET gate
const int ledPin = 4; // optional status LED
// Temperature thresholds (Celsius)
const float onTemp = 45.0; // turn fan on above this
const float offTemp = 40.0; // turn fan off below this
void setup() {
pinMode(fanPin, OUTPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// Read LM35 voltage (5V reference, 10-bit ADC)
int raw = analogRead(sensorPin);
float voltage = raw * (5.0 / 1023.0);
float temperature = voltage * 100.0; // 10mV per °C
Serial.print("Temp: ");
Serial.println(temperature);
static bool fanOn = false;
if (!fanOn && temperature >= onTemp) {
fanOn = true;
digitalWrite(fanPin, HIGH);
digitalWrite(ledPin, HIGH);
} else if (fanOn && temperature <= offTemp) {
fanOn = false;
digitalWrite(fanPin, LOW);
digitalWrite(ledPin, LOW);
}
delay(1000); // sample once per second
}
A few notes:
- The
onTempandoffTempvalues create a small hysteresis band (5 °C) so the fan doesn’t chatter on and off at the exact threshold. - If you use a DS18B20, replace the analog read with the OneWire library calls; the logic stays the same.
- You can tweak the thresholds for your specific enclosure. I found 45 °C to be a safe cut‑off for my 3D‑printed case, but a metal box may need a lower point.
Testing and Tuning
Before you solder everything, give the breadboard version a spin. Use a hair dryer or a heat gun to raise the temperature of the sensor deliberately. Watch the serial monitor; you should see the temperature climb, the fan turn on, and the LED light up. Let it cool down and verify that the fan shuts off at the lower threshold.
If the fan never starts, check the MOSFET gate voltage with a multimeter. The Nano’s digital pins output 5 V when HIGH, which is enough to fully open a logic‑level MOSFET. If you see only a few volts, the pin may be set as INPUT by mistake.
Once you’re happy, move the circuit to a perf board, trim any excess wire, and secure the fan with a small screw or hot glue. Make sure the fan’s airflow direction matches the intended cooling path—most fans have arrows on the frame indicating airflow.
A Few Tips and Gotchas
- Sensor placement matters. Mount the temperature sensor where the heat actually builds up, not right next to the fan. A small piece of thermal paste can improve contact if you’re measuring a chip’s surface.
- Watch your power budget. If you’re running off a coin cell, a 100 mA fan can drain it quickly. In that case, consider a slower 30 mm fan or a PWM‑controlled fan that runs at lower speed.
- Add a soft‑start. Some fans make a loud click when they start. Adding a small resistor in series with the gate for a few milliseconds can ease the inrush current and reduce noise.
- Seal the enclosure. Even the best fan can’t fight a leaky case. Use silicone or a gasket to keep hot air from escaping through gaps.
Building a temperature‑controlled fan is a small project that teaches you a lot about analog sensing, digital control, and power management. It also gives you a reusable module you can drop into future builds—whether it’s a portable audio amp, a tiny CNC controller, or a custom IoT sensor node.
Next time you see a little board sweating its circuits, you’ll have a ready‑made solution that only works when it’s really needed. That’s the kind of practical, low‑tech magic I love sharing on CoolTech Fans.
#cooltechfans #diy #electronics
- → How to Design a Precise LED Dimmer Using a Rheostat – Complete Wiring Diagram & Calculations @rheostatrealm
- → Step-by-Step Guide: Building a DIY Variable-Speed Motor Controller with a Rheostat @rheostatrealm
- → How to Quickly Identify Resistor Values with a Simple Color‑Code Cheat Sheet @resistorrealm
- → Step-by-Step Guide to Building a Reliable LED Dimmer Using Common Resistors @resistorrealm
- → Designing Energy‑Efficient LED Segment Displays for Portable Projects @segmentlight