Skip to main content
added 868 characters in body; edited title
Source Link

Error occuroccurs when compilecompiling ESP32 self-update firmware code

when i write this code in esp8266, it's work fine. but when i tried that code in esp32 with some changes,it shows error on compile time:

board which i use : DOIT ESP32 DevKit v1

error is:

In file included from C:\Users\Gabbar Singh\Documents\Arduino\ESP32_OTA\ESP32_OTA.ino:5:0:
C:\Users\Gabbar Singh\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\HTTPUpdate\src/HTTPUpdate.h:47:6: error: exitmultiple statusdefinition 1of 'enum HTTPUpdateResult'
 enum HTTPUpdateResult {
    Error compiling for^
In boardfile DOITincluded ESP32from DEVKITC:\Users\Gabbar V1Singh\Documents\Arduino\ESP32_OTA\ESP32_OTA.ino:3:0:
boardC:\Users\Gabbar whichSingh\Documents\Arduino\libraries\ESP32httpUpdate\src/ESP32httpUpdate.h:59:6: inote: useprevious :definition DOIThere
 ESP32enum DevKitHTTPUpdateResult v1{
      ^
Multiple libraries were found for "WiFi.h"
 Used:C:\Users\GabbarSingh\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi
 Not used: C:\Program Files (x86)\Arduino\libraries\WiFi

and the last error is : exit status 1 Error compiling for board DOIT ESP32 DEVKIT V1.

Code:

#include <Update.h>
#include <WiFi.h>
#include <ESP32httpUpdate.h>
#include <WiFiClient.h>
#include <HTTPUpdate.h>
#include <HTTPClient.h>

#define LED_BUILTIN 2

const String FirmwareVer = {"1.4"};

#define URL_fw_Version "http://vadaliya2007.000webhostapp.com/atte/ota/version.txt"
#define URL_fw_Bin "http://vadaliya2007.000webhostapp.com/atte/ota/firmware.bin"
HTTPClient http;

const char* ssid = "Honor8X";
const char* password = "1414141414";

void FirmwareUpdate()
{
  http.begin(URL_fw_Version, "‎5b fb d1 d4 49 d3 0f a9 c6 40 03 34 ba e0 24 05 aa d2 e2 01"); // check version URL
  delay(100);
  int httpCode = http.GET();            // get data from version file
  delay(100);
  String payload;
  if (httpCode == HTTP_CODE_OK)         // if version received
  {
    payload = http.getString();  // save received version
    Serial.println(payload );
  }
  else
  {
    Serial.print("error in downloading version file:");
    Serial.println(httpCode);

  }

  http.end();
  if (httpCode == HTTP_CODE_OK)         // if version received
  {
    if (payload.equals(FirmwareVer) )
    {
      Serial.println("Device already on latest firmware version");
    }
    else
    {
      Serial.println("New firmware detected");
      WiFiClient client;

      // The line below is optional. It can be used to blink the LED on the board during flashing
      // The LED will be on during download of one buffer of data from the network. The LED will
      // be off during writing that buffer to flash
      // On a good connection the LED should flash regularly. On a bad connection the LED will be
      // on much longer than it will be off. Other pins than LED_BUILTIN may be used. The second
      // value is used to put the LED on. If the LED is on with HIGH, that value should be passed
      //ESPhttpUpdate.setLedPin(LED_BUILTIN, LOW);


      t_httpUpdate_return ret = ESPhttpUpdate.update(URL_fw_Bin, "", "‎5b fb d1 d4 49 d3 0f a9 c6 40 03 34 ba e0 24 05 aa d2 e2 01");

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

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

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

unsigned long previousMillis = 0;        // will store last time LED was updated
const long interval = 30000;

void repeatedCall() {
  unsigned long currentMillis = millis();
  if ((currentMillis - previousMillis) >= interval)
  {
    // save the last time you blinked the LED
    previousMillis = currentMillis;
    FirmwareUpdate();
  }
}


void setup()
{
  Serial.begin(115200);
  Serial.println("");
  Serial.println("Start");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print("O");
    delay(500);
  }
  Serial.println("Connected to WiFi");
  pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(100);                       // wait for a second
  repeatedCall();
}

Error occur when compile ESP32 self-update firmware code

when i write this code in esp8266, it's work fine. but when i tried that code in esp32 with some changes,it shows error on compile time:

error: exit status 1
       Error compiling for board DOIT ESP32 DEVKIT V1.
board which i use : DOIT ESP32 DevKit v1
 

#include <Update.h>
#include <WiFi.h>
#include <ESP32httpUpdate.h>
#include <WiFiClient.h>
#include <HTTPUpdate.h>
#include <HTTPClient.h>

#define LED_BUILTIN 2

const String FirmwareVer = {"1.4"};

#define URL_fw_Version "http://vadaliya2007.000webhostapp.com/atte/ota/version.txt"
#define URL_fw_Bin "http://vadaliya2007.000webhostapp.com/atte/ota/firmware.bin"
HTTPClient http;

const char* ssid = "Honor8X";
const char* password = "1414141414";

void FirmwareUpdate()
{
  http.begin(URL_fw_Version, "‎5b fb d1 d4 49 d3 0f a9 c6 40 03 34 ba e0 24 05 aa d2 e2 01"); // check version URL
  delay(100);
  int httpCode = http.GET();            // get data from version file
  delay(100);
  String payload;
  if (httpCode == HTTP_CODE_OK)         // if version received
  {
    payload = http.getString();  // save received version
    Serial.println(payload );
  }
  else
  {
    Serial.print("error in downloading version file:");
    Serial.println(httpCode);

  }

  http.end();
  if (httpCode == HTTP_CODE_OK)         // if version received
  {
    if (payload.equals(FirmwareVer) )
    {
      Serial.println("Device already on latest firmware version");
    }
    else
    {
      Serial.println("New firmware detected");
      WiFiClient client;

      // The line below is optional. It can be used to blink the LED on the board during flashing
      // The LED will be on during download of one buffer of data from the network. The LED will
      // be off during writing that buffer to flash
      // On a good connection the LED should flash regularly. On a bad connection the LED will be
      // on much longer than it will be off. Other pins than LED_BUILTIN may be used. The second
      // value is used to put the LED on. If the LED is on with HIGH, that value should be passed
      //ESPhttpUpdate.setLedPin(LED_BUILTIN, LOW);


      t_httpUpdate_return ret = ESPhttpUpdate.update(URL_fw_Bin, "", "‎5b fb d1 d4 49 d3 0f a9 c6 40 03 34 ba e0 24 05 aa d2 e2 01");

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

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

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

unsigned long previousMillis = 0;        // will store last time LED was updated
const long interval = 30000;

void repeatedCall() {
  unsigned long currentMillis = millis();
  if ((currentMillis - previousMillis) >= interval)
  {
    // save the last time you blinked the LED
    previousMillis = currentMillis;
    FirmwareUpdate();
  }
}


void setup()
{
  Serial.begin(115200);
  Serial.println("");
  Serial.println("Start");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print("O");
    delay(500);
  }
  Serial.println("Connected to WiFi");
  pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(100);                       // wait for a second
  repeatedCall();
}

Error occurs when compiling ESP32 self-update firmware code

when i write this code in esp8266, it's work fine. but when i tried that code in esp32 with some changes,it shows error on compile time:

board which i use : DOIT ESP32 DevKit v1

error is:

In file included from C:\Users\Gabbar Singh\Documents\Arduino\ESP32_OTA\ESP32_OTA.ino:5:0:
C:\Users\Gabbar Singh\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\HTTPUpdate\src/HTTPUpdate.h:47:6: error: multiple definition of 'enum HTTPUpdateResult'
 enum HTTPUpdateResult {
      ^
In file included from C:\Users\Gabbar Singh\Documents\Arduino\ESP32_OTA\ESP32_OTA.ino:3:0:
C:\Users\Gabbar Singh\Documents\Arduino\libraries\ESP32httpUpdate\src/ESP32httpUpdate.h:59:6: note: previous definition here
 enum HTTPUpdateResult {
      ^
Multiple libraries were found for "WiFi.h"
 Used:C:\Users\GabbarSingh\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi
 Not used: C:\Program Files (x86)\Arduino\libraries\WiFi

and the last error is : exit status 1 Error compiling for board DOIT ESP32 DEVKIT V1.

Code:

#include <Update.h>
#include <WiFi.h>
#include <ESP32httpUpdate.h>
#include <WiFiClient.h>
#include <HTTPUpdate.h>
#include <HTTPClient.h>

#define LED_BUILTIN 2

const String FirmwareVer = {"1.4"};

#define URL_fw_Version "http://vadaliya2007.000webhostapp.com/atte/ota/version.txt"
#define URL_fw_Bin "http://vadaliya2007.000webhostapp.com/atte/ota/firmware.bin"
HTTPClient http;

const char* ssid = "Honor8X";
const char* password = "1414141414";

void FirmwareUpdate()
{
  http.begin(URL_fw_Version, "‎5b fb d1 d4 49 d3 0f a9 c6 40 03 34 ba e0 24 05 aa d2 e2 01"); // check version URL
  delay(100);
  int httpCode = http.GET();            // get data from version file
  delay(100);
  String payload;
  if (httpCode == HTTP_CODE_OK)         // if version received
  {
    payload = http.getString();  // save received version
    Serial.println(payload );
  }
  else
  {
    Serial.print("error in downloading version file:");
    Serial.println(httpCode);

  }

  http.end();
  if (httpCode == HTTP_CODE_OK)         // if version received
  {
    if (payload.equals(FirmwareVer) )
    {
      Serial.println("Device already on latest firmware version");
    }
    else
    {
      Serial.println("New firmware detected");
      WiFiClient client;

      // The line below is optional. It can be used to blink the LED on the board during flashing
      // The LED will be on during download of one buffer of data from the network. The LED will
      // be off during writing that buffer to flash
      // On a good connection the LED should flash regularly. On a bad connection the LED will be
      // on much longer than it will be off. Other pins than LED_BUILTIN may be used. The second
      // value is used to put the LED on. If the LED is on with HIGH, that value should be passed
      //ESPhttpUpdate.setLedPin(LED_BUILTIN, LOW);


      t_httpUpdate_return ret = ESPhttpUpdate.update(URL_fw_Bin, "", "‎5b fb d1 d4 49 d3 0f a9 c6 40 03 34 ba e0 24 05 aa d2 e2 01");

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

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

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

unsigned long previousMillis = 0;        // will store last time LED was updated
const long interval = 30000;

void repeatedCall() {
  unsigned long currentMillis = millis();
  if ((currentMillis - previousMillis) >= interval)
  {
    // save the last time you blinked the LED
    previousMillis = currentMillis;
    FirmwareUpdate();
  }
}


void setup()
{
  Serial.begin(115200);
  Serial.println("");
  Serial.println("Start");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print("O");
    delay(500);
  }
  Serial.println("Connected to WiFi");
  pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(100);                       // wait for a second
  repeatedCall();
}
edited title
Link

Error :ESP32occur when compile ESP32 self-update firmware updatecode

Source Link

Error :ESP32 self-update firmware update

when i write this code in esp8266, it's work fine. but when i tried that code in esp32 with some changes,it shows error on compile time:

error: exit status 1
       Error compiling for board DOIT ESP32 DEVKIT V1.
board which i use : DOIT ESP32 DevKit v1
 

#include <Update.h>
#include <WiFi.h>
#include <ESP32httpUpdate.h>
#include <WiFiClient.h>
#include <HTTPUpdate.h>
#include <HTTPClient.h>

#define LED_BUILTIN 2

const String FirmwareVer = {"1.4"};

#define URL_fw_Version "http://vadaliya2007.000webhostapp.com/atte/ota/version.txt"
#define URL_fw_Bin "http://vadaliya2007.000webhostapp.com/atte/ota/firmware.bin"
HTTPClient http;

const char* ssid = "Honor8X";
const char* password = "1414141414";

void FirmwareUpdate()
{
  http.begin(URL_fw_Version, "‎5b fb d1 d4 49 d3 0f a9 c6 40 03 34 ba e0 24 05 aa d2 e2 01"); // check version URL
  delay(100);
  int httpCode = http.GET();            // get data from version file
  delay(100);
  String payload;
  if (httpCode == HTTP_CODE_OK)         // if version received
  {
    payload = http.getString();  // save received version
    Serial.println(payload );
  }
  else
  {
    Serial.print("error in downloading version file:");
    Serial.println(httpCode);

  }

  http.end();
  if (httpCode == HTTP_CODE_OK)         // if version received
  {
    if (payload.equals(FirmwareVer) )
    {
      Serial.println("Device already on latest firmware version");
    }
    else
    {
      Serial.println("New firmware detected");
      WiFiClient client;

      // The line below is optional. It can be used to blink the LED on the board during flashing
      // The LED will be on during download of one buffer of data from the network. The LED will
      // be off during writing that buffer to flash
      // On a good connection the LED should flash regularly. On a bad connection the LED will be
      // on much longer than it will be off. Other pins than LED_BUILTIN may be used. The second
      // value is used to put the LED on. If the LED is on with HIGH, that value should be passed
      //ESPhttpUpdate.setLedPin(LED_BUILTIN, LOW);


      t_httpUpdate_return ret = ESPhttpUpdate.update(URL_fw_Bin, "", "‎5b fb d1 d4 49 d3 0f a9 c6 40 03 34 ba e0 24 05 aa d2 e2 01");

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

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

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

unsigned long previousMillis = 0;        // will store last time LED was updated
const long interval = 30000;

void repeatedCall() {
  unsigned long currentMillis = millis();
  if ((currentMillis - previousMillis) >= interval)
  {
    // save the last time you blinked the LED
    previousMillis = currentMillis;
    FirmwareUpdate();
  }
}


void setup()
{
  Serial.begin(115200);
  Serial.println("");
  Serial.println("Start");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print("O");
    delay(500);
  }
  Serial.println("Connected to WiFi");
  pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(100);                       // wait for a second
  repeatedCall();
}