Migrating to the new version

Thank you

okay, have started to have a go at this and already come across a hurdle

BlynkEdgent.h: No such file or directory

How is this so if I have installed the latest library, restarted the IDE? If I go an Examples>Blynk>BlynkEdget it is there?

What’s have I missed?

Beggining of the code is this

#include <Blynk.h>
#define BLYNK_TEMPLATE_ID "xxx"
#define BLYNK_DEVICE_NAME "xxx"
#define BLYNK_FIRMWARE_VERSION        "0.1.0"
#include <BlynkSimpleEsp32.h>
#define APP_DEBUG
#include "BlynkEdgent.h"

I guess you’ve done something odd, like copying the Edgent_ESP32.ino file from the GitHub site without also copying all of the other Edgent files as well.

The easiest way is to go to File > Examples > Blynk > Blynk.Edgent and open the appropriate example (Edgent_ESP32 in your case).

This will then give you the appropriate tabs at the top of your sketch like this…

Pete.

so instead of editing my code, you suggest I copy my code over to the Edgent_ESP32 Example?

BTW I downloaded the zip from the github and then simply adding with sketch>include library>add .zip library. Then restarted the IDE

If you want to use Edgent then you need all of the supporting .h files, which appear in the tabs in the screenshot I provided.
If you want a simpler solution then do nothing other than adding the Template ID and Device Name lines to the top of your code and using the IoT Auth token.

Pete.

Thanks Pete, as Edgent is not important to me anyway that is what I have just tried to do.
Below is the latest code (I used the example from Blynk_WiFi>ESP32_Wifi).

The code uploaded ok, but just won’t connect and in the console it shows device is offline? What did I miss here? I have tripled checked my credentials, tried various ip addresses with the latest being 45.55.96.146. I have also restarted my router.

#define BLYNK_TEMPLATE_ID "xxx"
#define BLYNK_DEVICE_NAME "xxx"

#define BLYNK_FIRMWARE_VERSION        "0.1.0"
#define BLYNK_PRINT Serial


#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxx";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxx";
char pass[] = "xxx";



BlynkTimer timer;
BlynkTimer timer2;

const int relayPin = 2; //GPIO pin relay is attached to (D2)
const int btnPin = 14; //pin physical button is attached to. wired between GPIO14 (D5) and GND

int cycleState = LOW;
int btnState = HIGH;

float RunTime = 1;
int DelayTime = 1;

int timerId1;
int timerId2;
int timerId3;

int ReCnctFlag;  // Reconnection Flag
int ReCnctCount = 0;  // Reconnection counter

int onFlag = 0;

WidgetLED led1(V10);

// Every time we connect to the cloud...
BLYNK_CONNECTED() {
  // Request the latest state from the serverformula answer virtual pin write blynk flow rate
  Blynk.syncVirtual(V1, V2, V7);
  ReCnctCount = 0;

}

// When App button is pushed - switch the state. The button should be on virtual pin 7 and set to switch
BLYNK_WRITE(V7) {
  cycleState = param.asInt();

  if (cycleState == HIGH) {
    onFlag = 1;
    onRelay();

  }
  else if (cycleState == LOW) {
    onFlag = 0;
  }
}





void checkPhysicalButton()
{
  //Serial.println("BUTTON CHECK");
  if (digitalRead(btnPin) == LOW) {
    // btnState is used to avoid sequential toggles
    //Serial.println("BUTTON PRESSED");
    if (btnState != LOW) {

      // Toggle cycleState
      cycleState = !cycleState;
      Blynk.virtualWrite(V7, cycleState);
      if (cycleState == HIGH) {
        onFlag = 1;
        onRelay();
      }
      else if (cycleState == LOW) {
        onFlag = 0;
      }

    }
    btnState = LOW;
  }
  else {
    btnState = HIGH;
  }
}

BLYNK_WRITE (V1) // Time interval for misting 0.5-10 seconds
{
  RunTime = param.asFloat(); // assigning incoming value from pin V1 to a variable

  Serial.println(RunTime);
}



BLYNK_WRITE (V2) // Time interval for delay 5-120 seconds
{
  DelayTime = param.asInt(); // assigning incoming value from pin V2 to a variable

  Serial.println(DelayTime);
}








BLYNK_READ(V30) //Displays Wifi Strength as a % in the an the app (Value display setting widget) - Set to Virtual Pin 30
{
   Blynk.virtualWrite(V30, String("Wifi: ") + map(WiFi.RSSI(), -105, -40, 0, 100) + String('%'));
}









void onRelay()
{
  if (onFlag == 1) {
    timer.deleteTimer(timerId1);//delete timers in case they are still running, that is buttons turned on/off/on too fast
    timer.deleteTimer(timerId2);//delete timers in case they are still running, that is buttons turned on/off/on too fast
    digitalWrite(relayPin, HIGH); //turn relay ON
    led1.on();
    Serial.println("ON");  
    Serial.println((((RunTime/(RunTime+DelayTime)))*11*5.5));     
Blynk.virtualWrite(V8,(((RunTime/(RunTime+DelayTime)))*11*5.5));
Blynk.virtualWrite(V9,"L/Hr");
    timerId1 = timer.setTimeout(RunTime * 1000, offRelay); //run after
  }

}

void offRelay()
{
  digitalWrite(relayPin, LOW);//turn relay OFF
  led1.off();
  Serial.println("OFF");
  timerId2 = timer.setTimeout(DelayTime * 1000, onRelay); //run after
}

