Missing libraries when using BlynkEdgent whith Arduino Mega 2560 & ESP8266 shield

Hello.
I tried to run BlynkEdgent for ESP8266 from Arduino IDE, but errors appeared during compilation: a lot of ‘h’ libraries are missing. Where can I get the full package of these libraries?
Thanks.

Edgent isn’t compatible with the Mega/Uno/Nano boards when using an ESP-01 as a WiFi modem in AT mode.

If you want to use the Edgent features such as Dynamic Provisioning, Blynk.Air and remote reboot then you should probably switch to using a NodeMCU or ESP32.

https://docs.blynk.io/en/blynk.edgent/supported-boards

Pete.

OK, thanks for information. So my initial problem is still present: when using the template ‘Quickstart Device’ (Arduino Mega 2560 + ESP8266), the Static IP address is always set to ‘85.xxx.xxx.xxx’ and the Arduino console is freezed to ‘Connected to wifi’. And on the Blynk Console or on my phone, the device is always ‘Off line’.
I think my box is blocking this kind of IP address. So is there a solution to fix an IP address corresponding to my local network?

Can you provide more details please ?
Something like wiring diagram, library version, etc…

The Quickstart wizard doesn’t give the option to choose “Arduino Mega 2560 + ESP8266”. Do you mean the Sketchbuilder example with “Arduino Mega 2560” as the board type and “ESP8266 WiFi Shield” as your connection type and “Blynk Simple Demo” as the example?

What does your serial monitor show?

Pete.

Yes Pete. I don’t remember the example as I not at home. I will give you the information this evening (@french time).
Herve

Hi Pete.
I downloaded again the Sketchbuilder example with “Arduino Mega 2560” as the board type and “ESP8266 WiFi Shield” as my connection type and “Blynk Simple Demo” as example.
The serial monitor shows:

[9] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.0.1 on Arduino Mega

[517] Connecting to WiFi_HLA
[3568] AT version:1.7.4.0(May 11 2020 19:13:04)
SDK version:3.0.4(9532ceb)
compile time:May 27 2020 10:12:22
Bin version(Wroom 02):1.7.4
OK
[8628] +CIFSR:STAIP,"87.105.70.105"
+CIFSR:STAMAC,"50:02:91:79:2d:aa"
[8629] Connected to WiFi

And that’s all, nothing else!

What is strange is the IP address ‘87.105.70.105’. Do you have any idea?

Note: I tried before with a simple connection between the Arduino board and the ESP shiled, and the communication is OK with AT commands.

I have no idea why your router is allocating this IP address, but that’s why it’s failing to connect to Blynk.
It appears to be an issue with either your ESP-01 or your router.

Pete.

Hi Pete.
Thanks for your reply. I’ll try to affect a static IP with my previous code and will let you know if it’s better or not.
Herve

Hi Pete.
After several tests, it’s seems to be OK for the IP address, but now I’ve got the message ‘Invalid auth token’


/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v1.0.1 on Arduino Mega

[8441] Connecting to WiFi_HLA
[11493] AT version:1.7.4.0(May 11 2020 19:13:04)
SDK version:3.0.4(9532ceb)
compile time:May 27 2020 10:12:22
Bin version(Wroom 02):1.7.4
OK
[18567] +CIFSR:STAIP,“192.168.1.6”
+CIFSR:STAMAC,“00:00:00:00:57:69”
[18567] Connected to WiFi
[28701] Invalid auth token
[51710] Invalid auth token
[74721] Invalid auth token

I tried several sketches but the issue is still present. As you can on the below picture, my ESP is seen by my Box (ESP-POOLMETER).

image

Do you have any idea to help me?

Thanks,
Herve

Posting your sketch might help.
also make sure that you’re using the right auth token, it can be found here

Yes, token is OK. I alreday pasted it from dashboard.

My sketch is the following :slight_smile:

/*************************************************************
  WARNING!
    It's very tricky to get it working. Please read this article:
    http://help.blynk.cc/hardware-and-libraries/arduino/esp8266-with-at-firmware

  This is a simple demo of sending and receiving some data.
  Be sure to check out other examples!
 *************************************************************/


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL-WSYBYxx"
#define BLYNK_DEVICE_NAME "Quickstart Template"

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings

