Nodemcu 12-F, ESP8266
communicating over wifi
Blynk library version 1.0.1
i’ve tried countless variables
any ideas?
#define BLYNK_TEMPLATE_ID "TMPLJyQyUYRk"
#define BLYNK_DEVICE_NAME "Motion 2"
#define BLYNK_AUTH_TOKEN "w3GHXXXXXXXXXXXX7ktY6"
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "w3GHXXXXXXXXXXXXXXX7ktY6";
/* WiFi credentials */
char ssid[] = "XXXXXX_2GEXT";
char pass[] = "XXXXXXXX";
/* HC-SR501 Motion Detector */
#define pirPin 5 // Input for HC-S501
int pirValue; // Place to store read PIR Value
int pinValue; //Variable to read virtual pin
#define BLYNK_PRINT Serial
BLYNK_WRITE(V0)
{
pinValue = param.asInt();
}
void setup()
{
Serial.begin(115200);
delay(10);
Blynk.begin(auth, ssid, pass);
pinMode(pirPin, INPUT);
}
void loop()
{
if (pinValue == HIGH)
{
getPirValue();
}
Blynk.run();
}
void getPirValue(void) //Get PIR Data
{
pirValue = digitalRead(pirPin);
if (pirValue)
{
Serial.println("Motion detected");
Blynk.notify("Motion detected");
}
}