Tachometer Using Arduino and Hall Effect Sensor

Introduction to Tachometer

In this project we will make a tachometer using Arduino. It is a device which is used to measure the RPM (revolution per minutes) of rotating objects like a shafts or wheels etc. This project differ from other projects present around web as it uses a Hall Effect sensor rather an IR LED  sensor which means it can be used in any prevailing ambient conditions.


  • Hall Effect Sensor
  • Arduino Uno
  • Rotating Shaft (Who’s RPM to be measured)
  • Small magnet
  • Connecting wires

Let us first start with the principle of a Hall Effect sensor. Click on link to learn about Halls Effect sensor and working.

NOTE: This tutorial makes use of the Timer Interrupts of Arduino Uno defined in previous article to measure the RPM more precisely and accurately rather than other prevailing methods present. If you are not familiar with this concept than check out that article first.


The setup for making this project is very simple.

  • A small magnet is placed (fixed) on the shaft/wheel whose RPM is to be measured.
  • The detector of Hall Sensor placed in the proximity of the shaft (perpendicular to axis of shaft).
  • Hookup the Vcc and Gnd pin of the hall sensor to Arduino’s 5V and Gnd respectively using jumpers.
  • We will use the Timer0 of Arduino Uno for this project, so, after connecting Vcc and Gnd pin of the Sensor connect its output pin to the pin 2 of Uno for readings.

The setup to measure shaft RPM is shown in figure below:

Techometer using Arduino and Hall effect sensor using interrupts of microcontroller. (Circuit Configuration)
Figure: Techometer Circuit Configuration


int hallsensor = 2;                // Hall sensor at pin 2

volatile byte counter;

unsigned int rpm;

unsigned long passedtime;

void isr()


   //Each rotation, this interrupt function is run twice, so take that into consideration for

   //calculating RPM

   //Update count


void setup()


   //Intiates Serial communications

   attachInterrupt(0, isr, RISING); //Interrupts are called on Rise of Input

   pinMode(hallsensor, INPUT); //Sets hallsensor as input

   counter = 0;

   rpm = 0;

   passedtime = 0; //Initialise the values

 void loop()
   delay(1000);//Update RPM every second

   detachInterrupt(0); //Interrupts are disabled

   rpm = 60*1000/(millis() - passedtime)*counter;

   passedtime = millis();

   counter = 0;


   Serial.println(rpm); //Print out result to monitor

   attachInterrupt(0, isr, RISING);   //Restart the interrupt processing



Most of the code is clear from the comments mentioned.


The code as mentioned above makes use of the Arduino Interrupts. Now as we know the Interrupts execute a set of instruction when called no matter what the Arduino was doing before. Here, Interrupts are called when the magnet passes through the detector.

We use Interrupts here to count the number of times the Hall sensor detects the magnet. Whenever there is a hike in Input pin the Interrupt routine (ISR function) named as “isr” is called which increment the counter value and thus makes a count.

Use of Interrupts increases the accuracy of reading as Interrupt is called every time the magnet passes and Uno counts it this is different from other methods in which the Arduino has to wait for whole code to be finished before getting back to read the Sensor reading again and if the code is large due some other reasons the reliability of the reading decreases drastically.

The Interrupts in Arduino Uno are initiated or called on either using Falling, Rising or Logic type. In our Program we have used the Rising type Interrupt initiator; Rising type calls the Interrupt every time the detector pin detects a rise in input from LOW to HIGH.

If you are using an IR LED based sensor you can also use Falling type, in this case the Interrupt will be called every time the detector pin detects a fall in the input i.e. from HIGH to LOW.

Another thing to note is the formula for the rpm calculation; it is based on simple math and unitary method to calculate number of revolution made by the shaft-

 i.e. RPM= No. of counts / Time taken to count

Time taken to count will be measured through millis function of Arduino. Study complete article about millis function here.

Delay Function:

The delay(1000) is used in the code it determine after how much time the value to be changed on your display, you can set it according to your needs.

The display device used in this tutorial is the Serial Monitor of the Arduino itself; instead of this you can also use 16*2 LCD or LED shields to display the RPM values using the respective libraries and hardware.


The value obtained from this project can further be used for measuring the speed of the wheel/disc to which the shaft is connected using the relation-(3.14*D*N)/60 here, D is diameter of the wheel/disc and N is the RPM. This relation will give the speed in m/s. This speed further can be converted to Kmph or Mph.

The value obtained can also be used in positioning of some other components relative to shaft or for feedback and control.


Feel Free to contact us, comment below and provide us with your feedback to improve our services. Like our facebook page for more posts.

Ankit Negi

I am an electrical engineering student and a youtuber. My YouTube channel THE-ELECTRONIC-GUY is dedicated to electronics and all. I am an avid publisher, I write technical articles and make electronic projects regularly.

What do you think?