Hey there.
I’m using old blynk app on my phone, with my esp8266 controlling couple devices. What I want to ask, is:
I heard old app soon will be not supported? Is that really necessary to migrate?
I want to add, to esp8266 firmware - OTA firmware update and widget sync (so devices will sync last virtual button states, from app).
Also, I found some Edgent… . As I understand, it’s new app device manager? I will add this option to code, which I will post below. Just check my code, please.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
#include <SPI.h>
#include "BlynkEdgent.h"
char auth[] = "****s****f****";
char ssid[] = "*****";
char pass[] = "******";
BLYNK_CONNECTED() {
Blynk.syncAll();
}
#define DHTPIN 1
#define DHTTYPE DHT11
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;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V1, h); //V1 is for Humidity
Blynk.virtualWrite(V2, t); //V2 is for Temperature
}
void setup()
{
// Debug console
Serial.begin(115200);
delay(100);
Blynk.begin(auth, ssid, pass);
BlynkEdgent.begin();
dht.begin();
// Setup a function to be called every 10 seconds
timer.setInterval(10000L, sendSensor);
}
void loop()
{
Blynk.run();
BlynkEdgent.run();
timer.run(); // Initiates SimpleTimer
}
The old app stopped being supported aroung 3 years ago.
At some point *(we don’t know when) the old (Legacy) server will be turned off and your app and devices will stop working.
If you want to continue using Blynk then yes, it is.
The Edgent example for the ESP8266 is where you should start. It contains 10 files (tabs in the IDE) and should be the starting point for your sketch.
Add-in the old code (minus the Blynk.run() - this is now Edgent.run() when using the Edgent sketch and Blynk.begin() which is now Edgent.begin()) and omit your auth, ssid and pass variables - but add-in the BLYNK_TEMPLATE_ID and BLYNK_DEVICE_NAME from the template you create in the web console.
Also, Blynk.syncAll() only works for the datastreams you create where you turn on the "Sync with latest server value every time device connects to the cloud` in the datastream’s Advanced options.
C:\Users\*****\Documents\Arduino\Blynk_Edgent_ESP8266_3dp_new\Blynk_Edgent_ESP8266_3dp_new.ino: In function 'void setup()':
Blynk_Edgent_ESP8266_3dp_new:45:15: error: 'class Edgent' has no member named 'begin'
45 | BlynkEdgent.begin();
| ^~~~~
C:\Users\*****\Documents\Arduino\Blynk_Edgent_ESP8266_3dp_new\Blynk_Edgent_ESP8266_3dp_new.ino: In function 'void loop()':
Blynk_Edgent_ESP8266_3dp_new:51:15: error: 'class Edgent' has no member named 'run'
51 | BlynkEdgent.run();
| ^~~
exit status 1
'class Edgent' has no member named 'begin'
#define BLYNK_TEMPLATE_ID "JHBKBFDS"
#define BLYNK_DEVICE_NAME "KJBSDKFJBSDF"
#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define APP_DEBUG
#include "BlynkEdgent.h"
#include <DHT.h>
#include <SPI.h>
#define DHTPIN 1
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
BLYNK_CONNECTED() {
Blynk.syncAll(); }
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;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V1, h); //V1 is for Humidity
Blynk.virtualWrite(V2, t); //V2 is for Temperature
}
void setup()
{
Serial.begin(115200);
delay(100);
BlynkEdgent.begin();
dht.begin();
timer.setInterval(10000L, sendSensor);
}
void loop() {
BlynkEdgent.run();
timer.run();
}
and another error now:
C:\Users\*****\Documents\Arduino\Blynk_Edgent_ESP8266_3dp_new\Blynk_Edgent_ESP8266_3dp_new.ino: In function 'void setup()':
Blynk_Edgent_ESP8266_3dp_new:45:3: error: '' was not declared in this scope
45 | BlynkEdgent.begin();
|
C:\Users\******\Documents\Arduino\Blynk_Edgent_ESP8266_3dp_new\Blynk_Edgent_ESP8266_3dp_new.ino: In function 'void loop()':
Blynk_Edgent_ESP8266_3dp_new:51:15: error: 'class Edgent' has no member named 'run'
51 | BlynkEdgent.run();
| ^~~
exit status 1
'' was not declared in this scope
i need to add DHT temperature sensor. Is there already included SPI in this firmware? also, if that possible to define pins for DHT sensor from web interface, or i need to do that in sketch?
thanks all for help. but still got couple questions. sorry
seems, device remember last state before it powered down… while at this offline time - switch state changed. so when it back online - it got prev state of switch. how to do all switches sync, when device is going powered? BLYNK_CONNECTED() { Blynk.syncAll(); } not helped me at all… there no option, for switches, to sync - in web dashboard editor…
Yes, you told me that already. But there no such option for switches. Only for digit values, in my case. Switches either in datastream tab… I need so switches sync too. There was, such option, in old code…