Pir sensor

There’s no trigger in my pir sensor it is connected in nodemcu please help me here is my code.

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

char auth[] = "**********************";

SimpleTimer timer;

char ssid[] = "********";
char pass[] = "********";

int counter = 0;
int flag = 1;
int sensor = 13;

WidgetLED ledmovement(V2);

void myTimerEvent()
  counter = counter+1;

  if (counter == 5)
    counter = 0;
    flag = 1;

  int movement = digitalRead(13);
  if ( movement == HIGH )
    if  (flag == 1) 
       Serial.println("Motion Detected");
       Blynk.notify("Motion Detected");
       flag = 2;

void setup()
  Blynk.begin(auth, "*******", "******");


void loop()

Declaring a timer in your void setup that calls myTimerEvent on a regular basis would be a good start.

Also, why are you using SimpleTimer rather than BlynkTimer, which is already built into the Blynk library that you’ve included in your sketch?


I’m just a beginner I thought Simple timer is better than blynk timer. so it would be better If I’m going to use blynk timer rather than Simple timer??

BlynkTimer is an improved version of SimpleTimer. You save program space by using it rather than including another library that does the same basic thing.


Okay thank you Pete.