Migrating to new app? Code updates

Hey there.
I’m using old blynk app on my phone, with my esp8266 controlling couple devices. What I want to ask, is:

  1. I heard old app soon will be not supported? Is that really necessary to migrate?
  2. I want to add, to esp8266 firmware - OTA firmware update and widget sync (so devices will sync last virtual button states, from app).
  3. 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.

Pete.

1 Like

i changed code from Edgent example. Others tabs i left unchanged, except wifi_ap_ip, in settings.h. check, please:

#define BLYNK_TEMPLATE_ID "KIJNINDF***"
#define BLYNK_DEVICE_NAME "JUHBGASJHBFA****"

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define APP_DEBUG

char auth[] = "UYBUSADFUYBUASDO*******";
char ssid[] = "KJKJASD******";
char pass[] = "KJHASD*****";

#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);

   Edgent.begin(auth, ssid, pass);
   dht.begin();
   timer.setInterval(10000L, sendSensor);
}

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

first, If you would like to use blynk edgent, you don’t have to add WIFI SSID and password.
Check this out

second,

Should be

 
 ​  BlynkEdgent.​begin​();

and

Should be

BlynkEdgent.​run​();
1 Like

got it.
but im getting error:

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​'

Can you post the sketch you’re using please ?

#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

How many tabs are visible in your arduino IDE before you upload the code. My guess is that the edgent tab is missing.

Take a brand new Edgent template and add-in just your BLYNK_TEMPLATE_ID and BLYNK_DEVICE_NAME then compile the sketch.

Pete.

1 Like

that worked.
guess, i can change firmware by OTA?

You could, if you wish, but the important part is that you don’t break your working setup when adding-in your additional code.

Pete.

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?

No, but you’d know that if you searched the sketch.

No.

Yes, in exactly the same way as before.

Pete.

1 Like

thanks all for help. but still got couple questions. sorry :slight_smile:
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…

Pete.

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…

Post a screenshot of your datastream configuration in the web console.

Pete.


If that, what you meant

Like this