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.
Just tested the Noctua NF-S12B redux-1200 PWM 12V fan with an ESP32 where the PWM signal is just 3,3V without any issues. The tacho signal works also great and can be easily read via one of the input pins of the ESP32.
I’ve read previously that the tacho signal can be 12V pulses. Also read the input pins on ESP32 read 0-5V. Without a step-down, I guess you haven’t fried anything, but I’m curious how the board reacts to the 12V.
The fan 5V is connected to the 5V on the ESP32
Fan GND is on the Board GND
Tacho from the fan is on Pin 12
And the PWM signal to the fan is from Pin 23
I set up an automation to monitor HDD temps from my OMV server and spin the fan up in 4 different increments.
What’s the amperage (current) on the leads? I really want to know. You are allowed to draw max 16 mA from GPIO pins. If your fan consumes more, you will fry your ESP device. This is why most people use transistors with an independent power supply — and the GPIO is used to connect to the base in the transistor so that current activates the transistor.
I haven’t had any issues (yet), and I’m fairly confident it will be OK especially as the fan never goes above 20% anyway and I have run it at 100% during testing.
Looking at this thread on Reddit:
Seems that other users are pulling a lot more current than I am just fine.
I’m not saying its a good idea though, if you do it like I have then its at your own risk, seems the limiting factor is the trace on the board so be careful!