Pir Sensor is most common to detect motion of Passive Infrared radiations that are emitted by Humans/Living things.
These radiations are invisible to the human eye but are not to Fresnel lens which enhances the radiations onto PIR detector. The IR sensor itself is housed in a hermetically sealed metal can to improve noise/temperature/humidity immunity. There is a window made of an IR-transmissive material (typically coated silicon since that is very easy to come by) that protects the sensing element. Behind the window are the two balanced sensors. As shown below:
PIR sensor itself creates a small millivolt when it detects a motion and that is analog which is even invisible to Arduino. So, the module has IC NCS36000 that helps to create a digital output when PIR detects the motion.
This PIR module has a detection range of up to 6 meters.
The NCS36000 is a fully integrated mixed−signal CMOS device designed for low−cost passive infrared controlling applications. The device integrates two low−noise amplifiers and an LDO regulator to drive the sensor. The output of the amplifiers goes to a window comparator that uses internal voltage references from the regulator. The digital control circuit processes the output from the window comparator and provides the output to the OUT and LED pin. (see this file for more details)
PIR module has two variable resistors namely TIME and Sensitivity. Turning clockwise the sensitive resistor will increase its sensitivity similarly turning clockwise will increase the delay time of PIR sensor. More details and features are given below:
Features and Electrical Specification of a PIR Module
- Compact size (28 x 38 mm)
- Supply current: DC5V-20V(can design DC3V-24V)
- Sensitivity range: up to 20 feet (6 meters) 110° x 70° detection range
- Current drain :< 50uA
(Another choice: DC0.8V-4.5V; Current Drain: 1.5mA-0.1mA) - Voltage Output: High/Low-level signal :3.3V
(Another choice: Open-Collector Output) - TTL output
- High sensitivity
- Delay time:5s-18 minute
- Blockade time:0.5s-50s (acquiescently 0 seconds)
- Operation Temperature: -15oC -70Oc
- Infrared sensor: dual element, low noise, high sensitivity
PIR Module is a complete package to use with Arduino. See the connection diagram below:
After connecting PIR Module with Arduino as shown above. Burn the following code onto Arduino using Arduino software. The code is very simple and self-explanatory.
Code:
/// Brave Learn ///
/// https://bravelearn.com ///
// Connect PIR Motion Sensor to Arduino as shown in the diagram
// digital pin 7 has a pir attached to it.
int pirstat = 7;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// make the PIR Digital pin an input:
pinMode(pirstat, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
boolean buttonState = digitalRead(pirstat); //boolean cuz we need 1/0 as motion detected or not
// print out the state of the button:
if (buttonState == 1)
Serial.println("Motion is Detected");
else
Serial.println("No Motion is present");
delay(5000); // wait for 5 seconds before taking the reading again
}
After uploading the code onto Arduino
press CTRL+Shift+M to open serial monitor or go to tools->Serial Monitor in Arduino Software to see the status of PIR. It should print “Motion is Detected” or “No Motion is present” as shown.
Well! This is really a simple to implement but hey we would go into advanced stuff with this. We will build a complete intruder detector system that warns user via text message on detecting motion. See Arduino category for more fun projects.
If you have any suggestions, please leave us a comment below: