PIR Sensor Interfacing with ARM MBED

Overview of PIR Sensor

PIR Sensor

 

  • PIR sensor is used for detecting infrared heat radiations. This makes them useful in applications involving the detection of moving living objects that emit infrared heat radiations.
  • The output (in terms of voltage) of the 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.

 

Connection Diagram of PIR with ARM MBED (LPC1768)

Interfacing PIR Sensor with ARM MBED

 

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.

 

Detect Motion using PIR Sensor and LPC1786 ARM MBED

Motion detection of living objects using PIR sensor using ARM MBED.

Upon detection of motion, LED1 is blink for 200mili seconds. When there is no motion, no object detected LED1 on the ARM MBED board will turn off.

 

PIR Sensor Code for ARM MBED LPC1768

#include "mbed.h"

InterruptIn PIR(p15);
DigitalOut myled(LED1);
int PIR_Detected = 0;

void irq_handler(void)
{
    PIR_Detected = 1;
}

int main()
{
    PIR.rise(&irq_handler);
    while(1) {
        if (PIR_Detected) {
            myled = 1;
            PIR_Detected = 0;
            wait(1);
        }
				
	else {
		myled = 0;
		wait(2);		//for warming up time
		}
    }
}

Components Used

ARM mbed 1768 LPC1768 Board
ARM mbed 1768 Board
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_uvision5_lpc1768 Download
Ad