I have a noctua NF-A20 fan that I would like to control with a D1 mini and ESPHome. Using this topic as a reference: PWM Fan Controller
I created this configuration:
esphome:
name: pwm-fan-controller
friendly_name: pwm fan controller
esp8266:
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Pwm-Fan-Controller"
password:
captive_portal:
sensor:
- platform: pulse_counter
pin:
number: D2
name: Fan Speed
id: fan_pulse
unit_of_measurement: 'RPM'
filters:
- multiply: 0.5
count_mode:
rising_edge: INCREMENT
falling_edge: DISABLE
update_interval: 5s
output:
- platform: esp8266_pwm
id: fan_speed
pin: D1
frequency: "25000 Hz"
min_power: 13%
max_power: 100%
fan:
- platform: speed
output: fan_speed
name: fan speed
id: fan_toggle
Controlling the fan seems to work, when I move the slider up, the fan increases it’s speed, when I move it down, it decreases it’s speed. I am however facing 2 issues:
The reported RPM is incorrect, the fan has a minimum rpm of 350 and a max of 800, I get RPM values between 1500 and 3392. According to the documentation (https://noctua.at/pub/media/wysiwyg/Noctua_PWM_specifications_white_paper.pdf) the current code should be ok:
All Noctua fans provide a tachometer output signal of the following characteristics:
• two cycles per revolution
When I have a look at the log when the fan is running at full speed, I see that the pulse counter is all over te place:
[D][pulse_counter:174]: 'Fan Speed': Retrieved counter: 3348.00 pulses/min
[D][sensor:126]: 'Fan Speed': Sending state 1674.00000 RPM with 2 decimals of accuracy
[D][pulse_counter:174]: 'Fan Speed': Retrieved counter: 3779.24 pulses/min
[D][sensor:126]: 'Fan Speed': Sending state 1889.62207 RPM with 2 decimals of accuracy
[D][pulse_counter:174]: 'Fan Speed': Retrieved counter: 4132.13 pulses/min
[D][sensor:126]: 'Fan Speed': Sending state 2066.06616 RPM with 2 decimals of accuracy
[D][pulse_counter:174]: 'Fan Speed': Retrieved counter: 3894.55 pulses/min
[D][sensor:126]: 'Fan Speed': Sending state 1947.27380 RPM with 2 decimals of accuracy
[D][pulse_counter:174]: 'Fan Speed': Retrieved counter: 3649.46 pulses/min
[D][sensor:126]: 'Fan Speed': Sending state 1824.72986 RPM with 2 decimals of accuracy
[D][pulse_counter:174]: 'Fan Speed': Retrieved counter: 4120.12 pulses/min
[D][sensor:126]: 'Fan Speed': Sending state 2060.06006 RPM with 2 decimals of accuracy
[D][pulse_counter:174]: 'Fan Speed': Retrieved counter: 3888.00 pulses/min
[D][sensor:126]: 'Fan Speed': Sending state 1944.00000 RPM with 2 decimals of accuracy
[D][pulse_counter:174]: 'Fan Speed': Retrieved counter: 4700.24 pulses/min
[D][sensor:126]: 'Fan Speed': Sending state 2350.11987 RPM with 2 decimals of accuracy
[D][pulse_counter:174]: 'Fan Speed': Retrieved counter: 5704.56 pulses/min
[D][sensor:126]: 'Fan Speed': Sending state 2852.28174 RPM with 2 decimals of accuracy
[D][pulse_counter:174]: 'Fan Speed': Retrieved counter: 12396.00 pulses/min
[D][sensor:126]: 'Fan Speed': Sending state 6198.00000 RPM with 2 decimals of accuracy
[D][pulse_counter:174]: 'Fan Speed': Retrieved counter: 11397.72 pulses/min
[D][sensor:126]: 'Fan Speed': Sending state 5698.86035 RPM with 2 decimals of accuracy
[D][pulse_counter:174]: 'Fan Speed': Retrieved counter: 11978.40 pulses/min
[D][sensor:126]: 'Fan Speed': Sending state 5989.19775 RPM with 2 decimals of accuracy
[D][pulse_counter:174]: 'Fan Speed': Retrieved counter: 11604.00 pulses/min
[D][sensor:126]: 'Fan Speed': Sending state 5802.00000 RPM with 2 decimals of accuracy
The other issue I have is that when I set the fan to off / 0, it still keeps spinning. Any idea what the issue could be? I tried playing around with the “min_power”, but that doesn’t seem to help.
I have the fan connected to a 12v power supply, while the D1 mini gets it’s power via USB. I have the GND’s of the 2 power sources wired to eachother.