Thingsboard OTA with ESP

I want to update firmware using Thingsboard.h but I am having errors. Does anyone has solution how can I implement OTA function by thingsboard with ARDUINO IDE?

Here this is my code..i want to update firmware using HTTP protocol, But it is showing bad request or 404 Error.
Any suggestions are welcome.

Thank you.

#include <Arduino.h>

#include <WiFi.h>

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

#define USE_SERIAL Serial

void setup() {

    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);
    }
connectwifi();
  //Serial.println(status);
}

void connectwifi() {
 WiFi.begin("TestECT", "07012023");
  Serial.println("Connected to wifi:");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("Connecting to WiFi..");
  }

  Serial.println("Connected to the WiFi network");
}

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

        t_httpUpdate_return ret = ESPhttpUpdate.update("http://192.168.0.111:8080/api/v1/{Cred12}/firmware?title=${ESP_Title}&version=${0.0.3}");

        switch(ret) {
            case HTTP_UPDATE_FAILED:
                USE_SERIAL.printf("HTTP_UPDATE_FAILD Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
                Serial.println("");
                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;
        }
    }
}

Hi @pa111

I'm going to ask you to post some additional information that might help us to identify the problem.


:exclamation: NOTE: These instructions will not solve the problem. They are only intended to gather more information which might provide a clue that eventually leads to a solution.


Please do this:

  1. If you don't still have the IDE or web editor open with the error present, repeat the process that generated it.
  2. You now need to copy the full and exact text of the output.
    The procedure for doing this is different depending on which Arduino development software you are using:
    • Arduino IDE 1.x: Click the Copy error messages button on the right side of the orange bar in the IDE.
    • Arduino IDE 2.x: Right click on the black "Output" panel at the bottom of the IDE window and then select "Copy All" from the context menu.
    • Arduino Web Editor: Click the icon that looks like two pieces of paper at the top right corner of the black console window Web Editor.
  3. Open a forum reply here by clicking the Reply button.
  4. Click the </> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block
  5. Press Ctrl+V.
    This will paste the compilation output into the code block.
  6. Move the cursor outside of the code block markup before you add any additional text to your reply.
  7. Click the Reply button to post the output.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here:

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a forum reply here by clicking the Reply button.
  5. Click the "Upload" icon (image) on the post composer toolbar:
    image
  6. Select the .txt file you saved.
  7. Click the Open button.
  8. Click the Reply button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

i have uploaded code and some information. Hope it would be helpfull.

I see now from the information you edited into the first post it is a runtime error:

Unfortunately I am not familiar with ThingsBoard so I am unable to assist you with this issue. Hopefully one of the other forum members is more knowledgeable on this subject and will be able to help.

Best wishes for success with your project,
Per

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.