PWM controlled fan with ESPhome on ESP32

@tom_l Some more info: Looks like the limit mentioned in the blog post above is not applicable to ESPhome or Tasmota because they do not use pwm.c from the Expressif SDK, they use the Arduino libs which are greatly improved and can reach 60KHz.

2 Likes

Hi! Would you be able to share the hardware you used for this project? Also one question. Would I be able to tie two fans to this to control them with one output? Also I would like to attach a thermostat if possible.

Basically I’m just trying to replace these two loud fans up top here https://www.amazon.com/gp/product/B00P00LFPO/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1 with quiet noctuas. Basically I need very little to no airflow for what’s inside.

Hi, I am trying to make my first project but I am really stuck.
I have an ESP32 board (modell: ESP32-WROOM-32 it says on the box).
I have also bought a MOS Module like the one in the first post.

I would like to do exactly the same, do a PWM controlled fan and integrate it into Hassio but were to start?

I have downloaded esphome-flasher but I haven´t found what to flash on the board. I have read on ESPHOME homepage but I feel totaly lost.

In Hassio I have added the add-on but think I will understand how what/how to flash the board first.
I have used arduino ide and flashed same basic sketch. For example got it to join my WiFi-network.
Is that enought to just get it to connect to my WiFi-network or where should I start?

This is a good place to start. At least I found it to be.

Hope it’s of help.

Hi Akriss, (My question is solved, see EDIT 2 in the bottom, thank you)

That is were I started but I feel dumb like an idiot…
I have added the add on. Then I pressed on “Create New Node” in Hassio.

Node name, I guess this doesn´t matter. I can namned it whatever?
WiFi & Updates, is it my normal wifi ssid and password where Hassio also are connected to?

In the config file. Is this correct?

esphome:
name: fanis
platform: ESP32
board: esp32dev

wifi:
ssid: “XXX”
password: “XXX”

manual_ip:
static_ip: 192.168.0.138
gateway: 192.168.0.1
subnet: 255.255.255.0

When I try to compile and upload I get the following error.

INFO Successfully compiled program.
INFO Connecting to 192.168.0.138
ERROR Connecting to 192.168.0.138:3232 failed: [Errno 111] Connection refused

Do I have to open any ports or how to continue?

EDIT:
Can this depend on that I haven´t connected the board directly to the NUC where Hassio is installed? I have choosed OTA in the ESPHome gui in hassio.

EDIT 2:
I tried to connect directly in my NUC and now I got it running.

How can this project be modified to include the tach wire for rpm reading in home assistant?

1 Like

Maybe try this:

Just found this topic and it is exact what i need. SO I tried finding the right components but struggle a bit.

I found without problems the esp8266 but here comes the first problem. I read that esp only needs 3,3v, so I can not use a simple USB Power adapter, correct?
Second thing was the part where I connect the power for the fan, 12v. But that was easy after rotating and scaling the image a bit. :slight_smile:
So what power supply should I use for the fans? I find a lot 12v power supply but not sure wich to use.
And is there an option without cutting the cords from the fans?

Oh and what is the board in the latest post with the image called?

Hello all,

I have also installed a FAN on my system.

Hardware: ESP32 + Mos Module

Everything works, except that ON is OFF / OFF is ON and slider 100 = 0 V and 0 = 24V.

So just the other way round.

How can I change this setting? And it is possible to start by 10V → Slider 0-100 because with 2 or3 V my fan will not start.

ESP Config:

output:
  - platform: ledc
    pin: GPIO19
    frequency: 100 Hz
    id: ventilation_fan_pwm

fan:
  - platform: speed
    output: ventilation_fan_pwm
    name: "Basement Ventilation Fan"

ESPHOME Version 1.72
HA: 2021-5-2

How did you wire it up ?

For my ON / OFF problem , I found a solution :slight_smile:

inverted: True - But now I fighting with the MIN an MAX value

Wire - Should fit - otherwise the motor would not move - right?

output:
  - platform: ledc
    pin: GPIO19
    frequency: 5 Hz
    id: ventilation_fan_pwm
    inverted: True

How come your frequency is so low ? I have mine set to 10000 Hz

With 10000HZ the motor does not work. I have a 24V DC PC fan that I have as a fan in the house wall.

Strange, mines a 12v pc fan and works fine.

Looking here it seems to be the minimum

Strange - I will try again.

You are using the min_power and max_power function?
It doesn’t work for me.

No, not using those

Hey @anthr76 were you able to make any headway on this project? I found this thread looking for the exact same solution for my new NavePoint rack I have coming.

Looks like you should be able to use this to customize your output values:
https://esphome.io/components/output/custom.html

A quick sanity check please. I can achieve the exact same with this module, main difference being only s common ground and signal going to the MCU, right?

Thanks!

Hi, all
I have attempted same setup, but something weird is happening with MOS. When fan is not connected to MOS module output the slider button in HA can turn MOS module on and off. I can see 12v on the power input side and on the output side. As soon as I connect 12v output side to the fan voltage drops below 1v. As soon as fan disconnected - 12v is there again.
Any ideas?