Node MCU ESP8266 interface with PIR Motion Sensor circuit diagram with code

Node MCU ESP8266 interface with PIR Motion Sensor with code


The project uses PIR sensor to sense the motion of human  and turns ON an LED to  detect the motion. When movement of human will be detected by the PIR sensor. PIR Sensor provides a triggering pulse to NODE MCU  GPIO Pin 5 which is data D1 0n board.






Node MCU ESP8266


Pinout for ESP8266 NODE MCU

Pinout for ESP8266 NODE MCU



PIR Motion Sensor


Components Required

  1. NODE MCU ESP8266
  2. PIR Sensor
  3. LED
  4. Breadboard
  5. Jumper Wires

LED  +ve  to  D4  and  -ve  to  GND  of  NODE  MCU

PIR MOTION SENSOR 

  1. VCC = 3.3V
  2. OUTPUT =  D1
  3. GND = GND of Node MCU board

What is a PIR sensor module?

The PIR sensor is used to detect infrared radiation. This makes them useful in detecting moving organisms that emit infrared radiation.

The PIR sensor output (voltage) is high when it senses movement, and it is low when there is no movement (stationary object ).

PIR sensors are used in many applications such as room light control using human detection, human movement detection for home safety purposes, etc.

For more information on the PIR sensor and how to use it, see the article PIR sensor

Connecting the PIR sensors to Node MCU is very easy. The PIR works as a digital output. See pictures for more details.

Most PIR modules have a 3-pin connection on the side or bottom. The pinout can vary between modules so check the pinout carefully! Power usually includes 3-5v DC.

How do you connect the PIR motion sensor?

Connecting the PIR sensors to the microcontroller is quite easy. The PIR works as a digital output so all you need to do is listen to the output pin when HIGH pulse (Motion Detection) or LOW Pulse (Not Found). Enable PIR with 5V VCC and connect the ground to the ground. Then connect the output to the digital pin of the Microcontroller Board.

What is a PIR sensor output?

Output: High digital pulse (3V) when motion is detected and idle (no motion detected) low digital pulse. 

Which sensor is used in the PIR?

An Passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared light (IR) from objects in their field of view. They are often used in PIR-based motion sensors.


CODE
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
int LED = 2;       
     
int SENSOR_OUTPUT_PIN = 5;

void setup() {

  pinMode(SENSOR_OUTPUT_PIN, INPUT);  

  pinMode(LED, OUTPUT);           

  Serial.begin(9600);

}

void loop() {

  int sensorvalue = digitalRead(SENSOR_OUTPUT_PIN);

  Serial.println(sensorvalue);
  
  if (sensorvalue== HIGH) {
 
   digitalWrite(LED, HIGH);

    delay(1000);
  }

  else {

    digitalWrite(LED, LOW);
   
  }
}



YOU TUBE VIDEO






If you still have any questions related to this article, then you can message me on my social media accounts.


!!THANKS FOR VISITING!!
!!HAPPY LEARNING!!
!!HAVE A GREAT DAY!!