Server OTA support for ESP8266

@Jamin what curl command do you use so I can double check.

curl -v -F file=@Project-Unicorn-Provisioning.ino.adafruit.bin --insecure -u admin@blynk.cc:admin https://192.168.1.2:9443/admin/ota/start

I don’t know. It is not the server. I have tests for that. Maybe you are using old sketch? I remember it was in some version of sketch.

I have used the one that comes the with blynk library. But I did see that the OTA file was updated on the github repo so i tried using that version too with the same results.

This is definitely something with the sketch. The server doesn’t have “auth” param at all. And on hardware we had

  overTheAirURL = param.asString();
  overTheAirURL += String("?auth=") + configStore.cloudToken;

Please double check you uploaded correct and latest sketch.

3 posts were merged into an existing topic: Does Auth Token or Account Login have expiry

Hi @Dmitriy. Is there an intention to allow updates to devices using the blynk OTA option if I am not a business user and don’t have my own server. I.e. update over the blynk cloud. I only ask as I have devices on my network which don’t show up on my ide due to AP issues. My pc needs to be attached to specific APs on my network to see a device for the update to happen. This means me physically moving my pc around the property. :scream::joy:. I am using wemos and am using the wifimanager OTA function.

Hello @Dmitriy,

Can i use “server ota updates” in my private server OR should i be a business customer?

@ekeloglu you can use it on the local server. I’m not sure we have full documentation for that. However, you may try.

Hello Dmitriy

Thanks for the feedback.

Actually i tried it on my local server (a running remote VPS), i could managed to send curl command to specific device with specific token, but after the command sent, my wemos led turned into blue, lost blynk local server connection and no firmware downloaded

after i reset wemos, everything went normal. But of course without new firmware.

Anyway, i did not want to go into details and spent hours before being sure about that OTA updates can be achieved on local servers. Now i will give new tries.

If i can not manage to run blynk ota update, i will stay with esp8266 http updates.

Thanks a lot again.

Hello again @Dmitriy,

I could manage to upload new firmware with curl command by modifiying ota.h as below and i just included ota.h to my main program.

added below line to main program,

#include "OTA.h"

i just edited OTA.h as below in order to use it without Blynk Provisioning template. After editing OTA.h,

curl -v -F file=@Template_ESP8266.ino.nodemcu.bin --insecure -u admin@blynk.cc:admin https://localhost:9443/admin/ota/start?token=123

command worked like a charm.

On that point i have one question for you,

In my “OTA.h”, if i would use,

ESPhttpUpdate.update(overTheAirURL, BOARD_FIRMWARE_VERSION)

instead of

ESPhttpUpdate.update(overTheAirURL)

how ESPhttpUpdate command in ESP8266 code will check and compare firmware version from server side? Does blynk server keep a file which contains firmware information based on tokens? I just could not understand that how firmware version is compared between server side and mcu side?

By the way, it would be great to add an options to curl command which enables to send firmware to devices based on “tags”. Lets say, i have 100 devices in my project and 70 of them are temperature sensors and running same code and 30 of them pressure sensors which are running different code than temperature sensors. In my project i have two tags → “temp” and “pressure”. If there would be a command like below which ends /ota/start?tag=temp, it would be great to send firmware 70 pcs of temperature sensor without sending curl commands with 70 different tokens separately.

curl -v -F file=@Template_ESP8266.ino.nodemcu.bin --insecure -u admin@blynk.cc:admin https://localhost:9443/admin/ota/start?**_tag=temp_**

Thanks a lot.

Here is my edited OTA.h

#include <ESP8266HTTPClient.h>
#include <ESP8266httpUpdate.h>

String overTheAirURL;


void enterOTA() {

  Serial.println(String("Firmware update URL: ") + overTheAirURL);
  switch (ESPhttpUpdate.update(overTheAirURL)) {
  case HTTP_UPDATE_FAILED:
    Serial.println(String("Firmware update failed (error ") + ESPhttpUpdate.getLastError() + "): " + ESPhttpUpdate.getLastErrorString());
    break;
  case HTTP_UPDATE_NO_UPDATES:
    Serial.println("No firmware updates available.");
    break;
  case HTTP_UPDATE_OK:
    Serial.println("Firmware update: OK.");
    delay(10);
    ESP.restart();
    break;
  }
}

BLYNK_WRITE(InternalPinOTA) {
  overTheAirURL = param.asString();

  // Disconnect, not to interfere with OTA process
  Blynk.disconnect();

  // Start OTA
  enterOTA();  
  delay(500);
}
1 Like

Yes. On login hardware sends additional info regarding firmware. The server stores this info. So server has firmware version and build date and it uses it for OTA.

currently we are working on web part. And all this will be implemented there. At some point :slight_smile:. As managing OTA without Web UI is very hard. It has so many info that it is hard to place on mobile.

Thanks for the replies @Dmitriy.

Since you do not go into details and sharing a complete documentation regarding OTA Server feature, i guess your team is still implementing full functionality to OTA server feature.

I will be waiting the news.

BR
Erdinc

Not exactly. OTA is ready. However, at the moment we are focused on web UI. Blynk app was developed for 3 years already. You can imagine how many work we have to do on web :slight_smile:.

Any estimated release date?

no :slight_smile:

I’m having errors uploading the OTA.h with the #include OTA.h command written into my sketch.

There is an error in the IDE when I write BLYNK_WRITE(InternalPinOTA)

The error says: expected constructor, destructor, or type conversion before ‘(’ token

Any thoughts? I’ve built my own local Blynk Server and other sketches work great on it. Just getting this OTA into my original sketch and then onto the NodeMCU is proving quite difficult. I have all the updated libraries, I believe (though that was a bit of an issue too).

could you paste your code here? Probably you are making a syntax error.

Yeahere’s the cod. It works itself but the problem is with the OTA.h file when I include it. Connecting to Blynk on my own local server worked perfectly. Just the inclusion of this OTA isn’t working, and it’s absolutely essential to to project.

The project is essentially having buzzers places all around the facility and from Blynk I am able to push start a melody of my choice.

Updating the melodies OTA will be important because there will probably be up to 40 NodeMCU’s

Any help would be really really appreciated! Thanks.


#include "OTA.h"
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "";

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


// notes in the melody:
int melody1[] = {
  NOTE_C5, NOTE_D5, NOTE_E5, NOTE_F5, NOTE_G5, NOTE_A5, NOTE_B5, NOTE_C6
};

int melody2[] = {
  NOTE_C5, NOTE_C5, NOTE_C5, NOTE_F5, NOTE_E5, NOTE_A5, NOTE_E5, NOTE_G6
};

int duration = 500;  // 500 miliseconds
void MelodyOne(){
 for(int i=0; i <= 15; i++){
    for (int thisNote = 0; thisNote < 8; thisNote++) {
    // pin8 output the voice, every scale is 0.5 sencond
    tone(D1, melody1[thisNote], duration);
     tone(D6, melody1[thisNote], duration);
    // Output the voice after several minutes
    delay(1000);
}
}}

void MelodyTwo(){
  for(int i=0; i <= 15; i++){
    for (int thisNote = 0; thisNote < 8; thisNote++) {
    // pin8 output the voice, every scale is 0.5 sencond
    tone(D1, melody2[thisNote], duration);
     tone(D6, melody2[thisNote], duration);
    // Output the voice after several minutes
    delay(1000);
  
}}}





BLYNK_WRITE(V1){
int i = param.asInt();

if(i==1){
  MelodyOne();
}
else{return;}
  
}

BLYNK_WRITE(V2){
int i = param.asInt();

if(i==1){
  MelodyTwo();
}
else{return;}
  
}
 
void setup() {
   Serial.begin(9600);

  Blynk.begin(auth, ssid, pass, "isblynk.isbologna.com", 8080);
}
 
void loop() {  
  Blynk.run();
}

I have deployed a blynk-server on my cloud server with docker.
I have added my droplet ip in the server.properties.
But the error is Firmware update URL: http://"159.89.20.XXX":8080/static/ota/FUp_10783858033040037488_upload.bin Firmware update failed (error -1): HTTP error: connection refused
The server ip is correct.
Can someone give me some hints how to fix this? Thanks