arduino ide - ESP32 devkit v1 OTA via internet (HTTPS) looping back and load .bin file every 5 second from website

61 views Asked by At

I am trying to upload the .bin file via my website, so that I was testing many libraries today, and after all day long I found this example code from ESP32httpUpdate library example > httpUpdate.ino file code. I was already trying this all OTA library examples: HttpsOTAUpdate > HTTPS_OTA_Update.ino and Arduino_ESP32_OTA > OTA_Arduino_Server.ino. None of this are working.

So ESP32httpUpdate library example > httpUpdate.ino file code can load the .bin file from my website, but the problem I am facing right now is that this code loop back every 5 second and load the file again and again. This is the code:

#include <Arduino.h>

#include <WiFi.h>

#include <HTTPClient.h>
#include <ESP32httpUpdate.h>

#define USE_SERIAL Serial

#define LEDSS 2

void setup() {
    pinMode(LEDSS, OUTPUT);
    USE_SERIAL.begin(115200);
    // USE_SERIAL.setDebugOutput(true);

    USE_SERIAL.println();
    USE_SERIAL.println();
    USE_SERIAL.println();

    for(uint8_t t = 4; t > 0; t--) {
        USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
        USE_SERIAL.flush();
        delay(1000);
    }

    WiFi.begin("JANINA", "sayma01720");

}

void loop() {
    // wait for WiFi connection
    if((WiFi.status() == WL_CONNECTED)) {

        t_httpUpdate_return ret = ESPhttpUpdate.update("https://dibliotlab.xyz/codes/test3.ino.bin");

        switch(ret) {
            case HTTP_UPDATE_FAILED:
                USE_SERIAL.printf("HTTP_UPDATE_FAILD Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
                break;

            case HTTP_UPDATE_NO_UPDATES:
                USE_SERIAL.println("HTTP_UPDATE_NO_UPDATES");
                break;

            case HTTP_UPDATE_OK:
                USE_SERIAL.println("HTTP_UPDATE_OK");
                break;
        }
    }

  digitalWrite(LEDSS, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(500);                      // wait for a second
  digitalWrite(LEDSS, LOW);   // turn the LED off by making the voltage LOW
  delay(1000); 

}

It someone know where I did wrong or where I should have to update the code, please let me know.

0

There are 0 answers