4-pin PWM fan controller with temperature sensor
In this project, I will show how to build a circuit with Arduino Uno that read the temperature via a sensor and control the speed of a 4-pin PWM fan. Also, some information are written on the LCD.
The project is fairly easy to build and the schematic view is uploaded here. Please see the right side of the page for downloads. The steps are:
1) LM35: In order to connect the LM35 temperature sensor to Uno, the middle pin is connected to Analog_A1 pin of the Uno. Looking at the flat black side of the sensor, the right pin is connected to GND and the left pin is connected to Vcc.(5V of the Uno)
2) LCD: the LCD has 16 pins which are numbered from 1 to 16 (left to right). There should be a potentiometer (actually the size is not important) to control the contrast of the LCD. Two sides pins (left and right) are connected to GND and 5V of Uno (order is not important) and the middle pin is connected to LCD. The connections are:
1 => GND
2 => 5V of Uno
3 => middle pin of the potentiometer (for contrast)
4 => Digital_12 of Uno
5 => GND
6 => Digital_11 of Uno
7 => no connect
8 => no connect
9 => no connect
10 => no connect
11 => Digital_5 of Uno
12 => Digital_4 of Uno
13 => Digital_3 of Uno
14 => Digital_2 of Uno
15 => to 5V of Uno via a resistor (for back light)
16 => GND
3) Fan: The fan is a 4-pin PWM brushless fan. The colors may be different but I found the correct wires.
black => GND
yellow => 5V of Uno
red => Digital_9 of Uno (the PWM signal)
blue => Digital_8 of Uno (sens signal for reading the RPM of the fan)
Done! you can read the code to see what is going on. I wrote a simple code with 2 ifs to show to control the speed. You can add more conditions if you want.
** Although the fan is small, due to the inertial property, you may notice that values smaller than 120 won't turn on the fan. That is not a problem. The code works and you can verify that by connecting an LED to Digital_9 (the PWM signal) to see how the LED blinks.
** If you have a bigger fan, it is not a good idea to drive it via Uno. Therefore, you have to connect the Digital_9 (PWM signal) to the base pin of a power transistor and amplify the current to drive the fan safely.