PIR Sensor Arduino Interfacing

PIR Sensor Arduino Interfacing
PIR sensor stands for Passive Infra Red sensors. As it is clear from its name that PIR is an electronic device or sensor used to measure the infrared energy emitted by animals and human beings. This energy is emitted in the form of heat. When this energy is above the certain level, there is algorithm to show an an indication that the desired level has be reached. This tutorial is based on PIR interfacing with Arduino. PIR sensor is shown in the figure below along all of its pin names.
1. PIR Sensor Pins
- PIR sensor has three pins voltage, output and ground respectively.
- All of the pins are provided in the table shown in the figure given below.
2. PIR Sensor Pins Description
- Each pin has different task to perform while the sensor is in working condition.
- PIR sensor pin descriptions are listed in the table shown in the figure below.
3. PIR Working Principle
- PIR sensor has two different slot which are sensitive to infrared light/energy.
- When the sensor is in normal condition, both of the slots measure the same amount of infrared energy radiated by walls etc.
- When a warm body e.g animals and human beings crosses its coverage area, they first cross PIR sensors's first slot, which produces positive differential change between two slots.
- When an animal or human being leave from the sensing area, a corresponding negative differential change is produced.
- By detecting these types of changes PIR sensor can detect the motion of different objects which radiates infrared energy.
- I have tried to elaborate the PIR working principle through some visuals shown in the figure given below.
- I have also provided the visuals about how PIR sensor generates an output signal after sensing different objects/
- PIR sensor object sensing is given in the figure shown below.
4. PIR Sensor Schematic Diagram
- To understand the internal structure of any electronic device, we must have a look at its schematic diagram.
- PIR sensor schematic diagram is shown in the figure given below.
5. Apparatus Required
A list of apparatus required for PIR interfacing with Arduino is given below.- PIR (Passive Infra Red) Sensor
- Arduino (Microcontroller)
- Jumper wires
6. PIR Interfacing with Arduino Wiring Diagram
- I have already shared a brief article on Interfacing PIR sensor with Arduino.
- Now, this is a detailed article about the similar topic.
- I have provided wiring diagram for PIR interfacing with Arduino.
- You can make the similar wiring diagram and can test and verify your results as well.
- PIR Sensor Arduino Interfacing wiring diagram is shown in the figure given below.
7. PIR Sensor Arduino Interfacing Source Code and Description
- If you have never use Arduino software for programming then you should first go through How to Write Arduino Code.
- I have provided the complete source code for PIR interfacing with Arduino.
- You just need to copy and paste the entire code and upload it to your Arduino board and observe the results.
- You can also made the same simulation on Proteus as well and can verify the results.
- In case of Proteus simulation you must need to know about How to get Hex File from Arduino.
int LED = 13;
int inputPin = 2;
int PIR_STATE = LOW;
int VALUE = 0;
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(9600);
}
void loop(){
VALUE = digitalRead(inputPin);
if (VALUE == HIGH) {
digitalWrite(LED, HIGH);
if (PIR_STATE == LOW) {
// we have just turned on
Serial.println("Motion has been detected!");
PIR_STATE = HIGH;
}
} else {
digitalWrite(LED, LOW);
if (PIR_STATE == HIGH){
// we have just turned of
Serial.println("Motion has been stopped!");
PIR_STATE = LOW;
}
}
}
- I have initialized the LED pin, PIR state pin and the pin and a variable for reading sensor's data.
- Then I have checked whether the detected value from the sensor is above or below the certain level.
- Then I have decide to be print the certain values on Serial Monitor.
- If it is above the certain level a message "Motion has been detected" will be displayed on the serial monitor through Serial Communication.
- If the detected value is below the certain level then the message "Motion has been stopped" will be displayed on the serial monitor in Arduino software.
- So, that was the brief description of the source code designed for PIR interfacing with Arduino.
- You can download the complete wiring diagram along with the complete Arduino source code here by clicking on the button below.
8. PIR Sensor Interfacing with Arduino Actual Circuit Diagram
- I have also provided the actual circuit diagram for PIR interfacing with Arduino.
- Actual circuit diagram is shown in the figure given below.
9. PIR Sensor Ratings
- To know the power, current and voltage requirements of an electronic device can be known through its ratings.
- PIR sensor ratings are listed in the table given in the figure shown below.
10. PIR Sensor Features
- A device can be popular on the basis of its amazing and unique features, which make it different from other devices.
- PIR sensor some of the main features are listed in the table given in the figure shown below.
11. PIR Sensor Applications
- PIR sensor has several different real applications.
- Some of common applications associated with PIR sensor are provided in the table shown in the figure given below.
- I have provided a circuit designed for security alarm system, which is its most common application.
- The complete circuit design for security alarm system is given in the figure shown below.
- PIR sensor's another application is making a timer circuit using PIR.
- I have provided timer circuit using PIR sensor, shown in the figure given below.
- Another most common application of PIR sensor is the motion detection.
- Motion detection circuit diagram using PIR sensor is shown in the figure given below.
12. PIR Sensor Advantages
- There are a lot of advantages associated with Passive Infrared Sensor, few of them are given below.
13. PIR Sensor Disadvantages
- Infrared sensors also have some disadvantages but they are in a very small as compared to its disadvantage.
- Infrared sensor disadvantage are listed in the table given in the figure shown below.
×
![]()















































































