0% found this document useful (0 votes)
76 views14 pages

Arduino IR Tachometer Project Guide

The document describes a project for creating a tachometer using an Arduino UNO and an IR sensor, which counts revolutions and displays RPM on an OLED screen. It outlines the working mechanism, required components, circuit connections, and provides a detailed program code with explanations. This project is applicable in various fields such as automotive and industrial machinery for monitoring rotational speed.

Uploaded by

benjaminkatiyo76
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views14 pages

Arduino IR Tachometer Project Guide

The document describes a project for creating a tachometer using an Arduino UNO and an IR sensor, which counts revolutions and displays RPM on an OLED screen. It outlines the working mechanism, required components, circuit connections, and provides a detailed program code with explanations. This project is applicable in various fields such as automotive and industrial machinery for monitoring rotational speed.

Uploaded by

benjaminkatiyo76
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

eTechnophiles   Menu

Tachometer Using Arduino And IR Sensor


by Tejas Chavan

This is a simple yet effective RPM tachometer using Arduino UNO and an IR sensor.
It counts the revolutions of a rotating object using interrupts and displays the RPM
on an OLED screen. This adaptable tool is useful for controlling and monitoring
machines, making it an excellent addition to a variety of projects and industries.

Table of Contents

How does this tachometer work?


Components required
Introduction to IR sensor
Circuit diagram
Physical connections
Program/Code:
Program explanation
Conclusion

How does this tachometer work?

Given below are the series of steps this tachometer goes through to display the
motor speed.

1. Sensor setup: First, place an infrared sensor near a rotating product with a
reflecting marking or gaps. The IR sensor recognizes the marker as it passes in front
of it.

2. Interrupt handling: The Arduino board is set up to respond to falling edge


interrupts. When an interruption occurs, it increases a counter, effectively counting
half a revolution.

3. RPM calculation: To obtain the RPM (Revolutions Per Minute), this formula is
applied:

RPM = (Counter / 2) * 60

Here, the division by 2 stands for counting half-revolutions in the one-second


interval, and multiplying by 60 converts it to RPM.

4. Display update: The calculated RPM value is displayed on the OLED screen. The
display updates every second, giving real-time RPM readings.

5. Continuous monitoring: This process is repeated continuously and we get the


RPM of motors accurately.

Components required

Arduino Nano or Arduino Uno


IR Sensor
0.96 inch OLED Display
Introduction to IR sensor

An infrared sensor is an electronic device that emits light to detect an object in its
surroundings. An IR sensor can detect motion as well as measure the heat of an
object.

Typically, all objects in the infrared range emit some type of thermal radiation. These
radiations are undetectable to human eyes, but an infrared sensor can detect them.

The emitter is a simple infrared LED (Light Emitting Diode), while the detector is a
simple infrared photodiode. The photodiode is sensitive to infrared light of the same
wavelength as the IR LED.

When infrared light strikes a photodiode, the resistances and output voltages change
in response to the magnitude of the IR light.

Given below is the pinout of the IR sensor.

VCC: This is the power supply pin.


OUT: This is a 5V TTL logic output pin. LOW implies that no motion is
detected, and HIGH indicates that motion is detected.
GND: This is a ground pin.

Circuit diagram

OLED Pin Arduino Nano Pin

VCC 5V Pin

GND GND of Arduino Nano

SDA A4

SCL A5

OLED pins with Arduino Nano

IR Pin Arduino Nano Pin

VCC 5V Pin
GND GND of Arduino Nano

OUT D5

IR sensor with Arduino Nano

Physical connections

This is a physical connection image of this tachometer.

Program/Code:

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

const int IR_PIN = 5; // IR sensor input pin

volatile unsigned int counter = 0; // Counter variable for revolutions


unsigned long previousMillis = 0; // Variable to store previous time
unsigned int rpm = 0; // Variable to store RPM value

void IRinterrupt() {
counter++;
}

