PIR Sensor Interfacing with Particle Photon

Introduction

PIR Sensor

PIR sensor is used for detecting infrared heat radiations. This makes them useful in applications involving detection of moving living objects that emit infrared heat radiations.

The output (in terms of voltage) of PIR sensor is high when it senses motion; whereas it is low when there is no motion (stationary object or no object).

For more information on PIR sensor and how to use it, refer the topic PIR Sensor in the sensors and modules section.

Interfacing Diagram

Interfacing PIR Sensor with Particle Photon

 

Note:

  • PIR sensor: Never keep PIR Sensor close to the Wi-Fi antenna, ESP32, or NodeMCU.
  • PIR (Passive Infrared) sensor close to a WiFi antenna impacts the sensor's performance.
  • PIR sensors detect changes in infrared radiation for motion detection.
  • WiFi signals emit electromagnetic radiation that can interfere with the PIR sensor. Which causes false detection.
  • So always keep the PIR sensor and WiFi antenna as far apart as possible.
  • Also, you can try to shield the PIR sensor from the WiFi signal. This can be done by using metal shields or Faraday cages around the PIR sensor.

 

Example

Motion detection of living objects using PIR sensor using Particle Photon.

Upon detection of motion, object detected is printed on serial monitor. When there is no motion, no object detected is printed on serial monitor.

Sketch for Motion Detection of Living Object

constant PIR_SENSOR_OUTPUT_PIN = 0;	/* PIR sensor O/P pin */
int warm_up;

void setup() {
pinMode(PIR_SENSOR_OUTPUT_PIN, INPUT);
Serial.begin(9600);	/* Define baud rate for serial communication */
delay(20000);	/* Power On Warm Up Delay */
}

void loop() {
int sensor_output;
sensor_output = digitalRead(PIR_SENSOR_OUTPUT_PIN);
if(sensor_output == LOW )
  {
if(warm_up == 1 )
     {
Serial.print("Warming Up\n\n");
warm_up = 0;
delay(2000);
    }
Serial.print("No object in sight\n\n");
delay(1000);
  }
else
  {
Serial.print("Object detected\n\n");    
warm_up = 1;
delay(1000);
  }  
}

 

Output of PIR


Components Used

Particle Photon
PHNTRAYH
1
PIR Sensor
PIR motion sensors sense the Infrared signal radiated from moving objects including human or animal body. It is generally used to detect the presence of human or animal motions.
1

Downloads

PIR Download
Ad