Fan Controller

Preface

Very Short Summary:

The fan controller described on this project page, controls one or more PWM controlled 12V PC fans. It uses the input from two precise DHT22 based temperature sensors. The MCU is an Arduino Uno, which is powered using a 12V power source. On top of the Arduino Uno, there is the Adafruit data logger shield — and on top of that is an Adafruit LCD shield. The software is a simple, custom written PID controller.

Recently I had the problem some expensive components did overheat in my server rack. The ventilation was not optimal and I had to install additional fans. Because this rack is in my office and I like a quiet working place, the ventilation had to be as quiet as possible.

First I thought about buying a off-the-shelf product, but then I realised: If this controller does not work as I expect and the fans will spin too fast/loud, this will drive me crazy over time. So I decided to build a own fan controller. A very simple one, where I can write own code and tweak it until it runs as I like.

This project page describes how I built this particular controller. It is not meant you really reproduce this same controller exactly as shown, but maybe understand some basic principles to build your own controller.

For the start, here a photo of the final controller, without the case. You can see the display, with custom characters, the power wire on the left, two sensor wires on the right and one wire for where the fans and the PWM signal is connected. You can also see the SD card on the left side, where all values are recoded.

Fan Controller

Used Parts

  • Arduino Uno
    I am using an original Arduino Uno revision 3 board with the ATmega328P chip on it. I have chosen this board because it can be powered with a 12V power supply which is required for the fans. Also I had already the two shields, which were only compatible with the Arduino Uno.
  • PWM Controlled PC Fan
    For my setup I use two very quiet Noctua 80cm NF-A8 PWM fans. They are very powerful but almost make no audible noise. They especially keep that quite over their lifetime. Using the PWM input I can control the speed of the fans very precisely.
  • Adafruit Data Logger Shield
    This shield contains a RTC (real time clock) and a slot for a SD card. There is also a level converter which provides the required 3.3V for the SD card. It also contains a prototyping area, where I added required components and sockets.
  • Adafruit LCD Shield
    A very comfortable LCD shield which can be accessed over I²C. It shares this bus with the RTC. Beside of the display, there are also a number of handy buttons which can also be accessed over the same I²C bus.
  • DHT22 Temperature and Humidity Sensors
    I used this sensors for many other projects. They are not cheap, but quite precise. The only downside is the very slow readout, but for this project absolute no obstacle.
  • A reliable 12V power supply
    With enough power for the fans and the display.
  • Wires, resistors, sockets and plugs.
    For the fans, there were additional cables with many sockets and plugs in the package. I used them to solder a short cable with the default four pin socket to the board. So any PC fan could be connected. For the sensors I soldered two simple four pin male headers to the board, so I could easily plug-in the sensors.

The Hardware

The hardware for this project is very simple, because it mainly consists of off-the-shelf components.

At the bottom of the stack is a Arduino Uno. I have chosen this board because it can be powered with a 12V power supply which is required for the fans. Also I had already the two shields, which were only compatible with the Arduino Uno.

Fan Controller

On top of the microcontroller, I added the Adafruit data logger shield.

Fan Controller

In the prototyping area of this shield I added two sockets with four pins for the temperature sensors. I also connected the wire which ends in another four pin socket to power the fans.

Fan Controller

The bottom side of the prototype area is used to connect the different wires and components.

Fan Controller

The schema for the fan controller is pretty simple:

Fan Controller Schema

Please note the RTC and display are not visible in the schema. They are connected via I²C on the SDA and SCL pins.

The Software

To use the software, you will need the Arduino IDE, version 1.6.12 or newer. First you need to install the Adafruit RGBLCDShield and RTClib library. Both from Adafruit. You will find instructions how to install these libraries on the product pages for the Adafruit Data Logger Shield and Adafruit LCD Shield.

You will find my software on GitHub here:

  • https://github.com/LuckyResistor/FanController

Epilogue

I hope you enjoyed the description of this simple project. If you have questions, suggestions or corrections do not hesitate and either leave a comment or write a message. Also leave a link if you created a own project inspired from this page.

17 thoughts on “Fan Controller”

    1. These are pull-up resistors for the sensor data line. You can omit them, there are already pull-up resistors in the MCU which are used. I added them to be able to do measurements if the shield is disconnected from the Arduino Uno board.

    1. I use the data logger to record all temperature values and the fan speed over time. The values are recorded in a simple comma separated text file on the SD card. For my project, the temperature sensors are placed near very temperature sensitive components, so if I get troubles with these components I can check the log and see of the temperature was too high at some point in time.

      A few weeks ago, I checked the logs for the first half year and analysed the data. I was especially interested how well the PID controller works. In this case, the PID controller worked perfectly and the temperature was very stable over the whole time period.

  1. Nice project. I see that you have no check at the moment for valid temp values coming from the DHT sensors. Because of the bit-banging method Adafruit uses, there can be two kind of errors coming back as a result. First a nan (not a number), but this seldom happens, but more frequently, the result is a signed value of all digital 1’s (7FFFFFFF or 2147483647). This is equivalent (but not the cause) of having no power to the device. This can happen dozens of times per 24hrs. I don’t know what the pid code does with that anomaly, but in my code, I always check and discard readings of nan or values in excess of 100.

    1. Thank you for this additional information. Indeed, I do no range check for the values. The PID controller as configured reacts very slowly. I never had any of the misreadings you describe, but even if they happen from time to time, they will not have a great influence on the controller.

      I already checked the log, with raw values from more than a half year. Here I had no single misread from the sensor.

      Nevertheless, I agree with you, adding a range check would absolutely make sense.

  2. Where can I find the library needed for this project? Specifically the program code?

    1. Hi Austin, you find the whole code of the fan controller on GitHub. A link to the software is in the section “The Software” of the article. There you also find links to the used shields. On these pages are detailed instructions how to install the required libraries. Basically you can follow the guide here: https://learn.adafruit.com/adafruit-arduino-ide-setup/arduino-1-dot-6-x-ide See section “Add the Adafruit Board Support package!”. After this you can use “Manage Libraries…” to install all required libraries for the project. Make sure you use the latest version of the Arduino IDE.

  3. Just about what I was searching for to give a nominally fanless PC a bit extra cooling when needed. Do I read the diagram correctly in that neither datalogger nor LCD are actually needed to control the fans? And would it then work with a Micro or Nano, too?

    1. Yes, you read this correctly. I recommend you remove the display and SD libraries and code parts in this case. They need a lot of flash memory.
      You also might need to adjust the parameters a bit for your case, so make sure you have the serial output for testing.

      1. Thanks for the reply even if my discovery of the Arctic Pro fans just pretty much mooted the plan.

      2. Sure, if you just need a temperature controlled fan, there are plenty simpler solutions. 🙂 As I wrote in my article, the goal of the project is to create something completely under my control. So I can play with it and change the algorithm as I like.
        If you like to buy something working, there are plenty PC case fan controllers out there, even with fancy temperature displays. 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: