63 lines
4.3 KiB
Markdown

---
title: "An ESPHome-powered Smart PWM Fan Controller"
description: "Control your fan walls with style from HomeAssistant"
date: 2025-05-16
tags:
- DIY
- Home Automation
---
## The Motivations
I have a few fan arrays/walls throughout my house, namely two in my garage, and one I plan to build in my room over my bed to replace a tower fan.
But PC fans can be noisy, and control is ideal. So I decided to build myself a relatively simple ESPHome-based fan controller!
## The Design
I of course wanted to base the design off the ESP32, which is my go-to microcontroller for all ESPHome-related devices these days. One crucial feature of the ESP32 is that it contains 8 pulse counter units, which allow the chip to count pulses - like a fan tachometer - very quickly and without using the CPU. I selected my venerable slim HW-395 model, which I also use for [my](/posts/the-supersensor) (Supersensors](/posts/the-supersensor-2.0), as its compact size but full pin count makes designing around it very easy.
The ESP32 alone can output PWM as well, so I didn't need any sort of fancy controller chip - I just hooked the PWM lines up to each fan and let the ESPHome software do the rest. Lastly a relay controls power to the fans, for simple on/off control in addition to the PWM level control, giving the full range of control needed for a fan array.
I also needed a way to step down the 12VDC input to the 5V that both the ESP32 and relay needed, so for that I selected a basic adjustable DC-DC converter. This did require initial tuning during each board's assembly, but once set it should never need further adjustment. I used an SMD-like method with a hot air gun to ensure a flat profile with good contact for this board, while everything else is through-hole soldered.
I designed the board in EasyEDA and ordered from JLCPCB for a very reasonable price (though shipping costs are not what they used to be). The overall design is quite simple, with power routing capable of at least 3A of current at a minimum.
![Board Design](board-design.png)
![Board Layout](board-layout.png)
And assembled it looks very sleek in the black PCB finish.
![Assembled](completed.png)
Lastly, the HomeAssistant view shows everthing we might need, with power and speed controls as well as the RPM tachometer output of each fan (useful to see levels or if a fan fails).
![HomeAssistant Device](hass.png)
ESPHome code and schematics for the PCB can be found on [the GitHub project page](https://github.com/joshuaboniface/smart-pwm-fan-controller).
## Parts List (prices as of May 2025)
| Qty | Component | Cost (CAD, ex. shipping) | Links |
|-----------|--------------------------|--------------------------|-------|
| 1 | ESP32 HW-395 | $6.67 | [AliExpress](https://www.aliexpress.com/item/1005006019875837.html)* |
| 8 | 4-pin fan header | $0.21 ($1.02/5) | [AliExpress](https://www.aliexpress.com/item/1005007499957251.html) |
| 1 | MP1584EN DC-DC converter | $1.34 ($13.99/10) | [Amazon](https://www.amazon.ca/dp/B07THSDWHX) |
| 1 | SRD-05VDC-SL-C relay | $1.52 ($18.16/12) | [Amazon](https://www.amazon.ca/dp/B098JHY5TP) |
| 1 | DC barrel jack | $0.98 ($9.79/10) | [Amazon](https://www.amazon.ca/dp/B011HFLKI2) |
| 2 | 1kΩ resistor (1%) | $0.06 ($10.99/200) | [Amazon](https://www.amazon.ca/dp/B096PK4XN5) |
| 1 | 1N4004 diode | $0.07 ($20.99/300) | [Amazon (kit)](https://www.amazon.ca/dp/B07YK3XMQQ) |
| 1 | BC377 transistor | $0.06 ($12.13/200) | [Amazon (kit)](https://www.amazon.ca/dp/B07X62PBMH) |
| 1 | 3mm LED | $0.05 ($15.99/350) | [Amazon (kit)](https://www.amazon.ca/dp/B073GRZNRL) |
| 1 | Custom PCB (JLC) | $0.50 ($5.00/10) | [GitHub](https://github.com/joshuaboniface/esphome-pwm-fan-controller) |
| **TOTAL** | | $12.99 | |
* Items marked with an asterisk (`*`) require selection of the correct specific component on the page.
* Several pieces came as part of larger variety kits, so individual prices may not be completely accurate.
## Final Thoughts
This was a fun little project, and I'm quite happy with how it turned out. And it will definitely help keep me cool this summer. Happy hacking!