const char* BLYNK_AUTH_TOKEN  = "xxxxxxxxxxxxxxxxxxxxx";
//const char* BLYNK_DOMAIN = "blynk.cloud"; // Domaine Blynk
const char* BLYNK_DOMAIN = "139.59.206.133"; // Blynk Domain
uint16_t BLYNK_PORT = 8442; // Blynk Port
const char* ESP_SSID = "WiFi_HLA"; // SSID WiFi
const char* ESP_PASS = "xxxxxxxxxxxxxxxxxxx"; // WiFi Password

#include <ESP8266_HLA.h> // My ESP8266 library based on ESP8266_lib.h
#include <BlynkSimpleShieldEsp8266.h>

// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial1

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 BLYNK_WIFI(&EspSerial);
ESP8266_HLA wifi(&Serial1, &Serial, "-1");

BlynkTimer timer;

// This function is called every time the Virtual Pin 0 state changes
BLYNK_WRITE(V0)
{
  // Set incoming value from pin V0 to a variable
  int value = param.asInt();

  // Update state
  Blynk.virtualWrite(V1, value);
}

// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
{
  // Change Web Link Button message to "Congratulations!"
  Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
  Blynk.setProperty(V3, "onImageUrl",  "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
  Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}

// This function sends Arduino's uptime every second to Virtual Pin 2.
void myTimerEvent()
{
  Blynk.virtualWrite(V2, millis() / 1000);
}

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

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  wifi.softReset(); // Sw Reset of ESP module
  delay(1000);
  wifi.wifiModeStation(); // Station Mode
  wifi.closeAP(); // Close connection if already connected
  wifi.connectToAP(ESP_SSID, ESP_PASS); // WiFi connection
  wifi.espName(); // Define ESP Host name
  Blynk.begin(BLYNK_AUTH_TOKEN, BLYNK_WIFI, ESP_SSID, ESP_PASS, BLYNK_DOMAIN, BLYNK_PORT);
  
//   Setup a function to be called every second
    timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run();
  delay(100);
  if (Serial.available()) {
    Serial1.println(Serial.read());
  }
  if (Serial1.available()) {
    Serial.println(Serial1.read());
  }

}

Please edit your post and add triple backticks ( ``` ) before and after your sketch.

Done!

No. Despite @John93 giving you triple backticks to copy/paste, you decided to use different characters instead.
Please try again.

Pete.

OK, Pete. Is it OK now?

Herve.

Yes.

The reason for your “Invalid auth token” message is that you are instructing the device to connect to the Legacy cloud server in Frankfurt (139.59.206.133).
This server knows nothing about your Blynk IoT Cloud account, so it doesnt recognise your auth token - hence the message.

You are also instructing your device to use port 8442, when this should be port 80 or 8080

Remove this line…

const char* BLYNK_DOMAIN = “139.59.206.133”; // Blynk Domain

Un-comment this line…

//const char* BLYNK_DOMAIN = “blynk.cloud”; // Domaine Blynk

and change this line to 80 or 8080…

uint16_t BLYNK_PORT = 8442; // Blynk Port

In addition, this sounds like a very bad idea…

#include <ESP8266_HLA.h> // My ESP8266 library based on ESP8266_lib.h

The rest of your sketch is a mess!

I’s start by removing this…

wifi.softReset(); // Sw Reset of ESP module
delay(1000);
wifi.wifiModeStation(); // Station Mode
wifi.closeAP(); // Close connection if already connected
wifi.connectToAP(ESP_SSID, ESP_PASS); // WiFi connection
wifi.espName(); // Define ESP Host name

and this…

delay(100);
if (Serial.available()) {
Serial1.println(Serial.read());
}
if (Serial1.available()) {
Serial.println(Serial1.read());
}

then you might make some progress if you use the proper Blynk libraries.

Pete.

2 Likes

Great! It’s now functionning, thanks a lot Pete.
For your information, I used the 8442 port cause I saw it in another post as a solution, but finally that seems not to be the case!
For the other lines using wifi.xxx, this is the only solution I found to get a correct IP different from “87.105.70.105”, but you’re right that I maybe not use correctly the official lybrary…
And the last lines are for typing directly text in the console.
Herve.

8442 is the port for legacy local server.

Why do you want to do that?

Pete.

OK port the leagcy port.

By typing text in the console, I wanted to send another commands to the ESP to see if the module was alive :slight_smile: