ESP8266 COOLING FAN CONTROL
Here is a solution how to control cooling fan speed with ESP8266/Arduino etc.
The easiest way for me is to use a MOSFET.
As we know the following MOSFETS could be controlled by 3.3V logic of ESP8266:
IRLZ34NPBF (55V, 27A) - 11.29V at 1023(full open)
IRLZ44NPBF (55V, 47A) - 11.36V at 1023(full open)
IRL510PBF (100V, 5.6A) - 11.14V at 1023(full open)
The following diagram shall help you to assemble the hardware and you can control speed of the fan by PWM simple command in Arduino IDE - analogWrite(FanPin,FanSpeed);
Example - analogWrite(D8,1024); //Full speed

Everything cool BUT... when we try do downspeed the fan a high frequency noise appears. It is because of PWM frequency - fan motor makes sound from the PWM ;)
How to eliminate the noise? I dug the internet and found many solution but only mix of them worked for me.
So the only solution which woks for me is to change PWM frequency.
To change PWM frequency you shall use Aduino IDE command analogWriteFreq(Hz);
I found that the best frequency for my fan is 15kHz - 15000Hz
Also I found that PWM controlling range 0-1024 moves closer to 1024. I mean that using 100,200,300,400 in PWM command will not give you any result. Range starts approx from 600 - it is also because my fan shall start from approx 6 volts. So I found usable to use new PWM range - analogWriteRange(range);
So I put two commands into setup section:
analogWriteFreq(15000);
analogWriteRange(100);
and now I can control the speed of my fan without any noise by sending commands like analogWrite(D8,100);
Don't forget that PWM controlling range now 0-100, so the command shall looks not like analogWrite(D8,1024) but analogWrite(D8,100).
Have fun ;)
The easiest way for me is to use a MOSFET.
As we know the following MOSFETS could be controlled by 3.3V logic of ESP8266:
IRLZ34NPBF (55V, 27A) - 11.29V at 1023(full open)
IRLZ44NPBF (55V, 47A) - 11.36V at 1023(full open)
IRL510PBF (100V, 5.6A) - 11.14V at 1023(full open)
The following diagram shall help you to assemble the hardware and you can control speed of the fan by PWM simple command in Arduino IDE - analogWrite(FanPin,FanSpeed);
Example - analogWrite(D8,1024); //Full speed

Everything cool BUT... when we try do downspeed the fan a high frequency noise appears. It is because of PWM frequency - fan motor makes sound from the PWM ;)
How to eliminate the noise? I dug the internet and found many solution but only mix of them worked for me.
So the only solution which woks for me is to change PWM frequency.
To change PWM frequency you shall use Aduino IDE command analogWriteFreq(Hz);
I found that the best frequency for my fan is 15kHz - 15000Hz
Also I found that PWM controlling range 0-1024 moves closer to 1024. I mean that using 100,200,300,400 in PWM command will not give you any result. Range starts approx from 600 - it is also because my fan shall start from approx 6 volts. So I found usable to use new PWM range - analogWriteRange(range);
So I put two commands into setup section:
analogWriteFreq(15000);
analogWriteRange(100);
and now I can control the speed of my fan without any noise by sending commands like analogWrite(D8,100);
Don't forget that PWM controlling range now 0-100, so the command shall looks not like analogWrite(D8,1024) but analogWrite(D8,100).
Have fun ;)