Introduction: Arduino Uno Fan Control

About: I work as a Product Marketing Engineer at NI. In my free time, I love tinkering and finding creative ways to solve everyday problems.

This project allows users to control two different fans and a servo. The fans will automatically turn on if a certain temperature is reached and the servo will turn 90 degrees. A push button also allows for manual control of the fans. Once the button is pushed, the fans will turn on one at a time each time you knock,(recorded by a piezometer) once you knock three times the fans will turn back off.

This project is meant to be used to regulate the heat of electronics in an entertainment center. The servo can be placed in a way that it opens a door to allow extra airflow when temperatures are high.

Step 1: Materials

1) Temperature sensor [TMP36] (250 mV output at 25°C)

2) Piezo capsule [PKM17EPP-4001-B0]

3) Resistors (one 10KΩ resistor, three 220Ω resistors, and one 1MΩ)

4) Small servo motor

5) Two standard computer fans

6) Breadboard

7) Three LED's (one red, one green, one yellow)

8) Tactile switch

9) 100 uF electrolytic capacitor

10) Arduino / Genuino Uno

Step 2: Setup

Connect power and ground to both sides of the breadboard. Place the pushbutton on the breadboard and connect one end to the 5V. On the other side of the switch, connect to ground through a 10-kilohm resistor. Connect this junction to digital pin 7 on the Arduino.

Next step is to attach your piezo, first attach the wires from the piezo to the breadboard. Attach one wire to power and wire the other end of the piezo to Analog pin 0(A0). Place a 1-megaohm resistor between the ground and the other wire. Lower resistor values will make the piezo less sensitive to vibrations.

Wire up the LEDs, connecting the cathodes (short leg) to ground and placing a 220-ohm resistor in series with the anodes. Through their respective resistors, connect the red LED to Arduino digital pin 2, the yellow LED to digital pin 3, and the green pin to digital pin 4.

Insert the male headers into the 3 or 4 female sockets on the servo motor and the fans(see figure above for fan pin instructions). For the servo connect the red wire to power, and the black wire to ground. Place a 100uF electrolytic capacitor across power and ground to smooth out any irregularities in voltage. Connect the servo's data wire to pin 9 on your Arduino. Repeat this procedure for each of the 2 fans connecting the data wire of one to pin 10 and the other to pin 11.

Place the TMP26 on the breadboard with the rounded part facing away from the Arduino(the order of the pins is important!). Connect the left pin of the flat facing side to power, and the right pin to ground. Connect the center pin to Analog pin 1(A1).

Step 3: Arduino Code

From the temperature sensors datasheet, I found that every 10 millivolts of change from the sensor are equivalent to 1 degree Celsius. If you take the voltage, subtract 0.5, and multiply it by 100, you get the accurate temperature in degrees Celsius.

You can download the code by clicking on the "fan_control" file below. Once downloaded you will be able to change the temperature at which the fans are activated by changing the "baselineTemp" constant. You can also change what sort of knocking intensity that triggers your function by adjusting the "quietKnock" and "loudKnock" constants. Be careful though because if your "quietKnock" value is too low, your fans might trigger your function.

Once you have changed the code to your preference, press the upload button, and you're done! Let me know if you have any questions or if you have changes you would like to make.

Raspberry Pi Contest 2016

Participated in the
Raspberry Pi Contest 2016