Motion Detection Automatic Light.

 PIR sensor and relay interfacing with ARDUINO 
( Automatic light by PIR sensor)


PIR SENSOR(Motion Detector) :-__

Hey guys, Do you know how we can detect motion of human? yes, we can detect motion of human by PIR sensor. PIR sensor use for many more applications such as automatic switching operation of outdoor lights, lift lobby, common staircases, automatic switching operation of garden lights based on the presence of a human being, for covered parking area, automatic door operating system in shopping malls, and so on

What is PIR sensor?

passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared (IR) light radiating from objects in its field of view. They are most often used in PIR-based motion detectors. PIR sensors are commonly used in security alarms and automatic lighting applications .When the warm body leaves the sensing area, the reverse happens, whereby the sensor generates a negative differential change. These change pulses are what is detected by PIR sensor.

 Usually, plastic optical reflection system or plastic Fresnel lens used as a focusing system for infrared radiation PIR is made of a pyroelectric sensor, which is able to detect different levels of infrared radiation.  The detector itself does not emit any energy but passively receives it. 


The most widely used infrared detector is a pyroelectric detector. It uses as a sensor for converting human infrared radiation into electricity. If the human infrared radiation is directly irradiated on the detector, it will, of course, cause a temperature change to output a signal. but all is in limited coverage area as shown below.

  • Indoor passive infrared: Detection distances range from 25 cm to 20 m.

  • Outdoor passive infrared curtain detector: distance from 10 meters to 150 meters


 PIR sensor pin connection :-


  •  PIN 1(VCC) :- Power pin we have to apply +5v through ARDUINO.
  •  PIN 2(Out put) :- The output pin of the sensor. The pin 2 of the sensor carries the detected IR signal .
  • PIN 3(GND) :- Apply ground.

Relay:-

Relay is an electromechanical device that uses an electric current to open or close the contacts of a switch. The single-channel relay module is much more than just a plain relay, it comprises of components that make switching and connection easier and act as indicators to show if the module is powered and if the relay is active or not.


Connection of relay with ARDUINO UNO :-



  1. GND: goes to ground.
  2. IN1: controls the first relay (it will be connected to an Arduino digital pin)
  3. IN2: controls the second relay (it should be connected to an Arduino digital pin if you are using this second relay. ...
  4. VCC: goes to 5V.

 Automatic light by Motion Detection.

Now, Here we make simple project using PIR sensor(motion detector) and relay module is Automatic light by any motion detection.


As we shown connection of PIR sensor and relay module with ARDUINO UNO now we connect all components as figure shown.

Relay connection:-           

  PIR sensor connection :-

Input:- pin D8 of ARDUINO UNO

 Output:- pin D2 of ARDUINO UNO.

GND:- Ground

 GND:- Ground

VCC :- +5v

  VCC :- +5v


The connections for the relay is simple. We take a wire from the light bulb and cut it so that we have two separate wires just like it is shown in the picture above. Then we put one wire into the NO (normally open) pin of the relay, and the other wire into the COM (common) pin of the relay.

After completing hardware session we going to do coding How to do coding

// Relay pin is controlled with D8. The active wire is connected to Normally Closed and common
int relay = 8;
volatile byte relayState = LOW;

// PIR Motion Sensor is connected to D2.
int PIRInterrupt = 2;

// Timer Variables
long lastDebounceTime = 0;  
long debounceDelay = 10000;

void setup() {
  // Pin for relay module set as output
  pinMode(relay, OUTPUT);
  digitalWrite(relay, HIGH);
  // PIR motion sensor set as an input
  pinMode(PIRInterrupt, INPUT);
  // Triggers detectMotion function on rising mode to turn the relay on, if the condition is met
  attachInterrupt(digitalPinToInterrupt(PIRInterrupt), detectMotion, RISING);
  // Serial communication for debugging purposes
  Serial.begin(9600);
}

void loop() {
  // If 10 seconds have passed, the relay is turned off
  if((millis() - lastDebounceTime) > debounceDelay && relayState == HIGH){
    digitalWrite(relay, HIGH);
    relayState = LOW;
    Serial.println("OFF");
  }
  delay(50);
}

void detectMotion() {
  Serial.println("Motion");
  if(relayState == LOW){
    digitalWrite(relay, LOW);
  }
  relayState = HIGH;  
  Serial.println("ON");
  lastDebounceTime = millis();
}



              for any query Email to Innovativethnings@gmail.com
                 

Comments

Popular posts from this blog

Arduino

ARDUINO SOFTWARE(HOW TO PROGRAM IN ARDUINO ?)

Soil moisture sensor with Arduino ( Automatic watering plant)