Sensors are the devices that detect the changing of specific quantities in an area and lets the system know by varying its output. There are different types of sensors for sensing different quantities like temperature, atmospheric pressure, humidity, obstacle detection sensors and many more. These sensors can be interfaced with microcontrollers using Arduino boards to measure the respective quantities. Furthermore, to detect any movement in a specified area the infrared sensors are used, and we have interfaced the infrared (IR) module with Arduino Uno in this discourse.
What is an IR Module
The infrared sensor (IR) is a sensor that detects motion of any object in a specified area, and it also detects the heat signatures of a nearby object. Since every object emits heat in the form of radiation, this sensor detects that radiation and measures the temperature.
Here in this project we are using the IR module which comes with two LEDs for detection of the motion, one LED acts as a photodiode that detects any infrared radiation either reflected or any heat signature and the other acts as light emitting diode that emits the infrared radiation.
The IR module has 3 pins in total, one for supply voltage, one for the ground and the third one is the output pin. This module comes with the potentiometer that is used for the calibration of output of the sensor by increasing or decreasing the resistance of the photodiode. The image posted below shows the IR module:
The pin configuration of the IR module is given below in the table:
Pin number (From left to right) |
Symbol | Description |
---|---|---|
1 | (OUT) | Pin for reading the output of the module |
2 | (GND) | Pin for grounding the module |
3 | (VCC) | Pin for connecting the module to supply voltage |
The module works in such a way that the radiation is emitted by the light emitting diode and when the emitted radiation is reflected by colliding with some object the reflected radiation is received by the photodiode. The photodiode then generates a signal for the detection of the movement of any object or any obstacle.
There are number of applications where this module is used:
- Infrared temperature gun
- Night vision cameras
- Heat signature detection cameras
- Intruders’ detection for home security
How to Interface IR Module with Arduino Uno
To interface the infrared module, we have used the following list of components:
- Breadboard
- Arduino Uno
- Connecting wires
- IR Module
The image having the circuit schematic is given below to give a better understanding of interfacing of IR module with Arduino
Hardware assembly of interfacing IR Module with Arduino Uno
The hardware assembly of interfacing of the IR module with Arduino Uno can be seen in the figure given below . We have interfaced the infrared module with Arduino in such a way that first we have placed the LED on the breadboard and using the brown wire connected it to the pin 12 of Arduino. Secondly, we have interfaced the IR module with Arduino using the blue wire by using pin 4 of Arduino. To supply the voltage to the module and LED we have used the 5 volts and ground pins of the Arduino Uno.
Arduino Code for interfacing IR Module with Arduino Uno
To interface the IR module we complied the Arduino code which is given as:
#define LED 12// Arduino pin for LED
int ir;// variable to store the value of the sensor
void setup()
{
Serial.begin(9600);// initializing the Serial communication
pinMode(irpin, INPUT);// assigning the sensor as a input to Arduino
pinMode(LED, OUTPUT);// assigning the LED as output of Arduino
}
void loop(){
ir=digitalRead(irpin);// reading the output of the sensor
if(ir==LOW){// if the sensor detects the any reflected radiation
digitalWrite(LED,HIGH);// turn on the LED
}
else {
digitalWrite(LED,LOW);// otherwise keep the LED in off state
}
}
To compile the Arduino code for interfacing the IR module first we have declared the pins for LED and module. Next, we have assigned the pin mode of the LED and module and initialized the serial communication.
We have used the digitalRead() function for reading the output of the sensor in the loop section. If the output of the sensor is LOW which means that there is reflected wave on the receiver then turn on the LED otherwise keep the LED in off state.
Hardware implementation of IR module with Arduino Uno
The image posted below is the hardware implementation of the schematic of the circuit for interfacing the IR module:
The working of the IR module is demonstrated by the following image posted below:
Conclusion
The use of microcontrollers in different projects has been increased thanks to the Arduino platform which has made it easier for the students and professionals to interface the different input and output devices with microcontrollers. There are a variety of input devices that can be interfaced with Arduino and most of the input devices include different types of sensors like motion detection sensors, temperature sensors and many more. In this writeup we have discussed the interfacing of the IR sensor using the IR module with Arduino Uno briefly.