void setup() {
pinMode(IR_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(IR_PIN), IRinterrupt, FALLING);

[Link](SSD1306_SWITCHCAPVCC, 0x3C);
[Link]();
delay(2000);
[Link]();
[Link](2);
[Link](SSD1306_WHITE);
[Link](0, 0);
[Link]("TEG");
[Link]();
delay(2000);
[Link]();
[Link](2);
[Link](SSD1306_WHITE);
[Link](0, 0);
[Link]("Tachometer");
[Link]();
delay(2000);
}

void loop() {
unsigned long currentMillis = millis();

if (currentMillis - previousMillis >= 1000) {


detachInterrupt(digitalPinToInterrupt(IR_PIN));
rpm = (counter / 2) * 60; // Calculate RPM
counter = 0;
attachInterrupt(digitalPinToInterrupt(IR_PIN), IRinterrupt, FALLING);
previousMillis = currentMillis;

[Link]();
[Link](0, 0);
[Link]("RPM: ");
[Link](rpm);
[Link]();
}
}
Program explanation

Include Libraries:

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

These lines contain the libraries required for communication (Wire) and working with
the Adafruit SSD1306 OLED display.

Define Constants and Initialize Variables:

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

Here, a constant OLED_RESET is defined to specify the reset pin for the OLED
display. The Adafruit_SSD1306 object called display is created to interact with the
OLED screen.

const int IR_PIN = 2; // IR sensor input pin


volatile unsigned int counter = 0; // Counter variable for revolutions
unsigned long previousMillis = 0; // Variable to store previous time
unsigned int rpm = 0; // Variable to store RPM value

IR_PIN is a variable that stores the pin number to which the IR sensor is
connected.
Counter is a volatile variable that counts the number of revolutions detected
by the infrared sensor. It’s declared as volatile because it’s modified within an
interrupt service routine.
previousMillis is used to store the previous time for timing purposes.
The variable rpm is used to store the determined RPM value.

Interrupt Service Routine (ISR):

void IRinterrupt() {
counter++;
}
This is an interrupt service routine (ISR) that gets called whenever a falling edge is
detected on the IR sensor. It increments the counter variable, which keeps track of
the number of revolutions.

Setup Function:

void setup() {
pinMode(IR_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(IR_PIN), IRinterrupt, FALLING);

[Link](SSD1306_SWITCHCAPVCC, 0x3C);
[Link]();
delay(2000);
[Link]();
[Link](2);
[Link](SSD1306_WHITE);
[Link](0, 0);
[Link]("TEG");
[Link]();
delay(2000);
[Link]();
[Link](2);
[Link](SSD1306_WHITE);
[Link](0, 0);
[Link]("Tachometer");
[Link]();
delay(2000);
}

The setup function uses a pull-up resistor to initialise the IR sensor pin as an
input. It also attaches the IRinterrupt ISR to the falling edge of the IR sensor
input pin.
It then initializes and configures the OLED display, briefly displaying “TEG” and
“Tachometer” messages.

Loop Function:

void loop() {
unsigned long currentMillis = millis();

if (currentMillis - previousMillis >= 1000) {


detachInterrupt(digitalPinToInterrupt(IR_PIN));
rpm = (counter / 2) * 60; // Calculate RPM
counter = 0;
attachInterrupt(digitalPinToInterrupt(IR_PIN), IRinterrupt, FALLING);
previousMillis = currentMillis;
[Link]();
[Link](0, 0);
[Link]("RPM: ");
[Link](rpm);
[Link]();
}
}

In the loop function, the code checks if at least 1 second has passed since
the last RPM calculation using currentMillis – previousMillis >= 1000.
If a second has passed, it detaches the interrupt temporarily to prevent further
counts, calculates the RPM (assuming two counts per revolution), then
reattaches the interrupt.
The calculated RPM value is then displayed on the OLED display.

Conclusion

This project is made using an infrared (IR) sensor and an OLED display with Arduino
nano board. It counts the revolutions of a rotating object with an infrared (IR) sensor,
calculates the RPM (revolutions per minute), and displays the RPM value on an OLED
screen.

