Use a PC Fan as a Sensor

Use a PC Fan as a Sensor © GPL3+

Did you know that a standard three-wire PC Fan can be used as a sensor?

  • 48,805 views
  • 22 comments
  • 100 respects

Components and supplies

Apps and online services

About this project

Introduction

I recently built a device that had to monitor air flow in a vent and turn a booster fan on and off. The device was fairly straightforward. I used an ATmega328, a relay, a 12-volt power supply coupled to a 5-volt regulator, a couple of DS18B20's to monitor temperature and some LEDs. The question was, how to detect the airflow?

I once had to use a small fan to keep a power supply cool for 9W LEDs. I connected the fan through the microcontroller to turn it on and off when the temperature rose to a certain level. In addition to controlling the fan, I also decided to monitor the fan speed. Why not? I had an extra port! Later, when faced with the challenge of detecting air flow, I decided to pull the code from this project and tried using the fan as a sensor (without powering the blades).

Basic Fan Anatomy

PC fans come in three basic arrangements, two-wire, three-wire and four-wire. The two wire fans are for basic on and off. The three-wire fan has a third wire to receive a pulse from a hall-effect sensor. This sensor allows the rotational speed of the fan to be measured. The four-wire fan has an additional wire to control fan speed using PWM.

For use as a sensor, the three-wire fan is ideal. As the fan turns, a pulse can be read from between ground and the third wire (typically it is the wire that is not red or black). The pulse comes from a built in sensor, a hall-effect sensor, that measures the rotation of the magnets in the motor.

PC Fans are brushless motors and work differently than standard motors. See http://electronics.howstuffworks.com/brushless-motor.htm  for a description of brushless motors. 

Wiring

To wire the fan, the black wire is connected to ground on your circuit while the yellow wire is connected to the Arduino pin. A 10K pull-up resistor is needed between the sensor wire and the voltage supply. I use a 5-volt supply since I am connecting this to an Uno, but a 3.3V source works as well.

I added a push button switch to the test circuit shown above to allow power to be supplied to the fan when you choose. This makes testing the connection a little easier. In the above circuit, you can spin the fan manually or push the button to get a reading from the library.

The key thing to keep in mind here is that the fan is being used without power. Something else will push the blades (some type of external air flow) and the fan is used to detect or measure the air flow. 

Library

To measure the pulse on an Arduino, I use the pulseIn() function and measure the time between a series of pulses. The code for this is included in the GitHub repository located at the bottom of the article. The project also has a sample sketch attached for using the library.

To use the library, first create an instance of the FanMonitor class.

// *** 
// *** Define the FanMonitor instance to monitor 
// *** the 3-wire fan. 
// *** 
FanMonitor _fanMonitor = FanMonitor(FAN_MONITOR_PIN, FAN_TYPE_BIPOLE); 

Next, initialize the instance in the setup().

// *** 
// *** Initialize the fan monitor. 
// *** 
_fanMonitor.begin(); 

Finally, call getSpeed() whenever you want to measure the speed of the fan.

// *** 
// *** Get the fan speed. 
// *** 
uint16_t rpm = _fanMonitor.getSpeed();
// *** 
// *** Print the speed to the serial port. 
// *** 
Serial.print("Speed = "); Serial.print(rpm); Serial.println(" RPM"); 

I tested a few fans a found that some of them will pulse without power and some will not. I have not determined what makes them behave differently. To use a fan as a sensor, you may need to try a few different types of fans.

If you are reading this, and you are an expert on fans (or maybe you just know a lot about them) and can explain why some work without power and some do not, please leave a comment.

Uses

In my application, the fan worked great to sense air flow. I am not sure how many uses there are for using a PC Fan as a sensor, but if you need to detect or measure air flow, this is a great way to do it.

My Fan

The fan I used in my actual project was a fan from ADDA Corporation. The model number is AD0912HS-A76GL. This fan provides a pulse without supplying power to the fan. The datasheet is found at http://www.addausa.com/specifications/92-120.pdf. The fan can still be purchased on line at several places.

Code

Sample SketchArduino
#include <Arduino.h>
#include "FanMonitor.h"

// ***
// *** Pins
// ***
#define FAN_MONITOR_PIN 5

// ***
// *** Define the FanMonitor instance to monitor
// *** the 3-wire fan.
// ***
FanMonitor _fanMonitor = FanMonitor(FAN_MONITOR_PIN, FAN_TYPE_BIPOLE);

void setup()
{
  // ***
  // *** Initialize the serial port.
  // ***
  Serial.begin(115200);

  // ***
  // *** Initialize the fan monitor.
  // ***
  _fanMonitor.begin();
}

void loop()
{
  // ***
  // *** Get the fan speed.
  // ***
  uint16_t rpm = _fanMonitor.getSpeed();

  // ***
  // *** Print the speed to the serial port.
  // ***
  Serial.print("Speed = "); Serial.print(rpm); Serial.println(" RPM");
  
  // ***
  // *** Delay 1 second.
  // ***
  delay(1000);
}

Schematics

Fritzing
PC_Fan_Sensor.fzz

Comments

Similar projects you might like

Portable Arduino Temp/Humidity Sensor with LCD

Project tutorial by ThothLoki

  • 153,291 views
  • 115 comments
  • 185 respects

Distance Sensor and OLED

Project tutorial by javier muñoz sáez

  • 22,053 views
  • 22 comments
  • 65 respects

Complete Digital Clock Including Alarm and Motion Sensor

Project tutorial by LAGSILVA

  • 12,677 views
  • 11 comments
  • 50 respects

Simple Programmable Robotic Arm

Project showcase by Ryan Chan

  • 49,015 views
  • 63 comments
  • 145 respects

Smoke Detection using MQ-2 Gas Sensor

by Aritro Mukherjee

  • 213,110 views
  • 36 comments
  • 133 respects
Add projectSign up / Login