Dear friends,
I’m trying from weeks to update my firmware via OTA, but I can’t
Is it this guide still valid? OTA: Firmware Over-The-Air updates - Blynk Documentation
The question is: if I upload in my ESP8266 the example Blynk Edgent_ESP8266 how can Blynk found my device to update new firmawre??
Can please someone give me a guide step by step? I’m using Blynk from 4 years, but the OTA still for me a big problem.
Thank you!
Yes.
You obviously need to upload the initial sketch via USB and go through the “+ Add Device” process to provision it and get it online.
After that the device is talking to the Blynk server and the server triggers the update.
Pete.
Dear Pete, thank you!
Now the firmware is right uploaded via OTA, but when device reboot it is always in “off line” mode.
In my software I obviously added the right Auth_Token (generated in automatic by “+ Add Device” process).
Hereafter what serial monitor shows:
[881127] RUNNING => OTA_UPGRADE
[881127] Disconnected
[881128] OTA: http://fra1.blynk.cloud/static/fw_12382189385875925449_-838595071.bin?token=0HIx0K8rK7gsXRMcSnT5DpKnv-vN5n4S
[881134] Connecting to fra1.blynk.cloud:80
[881311] Expected MD5: 39e48e12ca065448ac04686a5dd1dc56
[881311] Flashing…
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%
[895642] === Update successfully completed. Rebooting.
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 3460, room 16
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4
tail 4
chksum 0xc9
csum 0xc9
v00071e20
@cp:B0
ld
Did you add or remove any lines/functions in the code before performing OTA?
If yes, then that particular lines may be causing the issue.
Try to upload the same code via USB. I think that will crash the device too.
You’re right! Trying to upload the same firmware via USB, the device is still in off line.
I’m goin to check any single lines and also to change hardware (now using Lolin D1 mini pro)
Thanks!
Are you saying that you added the Blynk Auth token to your sketch?
If so, this is your problem.
Pete.
The question is: have I to add my own code in Blynk.Edgent sketch (like online guide show) or have I to write a new one sketch? I’m confusing…
I don’t know what this means.
I’d suggest you give a yes/no answer to this question…
Pete.
yes
Okay.
Blynk Edgent automatically assigns an Auth token during the “+ Add Device” process in the app.
This Auth token, and the WiFi credentials are stored in EEPROM and persist until you reconfigure the device via the app, or clear the stored data by pressing and holding the physical button (defined in Settings.h) for 10 seconds.
You should NOT manually insert an Auth token into Edgent sketch, as it screws-up this process.
The ONLY thing you need to add to the Edgent sketch are the TWO lines of firmware configuration info from the TEMPLATE view in the web console.
(Not the three lines of config info from the Device view).
Pete.
Have you made any major changes to your firmware? Or changed auth token ?
I guess your board is not booting at all.
Okay Pete, this is very clear.
Now i’m just added a new device and the Auth token and WIFI credentials has been stored into EEPROM correctly.
In next step suppose that I would like to upload via OTA this new device with the follow my own simply code:
#define BLYNK_FIRMWARE_VERSION "2.0.0"
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define pinout_d1 D1
#define pinout_d5 D5
void setup()
{
pinMode(pinout_d1, OUTPUT);
pinMode(pinout_d5, OUTPUT);
}
BLYNK_WRITE(V1) // Pulsante Widget scrive sul Virtual Pin V1
{
boolean valore = param.asInt();
if (valore == 1) {
digitalWrite(pinout_d1, HIGH);
}
else {
digitalWrite(pinout_d1, LOW);
}
}
BLYNK_WRITE(V5) // Pulsante Widget scrive sul Virtual Pin V5
{
boolean valore = param.asInt();
if (valore == 1) {
digitalWrite(pinout_d5, HIGH);
}
else {
digitalWrite(pinout_d5, LOW);
}
}
void loop()
{
Blynk.run();
}
In witch way i must proceed now?? I tried to compile this code and ship the BIN file via OTA. The firmware is correctly sent, but the the device goes in off line and can’t connect to Blynk server anymore.
I also tried to implement this simple code in Edgent sketch, but some errors rises up during compiling.
The code you posted is missing the firmware configuration lines at the beginning, so won’t upload via Blynk.Air anyway.
Also, your sketch has no code to read the credentials stored in the ERPROM and use them, which is why it’s not able to get online. It also has no Blynk.Air code, so even if it did get online it could never be updated OTA again.
You need to upload the Edgent sketch via OTA for everything to work.
Normal procedure would be to take the Edgent example, modify it to incorporate your own functionality, upload the sketch via USB, provision the device via the app and perform testing.
If you need to make a minor tweak or bug-fix to the code you uploaded via USB, and you want to do this via OTA then you increment the BLYNK_FIRMWARE_VERSION value and deploy the tweaked sketch.
You need to post that sketch, along with details of the compiler error messages.
Pete.
Pete, I followed your procedure. I modified the Edgent example adding my own functionality (on-off of 2 relays) as hereafter:
#define BLYNK_TEMPLATE_ID "TMPLdG8Tralu"
#define BLYNK_DEVICE_NAME "OTATest"
#define BLYNK_FIRMWARE_VERSION "2.0.0"
#define BLYNK_PRINT Serial
#define APP_DEBUG
//#define BLYNK_DEBUG
// Uncomment your board, or configure a custom board in Settings.h
//#define USE_SPARKFUN_BLYNK_BOARD
//#define USE_NODE_MCU_BOARD
//#define USE_WITTY_CLOUD_BOARD
#include "BlynkEdgent.h"
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define pinout_d1 D1
#define pinout_d5 D5
void setup()
{
Serial.begin(115200);
delay(100);
BlynkEdgent.begin();
pinMode(pinout_d1, OUTPUT);
pinMode(pinout_d5, OUTPUT);
}
BLYNK_WRITE(V1) // Pulsante Widget scrive sul Virtual Pin V1
{
boolean valore = param.asInt();
if (valore == 1) {
digitalWrite(pinout_d1, HIGH);
}
else {
digitalWrite(pinout_d1, LOW);
}
}
BLYNK_WRITE(V5) // Pulsante Widget scrive sul Virtual Pin V5
{
boolean valore = param.asInt();
if (valore == 1) {
digitalWrite(pinout_d5, HIGH);
}
else {
digitalWrite(pinout_d5, LOW);
}
}
void loop() {
BlynkEdgent.run();
Blynk.run();
}
When I’m going to compile, this errors are shown:
In file included from C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\BlynkEdgent.h:21,
from C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\test_OTA.ino:15:
C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\ResetButton.h: In function ‘void button_init()’:
C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\ResetButton.h:51:37: warning: ‘void button_change()’ is deprecated: Use IRAM_ATTR in place of ICACHE_RAM_ATTR to move functions into IRAM [-Wdeprecated-declarations]
51 | attachInterrupt(BOARD_BUTTON_PIN, button_change, CHANGE);
| ^~~~~~~~~~~~~
C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\ResetButton.h:20:6: note: declared here
20 | void button_change(void)
| ^~~~~~~~~~~~~
C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\ResetButton.h:51:58: warning: ‘void button_change()’ is deprecated: Use IRAM_ATTR in place of ICACHE_RAM_ATTR to move functions into IRAM [-Wdeprecated-declarations]
51 | attachInterrupt(BOARD_BUTTON_PIN, button_change, CHANGE);
| ^
C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\ResetButton.h:20:6: note: declared here
20 | void button_change(void)
| ^~~~~~~~~~~~~
In file included from C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\test_OTA.ino:17:
C:\Users\Administrator\Desktop\Progetti Arduino Lollo\libraries\arduino_292481\src/BlynkSimpleEsp8266.h: At global scope:
C:\Users\Administrator\Desktop\Progetti Arduino Lollo\libraries\arduino_292481\src/BlynkSimpleEsp8266.h:29:7: error: template argument required for ‘class BlynkWifi’
29 | class BlynkWifi
| ^~~~~~~~~
C:\Users\Administrator\Desktop\Progetti Arduino Lollo\libraries\arduino_292481\src/BlynkSimpleEsp8266.h:99:19: error: conflicting declaration ‘WiFiClient _blynkWifiClient’
99 | static WiFiClient _blynkWifiClient;
| ^~~~~~~~~~~~~~~~
In file included from C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\BlynkEdgent.h:9,
from C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\test_OTA.ino:15:
C:\Users\Administrator\Desktop\Progetti Arduino Lollo\libraries\arduino_292481\src/BlynkSimpleEsp8266_SSL.h:191:25: note: previous declaration as ‘BearSSL::WiFiClientSecure _blynkWifiClient’
191 | static WiFiClientSecure _blynkWifiClient;
| ^~~~~~~~~~~~~~~~
In file included from C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\test_OTA.ino:17:
C:\Users\Administrator\Desktop\Progetti Arduino Lollo\libraries\arduino_292481\src/BlynkSimpleEsp8266.h:100:27: error: conflicting declaration ‘BlynkArduinoClient _blynkTransport’
100 | static BlynkArduinoClient _blynkTransport(_blynkWifiClient);
| ^~~~~~~~~~~~~~~
In file included from C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\BlynkEdgent.h:9,
from C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\test_OTA.ino:15:
C:\Users\Administrator\Desktop\Progetti Arduino Lollo\libraries\arduino_292481\src/BlynkSimpleEsp8266_SSL.h:192:51: note: previous declaration as ‘BlynkArduinoClientSecureBearSSL::WiFiClientSecure _blynkTransport’
192 | static BlynkArduinoClientSecure _blynkTransport(_blynkWifiClient);
| ^~~~~~~~~~~~~~~
In file included from C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\test_OTA.ino:17:
C:\Users\Administrator\Desktop\Progetti Arduino Lollo\libraries\arduino_292481\src/BlynkSimpleEsp8266.h:101:11: error: conflicting declaration ‘BlynkWifi<…auto…> Blynk’
101 | BlynkWifi Blynk(_blynkTransport);
| ^~~~~
In file included from C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\BlynkEdgent.h:9,
from C:\Users\Administrator\Desktop\Progetti Arduino Lollo\test_OTA\test_OTA.ino:15:
C:\Users\Administrator\Desktop\Progetti Arduino Lollo\libraries\arduino_292481\src/BlynkSimpleEsp8266_SSL.h:193:56: note: previous declaration as ‘BlynkWifi<BlynkArduinoClientSecureBearSSL::WiFiClientSecure > Blynk’
193 | BlynkWifi<BlynkArduinoClientSecure > Blynk(_blynkTransport);
| ^~~~~
Più di una libreria trovata per “BlynkSimpleEsp8266_SSL.h”
Usata: C:\Users\Administrator\Desktop\Progetti Arduino Lollo\libraries\arduino_292481
Non usata: C:\Users\Administrator\Desktop\Progetti Arduino Lollo\libraries\arduino_347498
Non usata: C:\Users\Administrator\Desktop\Progetti Arduino Lollo\libraries\arduino_315347
exit status 1
Errore durante la compilazione per la scheda LOLIN(WEMOS) D1 R2 & mini.
It’s difficult to tell what’s happening here, but it looks like you’ve modified some of the .h files in the Edgent example.
I’d start by going to Files > Examples > Blynk in the IDE and selecting the Edgent example for your ESP8266 board, then adding-in your Template_ID and Device_ID and un-commenting this line…
//#define USE_WEMOS_D1_MINI
and compiling the sketch.
Pete.