Arduino Uno and PIR Sensor: Building a Smart Motion Detection System

by ganesh_20203 in Circuits > Arduino

357 Views, 2 Favorites, 0 Comments

Arduino Uno and PIR Sensor: Building a Smart Motion Detection System

arduino uno R3.png
PIR sensor.png

In this article, we will embark on an exciting journey into the realm of motion detection and automation as we delve into the intricacies of interfacing an Arduino Uno with a PIR sensor. Whether you're a seasoned DIY enthusiast or a curious newcomer to the world of electronics, by the end of this guide, you'll have the knowledge and inspiration to create your own smart motion detection system. So, let's embark on this technological adventure and unlock the potential of Arduino Uno and PIR sensor integration.

Supplies

Components Required:

1) Arduino UNO R3 - 1

2) PIR sensor - 1

3) UART Cable - 1

Theory

PIR_concept.png
PIR.png

What is a PIR sensor?

PIR sensor (Passive Infrared Motion Detector). As the name suggests it doesn't emit radiation like an active sensor but detects the change in infrared radiation of the source.

Working Principle:

  • It works on the principle that whenever it detects a change in infrared radiation, it generates a digital output signal as a response.
  • Fresnel lens and pyroelectric material make up this device. The incoming infrared radiations are focused by a Fresnel lens constructed of high-density polyethylene such that they fall off the pyroelectric substance. The sensor may be more resistant to noise, temperature, and humidity with the help of metal. Infrared radiation variations are detected by pyroelectric material, which then produces an output signal.

PIR sensor characteristics:

  • Indoor passive infrared: the range is between 25 cm to 20 m.
  • Outdoor passive infrared: the range is between 10 m to 150 m.

Connections

PIR_final.png

1) Connect the GND of Arduino to GND Pin of PIR sensor.

2) Connect the 5V pin of Arduino to Vcc Pin of PIR sensor.

3) Connect the pin12 of Arduino to Signal Pin of PIR sensor.

According to the above diagram:

1) Red wire: power

2) Black wire: ground

3) Orange wire: signal

CODE

int led = 13; // Arduino has an inbuilt LED at pin 13 use that pin else an external LED can also be used.

int PIR_sensor = 12; // signal pin of the PIR sensor is connected to pin 12 of Arduino uno.

int x=0; // declare a variable to store the sensor status.

void setup()

{

  pinMode(led,OUTPUT); // initialise LED as output.

  pinMode(PIR_sensor,INPUT); // initialise PIR_sensor as input.

  Serial.begin(9600); // initialise the serial

}

void loop()

{

  x=digitalRead(PIR_sensor); // this line reads the sensor state and stores in x.

  if(x==HIGH)

  {

    digitalWrite(led,HIGH);

    delay(1000);

    Serial.println("PIR sensor detected the Motion");

  }

  else

  {

    digitalWrite(led,LOW);

    delay(1000);

    Serial.println("No motion detected");

  }


}

Conclusion

You can integrate any sensor with the PIR sensor based your requirements. Here I have used the inbuilt LED on the Arduino Uno board to check the working of PIR sensor.

In conclusion, Arduino Uno and PIR sensor integration opens the door to countless possibilities. From smart home automation to security solutions and interactive art, this combination empowers creativity. As you venture into this exciting world, remember that your imagination is the only limit. So, start tinkering and turn your ideas into reality!


For any questions, contact: gy802655@gmail.com.