void setup()
{
  // Debug console
  Serial.begin(115200);

  pinMode(relayPin, OUTPUT);
  pinMode(btnPin, INPUT_PULLUP);
  digitalWrite(relayPin, LOW); //relay is active HIGH, start with relay OFF

  WiFi.begin(ssid, pass);  // Non-blocking if no WiFi available
  Blynk.config(auth, IPAddress(45,55,96,146), 8080);
  Blynk.connect();

  // Setup a function to be called every 100 ms
  timerId3 = timer2.setInterval(100L, checkPhysicalButton);
}

void loop()
{
  if (Blynk.connected()) {  // If connected run as normal
    Blynk.run();
  } else if (ReCnctFlag == 0) {  // If NOT connected and not already trying to reconnect, set timer to try to reconnect in 30 seconds
    ReCnctFlag = 1;  // Set reconnection Flag
    Serial.println("Starting reconnection timer in a moment...");
    timer2.setTimeout(30000L, []() {  // Lambda Reconnection Timer Function
      ReCnctFlag = 0;  // Reset reconnection Flag
      ReCnctCount++;  // Increment reconnection Counter
      Serial.print("Attempting reconnection #");
      Serial.println(ReCnctCount);
      Blynk.connect();  // Try to reconnect to the server
    });  // END Timer Function
  }
  timer.run();
  timer2.run();
}

a snippet from the serial monitor

[5145] Connecting to 45.55.96.146

[10146] Connecting to 45.55.96.146

[15147] Connecting to 45.55.96.146

Starting reconnection timer in a moment…

Attempting reconnection #1

[48144] Connecting to 45.55.96.146

[53145] Connecting to 45.55.96.146

[58146] Connecting to 45.55.96.146

[63147] Connecting to 45.55.96.146

Starting reconnection timer in a moment…

Attempting reconnection #2

[96144] Connecting to 45.55.96.146

[101145] Connecting to 45.55.96.146

[106146] Connecting to 45.55.96.146

[111147] Connecting to 45.55.96.146

Starting reconnection timer in a moment…

I am stuck on this.

Starting reconnection timer in a moment…

Attempting reconnection #4

[192143] Connecting to blynk-cloud.com:8080

[197144] Connecting to blynk-cloud.com:8080

[202145] Connecting to blynk-cloud.com:8080

[207146] Connecting to blynk-cloud.com:8080

Starting reconnection timer in a moment…

Attempting reconnection #5

[240143] Connecting to blynk-cloud.com:8080

[245144] Connecting to blynk-cloud.com:8080

[250145] Connecting to blynk-cloud.com:8080

[255146] Connecting to blynk-cloud.com:8080

Starting reconnection timer in a moment…

Attempting reconnection #6

[288143] Connecting to blynk-cloud.com:8080

[293144] Connecting to blynk-cloud.com:8080

[298145] Connecting to blynk-cloud.com:8080

[303146] Connecting to blynk-cloud.com:8080

Starting reconnection timer in a moment…

Will blynk-cloud.com belongs to blynk legacy, in blynk IOT it’s blynk.cloud

Thanks - but why can’t I ping that?

That’s a type from @John93 it shold say blynk.cloud

However, you shouldn’t be hard-coding an IP address into your Blynk.config command, you should be doing this:

Blynk.config(auth, "blynk.cloud", 8080);

Pete.

1 Like

I fixed it, it was a mistake :sweat_smile:

1 Like

Fantastic!

all good now :slight_smile:

1 Like

Thank you anyway!

1 Like

Why does the slider function in ios not show the value like the legacy? The Web dashboard shows the value.

ok, realised I can add a value alongside it. Weird that the options are different to the web dashboard.

Do I need to change to the new app at all? I am using the local server.
Chris.

The new app is not compatible with your local server.

You will, at some point, find that the Legacy apps disappear from the app/play stores. If you are an Android user then this isn’t too bad, as you can keep the latest Legacy .apk file and use that on your device - until updates to the Android OS eventually break the Blynk functionality - so you’ll be forced to run the Blynk app on an old device.
If you’re an iOS users then life will be much more difficult, unless you jailbreak your device.

If using a cloud service rather than a local server is an option then I’d recommend migrating to Blynk IoT.

If you haven’t seen it already, you should ensure that you read this:

Pete.

Thanks very much for the info Peter. I was somewhat concerned that the Legacy app might be nobbled by an “update” and be rendered it inop. This happened to me with a postal company app (IOS), I think the app developer had an issue with the postal company and killed the app with an update.

I shall just have to hope that a future IOS update does not do the same. Have no plans to get a new IPhone or IPad.
I do not need the cloud version as only use Blynk app to monitor water tank levels and power consumption. Am very happy with the whole Blynk system and have learnt a lot from this forum.

As to the local server vulnerability, do I need to worry? My server is not accessible to the outside world, other than by VPN. It took me a long time to understand how to set up up and getting it running. I think I watched that UTube video with the charming lady about ten times.

Thanks again,

If you’re an iOS user (like me) then I think it will be a very real issue for Legacy users when the app disappears from the App Store.
The way that the Apple backup/restore/migrate process seems to work is that they backup a link to the app, as opposed to the app itself. This means that the app need to still exist in the app store for the process to work.

We’ve all experienced apps that stop working with the latest iOS update, and at some point in future that will almost certainly happen with the Blynk app.

That’s something you need to decide. If you are running your local server on a machine capable of running Java 11 then I’d say that you should upgrade to the latest local server release.

If you have a stable internet connection then I’d say that upgrading to the cloud IoT version is a good move,

Pete.