Introduction: NodeMcu Motion Detection Led

About: I am an electronic hobbyist on Arduino, Photon, Raspberry Pi and common electronics.A passionate cook.Any assistance in electronics and web development feel free to contact me at

Hey, peeps!! I'm Sridhar Janardhan back with interesting tutorials on Internet Of Things abbreviated as IOT which is a current trend in the electronic industry.So let me brush you about what is Internet of things in one sentence, aInternet of things is an upcoming technology which helps to control device through the internet which gives access to control any device in any part of the world.Seems interesting??Let's get into the real-time implementation.In this ible, I have used NodeMCU board which is an esp8266 breakout board.What's the difference between a NodeMCU and Arduino?? To connect an Arduino to Internet to the internet we must use an ethernet shield which makes the circuit little big and the cost of ethernet shield is very high and NodeMCU at other hand has a small wifi chip (ESP8266) embedded on its board making easy to get connected to the domestic wifi with the help of an android app Blynk App.

Shoutout: If you guys have missed my previous tutorial click the text here to keep updated about my daily tutorial activities.

Step 1: Electronics Billing:

The components to prepare this Ible are:

  • NodeMCU
  • PIR sensor
  • Resistor (1K, 2.2K, and 330ohm)
  • LED
  • Breadboard
  • Jumper wire
  • Android phone
  • wifi Connection

After the billing let's get into the action of building the circuit.

Step 2: Connecting the PIR Sensor:

The connection of PIR sensor to Arduino is as follows:

  • The VCC pin of the sensor is connected to the positive railings of the breadboard
  • the Gnd pin of the sensor is connected to the negative railings of the breadboard
  • the out pin of the sensor is connected to the Digital pin 1.

So after connecting the PIR sensor lets connect the LED to complete the hardware interface.

Step 3: Connecting the Led:

Usually, LED has two terminals called as anode and cathode.The longer leg is called as an anode and shorter leg is called as a cathode.The negative terminal or the shorter leg is connected to the negative terminal of the breadboard.

the positive terminal or the longer leg is connected to the digital pin 7 of the Arduino.

Step 4: Using Blynk App:

Blynk app is an open source software which helps in monitoring the nodeMCU is available in play store

To get started and control the NodeMCU follow these steps:

  • Create a New Project.
  • Give it a name
  • Select NodeMCU as HW Model
  • Copy the AUTH TOKEN to be used in the code
  • Includes a Push Notification Widget.
  • Press Play

Boom!! the hardware interface is over now let's get into coding.

Step 5: Code


#define BLYNK_PRINT Serial

#include char auth[] = "YOUR AUTH CODE HERE";

/* WiFi credentials */

char ssid[] = "YOUR SSID";

char pass[] = "YOUR PASSWORD";

/* HC-SR501 Motion Detector */

#define ledPin D7

#define pirPin D1

void setup() {



Blynk.begin(auth, ssid, pass);

pinMode(ledPin, OUTPUT);

pinMode(pirPin, INPUT);

digitalWrite(ledPin, LOW); }

void loop() {

getPirValue();; }

void getPirValue(void) {

pirValue = digitalRead(pirPin);

if (pirValue) {

Serial.println("==> Motion detected");

Blynk.notify("T==> Motion detected");


digitalWrite(ledPin, pirValue);


Step 6: The Output

Step 7: Assistance in Projects:

If any peeps having difficulty in any electronics project leave a comment below or mail your project abstract to

Thank you,

Makerspace Contest 2017

Participated in the
Makerspace Contest 2017