It turns out, the PWM control of a fan from an ESP32 is a bit more difficult than just turning a 2 wire fan on or off (or even controlling the speed on a 2 wire fan). PWM fans should be more efficient than switching a MOSFET to control a 2 wire fan though. What I've run into are several problems related to the PWM and tach for a 4 wire fan, controlled from an ESP32. These problems (that I know of so far) are the following:
1. Not all PWM fans shut off completely based on the PWM signal alone.
2. The tach readings can be off by quite a bit.
3. On one of my fans, I noticed that there was a small current backfeeding through the tach line, with the fan's ground disconnected.
I am no electronics expert, but here is what I did to work through each of these issues. For the first problem of the PWM signal not fully shutting down a fan, that seems like a known aspect of how PWM fans operate. I learned that most fans will not fully turn off based on a zero duty cycle PWM signal, and will continue to run at some very low speed instead. There is probably a reason why most of the Arduino or ESP32 fan control tutorials use Noctura fans too. It's because most Noctura fans do actually shut off completely when the PWM goes to a zeroed out duty cycle, so they're almost like a cheat code if using fans with ESP32's or Arduinos. I think if I were able to use a Noctura fan for this project, I'd just do that and save myself some headaches. But I need to use an Arctic 8038 12v fan for the exhuast system, and it does not fully shut off when the PWM signal goes to zero.
I decided to use an n-channel MOSFET board to control the fan's ground (low side switch), and add a control pin to the ESP32 to cut the fan's ground when it was "off" according to the program. This is not the best fix, since I learned that fans are tricky, and can suck power from other places if they really want to. While the MOSFET worked on my Arctic 8038 fan to shut it down, it did not work on another 120mm fan I used to bench test the setup. I use a 120mm fan to test since the 8030 is a scary finger eating monster at 10k, while the 120mm fan is relatively a kitten at full speed. The 120mm fan however was pulling a small current through the tach line, which was resolved when the tach line was cleaned up a bit in the next part.
https://www.paulkeeble.co.uk/posts/tachometer/
I followed that post and added a similar resistor network as follows:
12v ---- 4.7kohm ----- TACH pin from fan ----10Kohm ----- GPIO 7 (tach read pin pn ESP32) ---- 4.7kohm ---- GND
The tach values still bounce a bit, but they are very close to what I expected, and reasonably stable.
Finally, the last issue was the tach line backfeeding on the 120mm bench testing fan, which was also solved by adding the resistor divider network, so two birds with one stone there. Here is an image of the backfeeding current before the resistor divider network was added. This is with the fan ground disconnected (via the n-channel mosfet cutting the fan ground), and zero pwm signal being sent to the fan. The fan in this test should have been off but was spinning slowly. In this config, the tach line was connected to the ESP32 on GPIO 7, and there was a 10kOhm resistor to 5v as a pull up so the tach signal can be read by the ESP32. The ESP was registering 0 RPM as displayed on the OLED in the background (it did show an rpm value when it should be on high or low, but not when "off", though the fan did still spin slowly when "off"). The fan was pulling just a tiny current from the ESP32 while spinning slowly, though it did show the max was 27.4mA! (which I didn't actually catch when it happened so I'm not really sure about that value). In any case not good. In contrast, the 8038 monster fan which I intend to use for the project was only showing 0.0003mA (so nothing), when I ran this same test. I think this would have been OK in the specific case of using the 8038 fan, but not so great in the general case of just using any PWM fan.
I didn't re-test this setup after the resistor divider network was added, but the 120mm fan stops when it should be off now (and that is with the MOSFET cutting the fan ground when "off", along with zero PWM signal).
Again though, I'm no electronics expert, I'm just working my way though the problems as I see them with this project, and thought I'd share what I've done so far. Do your own research, and use your best judgement if you try anything similar.


































































RSS Feed