This project shows how to use Arduino microcontrollers to monitor and display
rotational speed, which can be used in a variety of fields such as automotive,
robotics, and industrial machinery maintenance.

Tejas Chavan

I am an electronics engineer with experience in firmware development and


embedded systems. My expertise involves creating embedded solutions,
utilizing communication protocols like UART, I2C, SPIetc. I have a proven
track record in national-level competitions, showcasing my proficiency in
embedded system design.

 ARDUINO, Electronics
 Kaiweets KM601 Smart Multimeter Review in 2025

 Flappy Bird Game Using ESP32 and Touch Button

8 thoughts on “Tachometer Using Arduino And IR Sensor”

Jeff Monegal
April 3, 2024 at 12:13 pm

Hi.

Well done mate but to enhance your project. Look at the model aircraft
sector. Measuring the speed of model glo plug engines is very important
especially with multi engine aircraft. An accurate taco is not only important
but very expensive. Glo engines can turn propellers at 40,000 rpm and more.
Petrol engines at 9000 and sometimes more. Drive shaft speeds on model
cars is also important.

If these speeds are within your taco’s limits then produce a neat looking unit
in a neat case. This would be a desirable item as long as your price is
reasonable.
Best of luck
Jeff.

Reply

Ankit Negi
April 5, 2024 at 11:13 am

Hi Jeff,

Thanks for your valuable insights! We’ll definitely consider your suggestions
for enhancing our project. But this is just a prototype project for learning.
Reply

Adrian
April 3, 2024 at 4:28 pm

Very interesting. I always wanted to complete an rpm visual unit to determine


the slot car speeds. I just did not have the time. I will try this in my spare
time and test it. Thanks. Keep up the good work. Simple things can amaze a
brilliant mind.

Reply

Ankit Negi
April 5, 2024 at 11:09 am

I’m glad you like this project. That’s great! Please give us an update when
you start working on it, and if you encounter any problems, we’re here to
help you out.

Reply

Segwabe Lekgatlhanye
August 24, 2024 at 3:05 am

Hello, where(supplier) can I buy this parts i will like to try the same project of
Tachometer Using Arduino And IR Sensor

Thanks
Reply

Ankit Negi
September 2, 2024 at 12:02 pm

Hi,
You are from which part of the world?

Reply

CB
December 7, 2024 at 8:12 am

Hello
I built the little project, the sketch uploaded nicely, the IR is responsive but
cannot get anything on OLED. I replaced and double checked the easy wiring,
I even exchanged breadboard to no avail. The Oled is good as I plugged it
into another project and it worked. It must be in the coding. Any suggestion?

Reply

Ankit Negi
December 8, 2024 at 12:37 pm

That’s odd. Are you using the same OLED display? If yes, to which pins your
OLED is connected to? Can you double check.
Reply

Leave a Comment

Name *

Email *

Website

Post Comment

Categories

Select Category

Disclaimer

This page might contain some affiliate Links as we are participant in the Amazon
Services LLC Associates Program. We may get compensation for each successful
purchase through our link.

Recent Posts

Soil Moisture Sensor with Arduino- Smart Plant Watering Project

Water Level Sensor with Arduino Tutorial- Rain detection Alarm

Sound Sensor with Arduino Tutorial – Music Reactive LEDs

Recent Comments

Peter liewkongyow on 10 Best Circuit Simulation Software- 2025(Free and Paid)

Kiran Dass on USB 2.0 vs 3.0 vs 3.1 – Know the Differences

Ankit Negi on Tachometer Using Arduino And IR Sensor

Home Write For Us Contact Us Privacy Policy Depositphotos

Copyright 2023 © eTechnophiles. All rights reserved

Common questions

Powered by AI

