Reading DC fan RPM with Arduino

reading dc fan rpm using internal hall effect sensor with arduino

Reading DC Fan RPM (Revolutions per minute or Rotation per minute) is very easy than we think, yes because DC fan internally contains Hall Effect sensor, So we need to count the output pulse from the Hall Effect sensor that’s it.

Lets start with Pinout of DC fan, 3 wire and 4 wire DC fan available in the market you can choose any one of them.

3 Wire DC FAN

In this tutorial I have used three wire 12V DC fan (D60SH-12) from yateloon Electronics.

3 wire dc fan rpm reading

This Fan internally contains a small Hall-Effect sensor to aware how fast the fan blades are rotating. Here we can use this sensor output and Interface with Arduino to serially print RPM value. It has Red wire for +Vcc, and black for Ground supply finally the Yellow gives signal output. Pull up resistor gives strength to the signal and may connected to external micro-controller.


4 Wire DC FAN

4 wire dc fan rpm reading


As like 3 wire DC fan this is also contains hall effect sensor and has 4 wires, Red for +Vcc, black for Gnd, Yellow/White for signal output from Hall sensor and Blue for PWM signal viz we can control speed of fan by varying PWM signal.


Component Requirements

setup rpm reading arduino

To make it possible you need Arduino Board (UNO, Genuino, mega, etc..,any one you have), Subject DC fan make sure it contains internal hall effect sensor, 9V Battery with clip to give separate bias to Fan, a 560Ω  Resistor, and Connecting wires.

Arduino DC fan Hookup

reading DC fan rpm arduino

Connect 560Ω Resistor in 3.3 V bias of Arduino board and connect Resistors another end to Fan signal pin (yellow wire) & Arduino Digital pin D2 together. Connect battery to DC Fan and bring common ground to Arduino board as shown in image. Connect the battery clip to the battery after uploading following sketch.

Schematic Diagram

reading dc fan rpm arduino schematic

Just given for details, Schematic represents same connections as in the Arduino DC fan Hookup image.

Arduino Sketch


//project done by
//code by Crenn from  thank you!
//Varibles used for calculations
int NbTopsFan; int Calc;
//The pin location of the sensor
int hallsensor = 2; typedef struct{
//Defines the structure for multiple fans and 
//their dividers 
char fantype;
unsigned int fandiv; }fanspec;
//Definitions of the fans
//This is the varible used to select the fan and it's divider,
//set 1 for unipole hall effect sensor
//and 2 for bipole hall effect sensor
fanspec fanspace[3]={{0,1},{1,2},{2,8}}; char fan = 1;
void rpm ()
//This is the function that the interupt calls
{ NbTopsFan++; }
//This is the setup function where the serial port is initialised,
//and the interrupt is attached
void setup()
{ pinMode(hallsensor, INPUT);
attachInterrupt(0, rpm, RISING); }
void loop ()
//Set NbTops to 0 ready for calculations
{ NbTopsFan = 0;
//Enables interrupts
//Wait 1 second
delay (1000);
//Disable interrupts
//Times NbTopsFan (which is apprioxiamately the fequency the fan 
//is spinning at) by 60 seconds before dividing by the fan's divider
Calc = ((NbTopsFan * 60)/fanspace[fan].fandiv);
//Prints the number calculated above
Serial.print (Calc, DEC);
//Prints " rpm" and a new line
Serial.print (" rpm\r\n");

Check the fan speed (RPM) after uploading Sketch and hardware connection. Just open Serial Monitor in Arduino IDE and you can see the RPM reading. It may ± 1 % tolerance output than actual RPM.


DC fan rpm prototype fan rpm serial monitor


  1. aliyarov February 18, 2017 Reply
  2. ray October 10, 2017 Reply
    • Steve April 17, 2018 Reply
  3. Paul January 3, 2018 Reply
    • ed November 6, 2020 Reply
  4. Milad January 4, 2018 Reply
  5. Zouhir July 9, 2018 Reply
  6. Beszczelny August 4, 2018 Reply
  7. john April 9, 2019 Reply

Add a Comment

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