I’ve just received my (first) ESP32 and trying to use it as a controller for a 120mm PWM fan in my network cabinet.
I took example on this topic using ESPHome with ledc output. What changes in my case is that my fan is a PWM PC fan (4pin, 12V) so I assume i don’t need the MOS Module, right ?
The upload is successful and I see my fan.network_cabinet_fan in Home Assistant.
When I change speed, I can see the ESP32’s onboard LED flash, I see logs in ESPHome but nothing is happening on the fan, it stays at full speed.
I unfortunately don’t have an oscilloscope (Or LED) to check if the PWM signal is good or not. When checking with a multimeter, I can see the voltage between the ESP Pins G12 and GND as following :
Low speed : -2.10V ±0.05V
Medium speed : 1.0V ±0.05V
High speed : 0V ±0.2V
These values are with the ESP’s GND, so do I have to connect ESP32’s GND to PSU’s GND ?
I tried to do it but in the logs I’m seeing this :
It’s more than just tying the grounds together. I think the PWM signal has to be at the same voltage as VCC. So you’d have to step up the ESP32 output to VCC.
after you make sure the grounds are connected, are you using the correct pin for PWM and not accidentally sending the PWM signal to the tach wire? Silly question I know, but sometimes it’s the obvious that gets overlooked.
Your first post made me check again about PWM signal, it should be 5V. That’s good in my case.
For the pin, yes it’s the right one. I’ve checked under the fan label, the cable connection to the board is labeled PWM.
I’ve received my level shifter today and it works as expected. Well, not at first because there is a pin on my ESP32 board labeled GND but should be labeled CMD … changed ground pin and it works !
Only issue is that levels are backwards : if I set “high” on HA the fan stops and if I set “off” the fan is at full power. Pretty sure that’s not hard to change.
Sharing the diagram in case someone wants to reproduce :
In my case, using 4pin fans (dell/server) I have not needed a level shifter, datasheet for my fans say they want 3.3v PWM at 25Khz (above human hearing) which esp32 can do but esp8266 cannot.
You need to manually set PWM frequency in esphome to 25000hz, some fans also require min_pwm 0.3 (30%) to get them going from a dead stop
Beware the tachometer output is usually pulsed 12V, which will probably kill ESP without a voltage divider circuit, so triple check you have everything hooked up properly before applying power
Great post! I want to make exactly that - control a 12V PWM fan with ESP from HA. One question: did someone solve the inverted levels? Why are the levels backwards?
Default behaviour of the fans when they don’t recieve a PWM signal (0% duty cycle) they failsafe into a full speed setting.
Using LEDC the fans work as expected, but again I’m not using level shifters and always send them a minimum PWM value so they start reliably and don’t go into failsafe
I assembled this thing today. Used Arctic PWM fan + level shifter + voltage regulator which lowers 12V to 5V to power the ESP32 and provides the reference voltage for the level shifter. It mostly works correctly. No inverted control in HA, but there’s one problem: when I set the speed to 0 in HA the fan still spins at a low speed. It doesn’t stop. Any ideas?? I don’t want to add a relay to cut the power off.
What can be wrong?
Hey there, I came across this thread by chance. Apparently, some fans can’t be turned off using PWM and just have a minimum speed. Noctua can be turned off.
Hello together, since reddit is currently not working and I cant see my post there I’m also posting here. I hope here are some ESP experts around which could help me out.
This is my “first” big ESP project. 3 years ago I build BRUHs Multisensor but thats basically just putting things together.
What I want to archive is basically this but with temperature & PWM controlled fans monitored by HomeAssistant
I’m by far no expert in this topic but I hope that I have enough knowlegde to archive this.This was my fist time using fritzing so please dont blame me
That’s what I currently have. But I’m unsure if its wired correctly. The GPIO Pins were randomly connected because I dont know which pins I must connect.
The thing should be powered by a 12V power adapter. A Buck converter will step this down to 5V to power the ESP32. The mosfet driver is just a placeholder (couldnt find a proper one in fritzing) the correct should be the one in the picture. The DS18B20 will measure the incomming water temperature of the radiator. When there are high temperatures, the fans should spin up. Since I’m going to use Arctic fans which cant be turned off via PWM I hooked up a relais to cut the 12V to the fan.
So, my questions are: Is this wired up correctly or will the hole thing explode?
And: Which pins must be used to control the relais, monitor the sensor and sent the PWM signal?
Do you have other recommendations how to archiv this? The mosfet driver could possibly replaced by a level shifter and PWM fans but i haven’t found any informations about hz or voltage for the PWM signal of the Arctic fans.
Controlling your fan by true PWM is more efficient than having a mosfet controlling the power to the fan. You only need a 3.3V to 5v logic convertor (cheap transistor(s) and some resistors). Fan PWM is 5V. You can also connect Tach-wire to ESP32 as input with pulse_counter sensor to get RPM-readings.
PWM-fan: Ground, 12V, Tach, PWM. Google “Pinout PWM fan” ,
logic level convertor something like; Simple Level Shifter With Transistors (3.3V-5V) Probably you can use a single 2n3904 BUT you have to invert PWM signal. Possible with ESPHome as property for output component. So get rid of first transistor in schematic.
I’ve got a question concerning speed fan component within ESPHome. When configuring this component in ESPHome Home Assistant only exposes a toggle button. I’m missing a slider-control.
Within homeassistant MQTT-topics this component config is;
When submitting a value (between 0 and 100) to speed_level_command_topic (in MQTT Explorer) the FAN Speed is controllable. Why doesn’t Home Assistant show Slider-control?
To reply on my own question. It appears ESPHome dropped Speed fan MQTT support as Home Assistant changed inner workings. Moving to API websocket communication Speed fan slider will be available. Maybe ESPhome is going to fix MQTT support for Speed Fan.
I got the official answer from Noctua:
“5V PWM fan can easily be driven DIRECTLY from ESP32, 3.3V logic is enough. Also there is no need for additional transistor to amplify the PWM signal”.
Actually I have done the power supply with 3 fans - all are 5V PWM, 120mm and 60mm - all are driven directly from GPIOs from ESP32 without any issue.