Arduino PIR: Difference between revisions

From James's Wiki
(Created page with "How It Works First let’s explain the working principle. The module actually consists of a Pyroelectric sensor which generates energy when exposed to heat. File:PIR-Motio...")
 
No edit summary
 
Line 18: Line 18:


[[File:PIR-Sensor-Pinout.jpg]]
[[File:PIR-Sensor-Pinout.jpg]]
The module has three more pins with a jumper between two of them. These pins are for selecting the trigger modes. The first one is called “non-repeatable trigger” and works like this: when the sensor output is high and the delay time is over, the output will automatically change from high to low level. The other mode called “repeatable trigger” will keep the output high all the time until the detected object is present in sensor’s range.
<nowiki>    /*    Arduini PIR Motion Sensor Tutorial
    *     
    *  by Dejan Nedelkovski, www.HowToMechatronics.com
    * 
    */
    int pirSensor = 8;
    int relayInput = 7;
    void setup() {
      pinMode(pirSensor, INPUT);
      pinMode(relayInput, OUTPUT); 
    }
    void loop() {
      int sensorValue = digitalRead(pirSensor);
      if (sensorValue == 1) {
        digitalWrite(relayInput, LOW); // The Relay Input works Inversly
      }
    }</nowiki>

Latest revision as of 18:44, 7 October 2018

How It Works

First let’s explain the working principle. The module actually consists of a Pyroelectric sensor which generates energy when exposed to heat.

File:PIR-Motion-Sensor-HC-SR501-Module.jpg

That means when a human or animal body will get in the range of the sensor it will detect a movement because the human or animal body emits heat energy in a form of infrared radiation. That’s where the name of the sensor comes from, a Passive Infra-Red sensor. And the term “passive” means that sensor is not using any energy for detecting purposes, it just works by detecting the energy given off by the other objects.

File:PIR-Sensor04.png

The module also consists a specially designed cover named Fresnel lens, which focuses the infrared signals onto the pyroelectric sensor.

File:PIR-Motion-Sensor-How-It-Works.png

The HC-SR501 PIR Sensor Module

The module has just three pins, a Ground and a VCC for powering the module and an output pin which gives high logic level if an object is detected. Also it has two potentiometers. One for adjusting the sensitivity of the sensor and the other for adjusting the time the output signal stays high when object is detected. This time can be adjusted from 0.3 seconds up to 5 minutes.

File:PIR-Sensor-Pinout.jpg

The module has three more pins with a jumper between two of them. These pins are for selecting the trigger modes. The first one is called “non-repeatable trigger” and works like this: when the sensor output is high and the delay time is over, the output will automatically change from high to low level. The other mode called “repeatable trigger” will keep the output high all the time until the detected object is present in sensor’s range.

    /*     Arduini PIR Motion Sensor Tutorial
     *      
     *  by Dejan Nedelkovski, www.HowToMechatronics.com
     *  
     */
    int pirSensor = 8;
    int relayInput = 7;
    void setup() {
      pinMode(pirSensor, INPUT);
      pinMode(relayInput, OUTPUT);  
    }
    void loop() {
      int sensorValue = digitalRead(pirSensor);
      if (sensorValue == 1) {
        digitalWrite(relayInput, LOW); // The Relay Input works Inversly
      }
    }