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:
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