Fan Speed Measurement using IR Sensor & Arduino:
In this project, we have designed Digital Tachometer using an IR Sensor with Arduino for measuring the number of rotations of rotating fans in RPM. Simply we have interfaced IR sensor module with Arduino and 16*2 LCD module for display. The IR sensor module consists of IR Transmitter & Receiver in a single pair that can work a Digital Tachometer. So let’s learn about Fan Speed Measurement using IR Sensor & Arduino.
The tachometer is an RPM counter which counts the no. of rotation per minute. There are two types of tachometers one mechanical and another one is digital. Here we are going to design an Arduino-based digital tachometer using an IR sensor module to detect objects for count rotation of any rotating body. IR transmits IR rays which reflect back to the IR receiver and then IR Module generates an output or pulse which is detected by the Arduino controller when we press the start button. It counts continuously for 5 seconds.
Components Required
For designing Fan Speed Measurement Circuit using IR Sensor & Arduino we need the following components:
- Arduino UNO Board
- 16*2 LCD
- IR Sensor module
- Breadboard
- Connecting Jumper Wires
Circuit Diagram
IR Sensor Module
Introduction
An infrared sensor is an electronic instrument that is used to sense certain characteristics of its surroundings by either emitting and/or detecting infrared radiation. Infrared sensors are also capable of measuring the heat being emitted by an object and detecting motion.
The wavelength region which ranges from 0.75 to 3µm is known as the near-infrared region. The region between 3 and 6µm is known as the mid-infrared and infrared radiation which has a wavelength greater higher than 6µm is known as far-infrared.
An IR sensor consists of an IR LED and an IR Photodiode; together they are called Photo–Coupler or Opto–Coupler. As said before, the Infrared Obstacle Sensor has a built-in IR transmitter and IR receiver. An infrared Transmitter is a light-emitting diode (LED) that emits infrared radiation. Hence, they are called IR LEDs. Even though an IR LED looks like a normal LED, the radiation emitted by it is invisible to the human eye. Infrared receivers are also called infrared sensors as they detect the radiation from an IR transmitter. IR receivers come in the form of photodiodes and phototransistors. Infrared Photodiodes are different from normal photodiodes as they detect only infrared radiation. When the IR transmitter emits radiation, it reaches the object and some of the radiation reflects back to the IR receiver. Based on the intensity of the reception by the IR receiver, the output of the sensor is defined.
Features
- Operating Voltage: 3.0V – 5.0V
- Detection range: 2cm – 30cm (Adjustable using potentiometer)
- Current Consumption:at 3.3V : ~23 mA,at 5.0V: ~43 mA
- Active output level: Outputs Low logic level when an obstacle is detected
- Onboard Obstacle Detection LED indicator
Source Code/Program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#include<LiquidCrystal.h> LiquidCrystal lcd(12,11,10,9,8,7); float value=0; float rev=0; int rpm; int oldtime=0; int time; void isr() //interrupt service routine { rev++; } void setup() { lcd.begin(16,2); //initialize LCD attachInterrupt(0,isr,RISING); //attaching the interrupt } void loop() { delay(1000); detachInterrupt(0); //detaches the interrupt time=millis()-oldtime; //finds the time rpm=(rev/time)*60000*3; //calculates rpm for blades oldtime=millis(); //saves the current time rev=0; lcd.clear(); lcd.setCursor(3,0); lcd.print("TACHOMETER"); lcd.setCursor(4,1); lcd.print( rpm); lcd.print(" RPM"); lcd.print(" "); attachInterrupt(0,isr,RISING); } |
Video Tutorial:
You can also use the IR Sensor to design a Digital Tachometer and a GPS Module to make a GPS Speedometer.
6 Comments
wheel rotate or not to sense the proximative sensore coading
How to change input to pin 8
The circuit diagram shows pin 2 is connected to IR and your code attachinterupt shows (0, )?
please fix basic and Speed in RPM is NOT correct, it is not 13000
That’s the trick of publishing program on the net. Do something tricky and the code should not work.
I tested it. Mr. Sunny, you are right. Connect the output pin of IR sensor to pin-2 and change the following lines in code, then it will work normally.
attachInterrupt(2,isr,RISING); //attaching the interrupt
}
void loop()
{
delay(1000);
detachInterrupt(0); //detaches the interrupt
time=millis()-oldtime; //finds the time
rpm=(rev/time)600003; //calculates rpm for blades
oldtime=millis(); //saves the current time
rev=0;
lcd.clear();
lcd.setCursor(3,0);
lcd.print(“TACHOMETER”);
lcd.setCursor(4,1);
lcd.print( rpm);
lcd.print(” RPM”);
lcd.print(” “);
attachInterrupt(2,isr,RISING);
}
on the following link of arduino.cc it is crearly mentioned to use ISR with only two pins i.e. pin-2 and pin-3
https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/
This line has a syntax error: rpm=(rev/time)600003; //calculates rpm for blades
Also, in the code in your article, you are using 60000*3 when it should be 60000/3
where does the 60000 come from?