Oct 07

Reading fan tacho with Arduino

3 wire fans are commonly found in computers such as CPU coolers, PSU fans, etc. If you have a spare one laying around, here is a quick and fun experiment to try.  The three wires consists of (usually) red (positive), black (negative) and tacho (yellow). Some fans will have a white tacho wire, it seems to depend on what colour the factories happen to have on hand at the time.


Left: 40MM fan with yellow tacho wire. Right: 120MM fan with white tacho wire.


The tacho output is triggered twice per revolution, so on the ‘scope we see:


To read the fan RPM with the Arduino, hook the fan up to a appropriate external power supply, usually 12 volts.

What I have done is setup two interrupts, one to count the pulses from the fan tacho wire, the other one calculates the RPM. To count the pulses, connect the fan tacho lead to digial pin two on the Arduino via a 10K pull up resistor, in this example, I use the attachInterrupt call which takes three parameters:

  1. Set which interrupt pin to use, ’0′ (pin 2) or ’1′ (pin 3).
  2. The function to call
  3. The condition to trigger the interrupt, in this case on a RISING signal.

The source code for the Arduino:


volatile int counter = 0;
volatile int result = 0;
volatile int led = 13;
void setup() {
 TCCR1A = 0;
 TCCR1B = 0;
 TCNT1 = 0;
 OCR1A = 15624; //(16*10^6) / (1024 * 1) -1
 TCCR1B |= (1 << WGM12);
 TCCR1B |= (1 << CS12) | (1 >> CS10);
 TIMSK1 |= (1 << OCIE1A);
 pinMode(led, OUTPUT);
 result = (counter / 2) * 60;
 counter = 0;
void rpm() {
void loop() {


The results are simply printed to the serial line which can be viewed using the serial monitor option in the Arduino IDE, but you could attach an LCD display or log the data, etc. For an fuller explanation of how to program the timers, see the links below.



Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>