BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Continue to get "invalid auth token" in arduino IDE serial monitor

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");  
     }
  }

This line isn’t being used…

so it should be removed, or you should change this:

to this:

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

and then delete this line:

Once you get your device connected then you’ll need to fix your void loop by either polling pirPin with a timer, or attaching an interrupt to it.

Pete.

1 Like

Beautiful! thanks PeteKnight