Invalid token on Blynk 2.0

I’m trying to learn how to use the new Blynk 2.0. (transition actually). I’ve been using some on line tutorials but I’ve run into a problem with one of the sketches.

I am getting an invalid auth token error along with connecting to blynk-cloud.com:80. I have read some of the solutions in the forum about solving this, but they aren’t working for me.

I’ve upgraded to the most current Blynk library 1.1.0 ) reflashed my ESP8266 node mcu to no avail. I don’t have this problem with other similar programs (eg Flash an LED on Blynk). Only this one. Here’s a shot of the error:
token error1
Here is my sketch:

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

#define BLYNK_TEMPLATE_ID "TMPLWRWOnhdE"
#define BLYNK_DEVICE_NAME "Temperature Alert"
#define BLYNK_AUTH_TOKEN "CqDzUYykEtecQORn_lmFJlFMnkfKKDKe"


char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "xxxxxxxxxxx";  // type your wifi name
char pass[] = "xxxxxxxxxxxk";  // type your wifi password

#define DHTPIN 2          // Mention the digital pin where you connected 
#define DHTTYPE DHT11     // DHT 11  
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

void sendSensor(){
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  Serial.println(t);
  Blynk.virtualWrite(V6, h);
  Blynk.virtualWrite(V5, t);
    Serial.print("Temperature : ");
    Serial.print(t);
    Serial.print("    Humidity : ");
    Serial.println(h);


  if(t > 30){
   // Blynk.email("jgroberman@gmail.com", "Alert", "Temperature over 28C!");
    Blynk.logEvent("temp_alert","Temp above 30 degree");
  }
}

void setup(){
   Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  dht.begin();
  timer.setInterval(2500L, sendSensor);
}

void loop(){
  Blynk.run();
  timer.run();
}

any help would be welcomed.
Jeff

Must be on the top of your sketch, the first lines.

Thanks John, moved them and that did it. It connected. Now I’ve got a "failed to read from DHT sensor error, but that might be easier to fix.
I’ll keep your suggestion in mind for the future.
Best
Jeff

That was an easy fix: Had wire in wrong spot. Need stronger glasses! Working well and sending notifications - which was the point of the exercise.
Thanks again.

It’s not a suggestion, it’s a requirement of Blynk IoT.

Pete.

This will quickly result in you exceeding the event/notification limits.

You should read this…

Pete.

Hi Pete:
Looks like your message go cut off… I also just posted another post about an interesting problem I had regarding using “fonts” on the SSID sign in. I’d like to know your thoughts on that.
Jeff

No, it’s a link. Click it!

Pete.

1 Like