Contents
Motion Sensor PIR Working and its Applicarions
The PIR motion sensor is ideal to detect movement. PIR stand for “Passive Infrared”. Basically, the PIR motion sensor measures infrared light from objects in its field of view. So, it can detect motion based on changes in infrared light in the environment. It is ideal to detect if a human has moved in or out of the sensor range.
SENSOR PIN | ARDUINO CONNECTION |
GND | Ground |
OUTPUT | Arduino Any Digital Pin |
5V DC | 5V Dc |
PIR Sensor Features
1. Wide range on input voltage varying from 4.V to 12V (+5V recommended)
2. Output voltage is High/Low (3.3V TTL)
3. Can distinguish between object movement and human movement
4. Has to operating modes – Repeatable(H) and Non- Repeatable(H)
5. Cover distance of about 120° and 7 meters
6. Low power consumption of 65mA
7. Operating temperature from -20° to +80° Celsius
How to use PIR Motion Sensor
The PIR sensor stands for Passive Infrared sensor. It is a low cost sensor which can detect the presence of Human beings or animals. This sensor has three output pins Vcc, Output and Ground as shown in the pin diagram above. Since the output pin is 3.3V TTL logic it can be used with any platforms like Arduino, Raspberry, PIC, ARM, 8051.
The module can be powered from voltage 4.5V to 20V but, typically 5V is used. Once the module is powered allow the module to calibrate itself for few minutes, 2 minutes is a well settled time. Then observe the output on the output pin. Before we analyse the output we need to know that there are two operating modes in this sensor such as Repeatable(H) and Non- Repeatable(L) and mode. The Repeatable mode is the default mode.
The output of the sensor can be set by shorting any two pins on the left of the module. The sensor in the figure above has two built-in potentiometers to adjust the delay trim (the potentiometer at the left) and the sensitivity (the potentiometer at the right).
ALL SENSOR DETAILS:
1. HC-05 – Bluetooth
2. Mpu 6050 accelerometer-gyroscope- -module
3. Flame-sensor
4. Rotary-encoder
5. Force-sensor-fsr400
6. Current-sensor-acs712
7. Flex-sensor
8. IR-sensor-tcrt5000
9. Pulse-sensor-pin
10. Color-sensor-tcs230
11. SD-card-module
12. Oled-with-arduino
13. Addressable-rgb-led-strip-ws1812
14. Relay-module
15. TFT-1-8-display-st7735r
16. 8×8-dot-matrix-display-max7219
17. Smoke-sensor-mq-2
18. Ultrasonic-sensor-HC-sr04
19. PIR-motion-sensor-hc-sr501
20. Tilt-sensor-sw-520d
21. Microphone-sound-sensor
22. Reed-switch-reed-sensor
23. Rfid-reader-Em18
24. Rfid-tag
25. RTC-real-time-clock-ds1307
26. Temperature-sensor-ds18b20
27. Moisture-sensor
28. Rain-sensor
29. Pressure-sensor
30. Accelerometer
31. MOC-3021-circuit
32. DHT11-DHT22-temperature-and-humidity-sensor
PIR Sensor Applications
1. Automatic Street/Garage/Warehouse or Garden Lights.
2. Burglar Alarms.
3. Security cams as motion detectors.
4. Industrial Automation Control.
PIR WITH ARDUINO CIRCUIT DIAREAM
PIR SENSOR WITH ARDUINO IDE
Copy and paste the below given or download from the bottom mentioned link.
/*
* Circuito.io is an automatic generator of schematics and code for off the shelf hardware combinations.
*/
// Include Libraries
#include “Arduino.h”
#include “LED.h”
#include “Switchable.h”
#include “PIR.h”
// Pin Definitions
#define LEDR_PIN_VIN 5
#define PIR_PIN_SIG 2
// Global variables and defines
// object initialization
LED ledR(LEDR_PIN_VIN);
PIR pir(PIR_PIN_SIG);
// define vars for testing menu
const int timeout = 10000; //define timeout of 10 sec
char menuOption = 0;
long time0;
// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup()
{
// Setup Serial which is useful for debugging
// Use the Serial Monitor to view printed messages
Serial.begin(9600);
while (!Serial) ; // wait for serial port to connect. Needed for native USB
Serial.println(“start”);
menuOption = menu();
}
// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.
void loop()
{
if(menuOption == ‘1’)
{
// LED – Basic Red 5mm – Test Code
// The LED will turn on and fade till it is off
for(int i=255 ; i> 0 ; i -= 5)
{
ledR.dim(i); // 1. Dim Led
delay(15); // 2. waits 5 milliseconds (0.5 sec). Change the value in the brackets (500) for a longer or shorter delay in milliseconds.
}
ledR.off(); // 3. turns off
}
else if(menuOption == ‘2’)
{
// PIR (motion) sensor – Test Code
bool pirVal = pir.read();
Serial.print(F(“Val: “)); Serial.println(pirVal);
}
if (millis() – time0 > timeout)
{
menuOption = menu();
}
}
// Menu function for selecting the components to be tested
// Follow serial monitor for instrcutions
char menu()
{
Serial.println(F(“\nWhich component would you like to test?”));
Serial.println(F(“(1) LED – Basic Red 5mm”));
Serial.println(F(“(2) PIR (motion) sensor”));
Serial.println(F(“(menu) send anything else or press on board reset button\n”));
while (!Serial.available());
// Read data from serial monitor if received
while (Serial.available())
{
char c = Serial.read();
if (isAlphaNumeric(c))
{
if(c == ‘1’)
Serial.println(F(“Now Testing LED – Basic Red 5mm”));
else if(c == ‘2’)
Serial.println(F(“Now Testing PIR (motion) sensor”));
else
{
Serial.println(F(“illegal input!”));
return 0;
}
time0 = millis();
return c;
}
}
}
Download Arduino Code Here Pir_with_Arduino Uno code After downloaded extract and open folder then double click Arduino uno code. Then compile and upload the sketch to Arduino Uno Project board.