In the Arduino tachometer setup, the IR sensor detects the presence of an object by emitting and receiving infrared light. It identifies a rotating object's marker as it passes, triggering changes in resistance and output voltages . The sensor's output is connected to the Arduino, which counts the detection events as revolutions. The OLED display, initialized via the Adafruit_SSD1306 library, receives RPM values from the Arduino and displays them in real-time, updating every second with the calculated RPM .

The Arduino-based tachometer uses a falling edge interrupt to trigger an increment in a counter variable whenever a rotating object passes the IR sensor . This counter, which effectively counts half of a revolution due to its setup, is then used to calculate the RPM. By detaching and reattaching the interrupt within each second, the code calculates RPM using the formula: RPM = (Counter / 2) * 60. Here, the division by 2 represents counting half-revolutions, and multiplying by 60 converts this per-second count into RPM .

Continuous RPM monitoring in the Arduino tachometer project is achieved through a loop function that repeatedly checks the elapsed time since the last RPM calculation using the millis() function. The project calculates RPM once per second by detaching the interrupt to read the counter value, computing the RPM, and then reattaching the interrupt to continue counting. This cycle ensures uninterrupted and accurate real-time RPM data display on the OLED, critical for applications requiring consistent speed monitoring and adjustments to prevent equipment failures or inefficient operations .

An RPM tachometer using Arduino and IR sensor technology can be effectively applied in various industrial settings for monitoring and controlling machinery. It can be utilized in automotive industries to measure engine speeds, in robotics for motor speed monitoring, and in manufacturing for ensuring the operational efficiency of machinery by maintaining optimal rotational speeds. Its adaptability and real-time monitoring capabilities make it a valuable tool for preventive maintenance scheduling, thereby reducing machinery downtime and enhancing productivity .

The initialization process of the OLED display in the Arduino tachometer project involves setting up communication using the Adafruit_SSD1306 library. In the setup() function, the display is initialized with display.begin(SSD1306_SWITCHCAPVCC, 0x3C) to set the display parameters and start communication. Display text attributes like text size and color are configured subsequently, ensuring the display is ready to show information such as "TEG" and "Tachometer" during setup, which verifies correct operations before displaying RPM data .

The volatile keyword in the Arduino tachometer code is used to declare the counter variable. It indicates to the compiler that this variable can change unexpectedly, such as within an interrupt service routine (ISR). This prevents the compiler from optimizing code in a way that assumes the variable does not change outside of regular program flow, ensuring the counter accurately reflects the number of revolutions counted during interrupts .

A pull-up resistor is used in the Arduino tachometer project to ensure that the input pin connected to the IR sensor does not float between HIGH and LOW states when it is not actively being driven by a signal. This configuration is crucial in digital circuits like this one, as it guarantees a stable known state (HIGH) until the IR sensor emits a LOW signal during an interrupt event . This helps in accurately detecting interrupts without false triggering caused by floating pin states.

Arduino-based tachometers offer significant cost-effectiveness and accessibility advantages, especially for small-scale projects. By utilizing accessible components like IR sensors and OLED displays, these tachometers allow hobbyists and small enterprises to monitor machine speeds affordably without investing in expensive industrial-grade tachometers . The open-source nature of Arduino allows for customization and scalability, enabling users to adapt the design to specific needs, thus enhancing the accessibility of precise speed monitoring to a broader audience.

The RPM calculation formula in the Arduino tachometer project is derived based on counting half-revolutions over a one-second interval and then converting this count to a per-minute rate. The formula used is RPM = (Counter / 2) * 60. The division by 2 accounts for the fact that the code counts half-revolutions due to its setup with falling edge interrupts. Multiplying by 60 converts the result from per-second to per-minute, providing the RPM value, crucial for real-time motor speed monitoring .

Implementing this tachometer project may present challenges such as ensuring correct wiring and component connections, which can affect functionality as reported by user CB who faced issues with OLED display response despite checking the wiring and swapping components . Debugging might involve verifying code for logical errors, especially ensuring interrupts are configured correctly. Additionally, real-world deployment may require handling environmental factors like IR light interference or mechanical vibrations that could affect sensor accuracy and reliability.

You might also like