ESP8266 OTA temperature measurement not working [String] 'x-ESP8266-

Could some one point me to the right solution?

Checking of the version works but the upload of the firmware goes wrong.
11:42:57.856 -> [HTTP-Client][begin] host: qnap port: 8080 url: /share.cgi?ssid=0wlZS01&fid=0wlZS01&filename=firmware.bin&openfolder=forcedownload&ep=
11:42:57.984 -> [String] 'x-ESP8266- ... 1753088

#include <OneWire.h>
#include <DallasTemperature.h>
#include <ArduinoOTA.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266httpUpdate.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>

const char* ssid = "";
const char* password = "";
const char* domoticzIp = "10.10.10.110";
const int domoticzPort = 8080;
const int ds18b20Pin = D2;
const int sleepDuration = 1e+7;                                                                                                           // 1 minutes in microseconds
const char* fwImageURL = "http://qnap:8080/share.cgi?ssid=0wlZS01&fid=0wlZS01&filename=firmware.bin&openfolder=forcedownload&ep=";        // update with your link to the new firmware bin file.
const char* fwVersionURL = "http://qnap:8080/share.cgi?ssid=0JdTb0b&fid=0JdTb0b&filename=firmware.version&openfolder=forcedownload&ep=";  // update with your link to a text file with new version (just a single line with a number)
const float FW_VERSION = 1.06;

OneWire oneWire(ds18b20Pin);
DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(9600);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.print("Connecting to WiFi");

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("\nConnected to WiFi");

  // Initialize OTA
  ArduinoOTA.setHostname("ESP8266-TEMP1");  // Set a unique hostname for OTA
  ArduinoOTA.onStart([]() {
    Serial.println("Start");
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
    else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
    else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
    else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
    else if (error == OTA_END_ERROR) Serial.println("End Failed");
  });
  ArduinoOTA.begin();
  Serial.println("Ready");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  sensors.begin();
}

void loop() {
  // Handle OTA updates
  ArduinoOTA.handle();

  // Request temperature reading from the DS18B20 sensor
  sensors.requestTemperatures();
  float temperatureC = round(sensors.getTempCByIndex(0) * 10) / 10;

  // Print temperature to Serial Monitor (optional)
  Serial.print("Temperature: ");
  Serial.print(temperatureC);
  Serial.println(" °C");

  // Send temperature data to Domoticz
  sendDataToDomoticz(temperatureC);
  check_OTA();
  // Enter Deep Sleep mode
  Serial.println("Going into Deep Sleep...");
  delay(500);  // Allow the serial messages to be sent
  ESP.deepSleep(sleepDuration);
}

void sendDataToDomoticz(float temperature) {
  WiFiClient client;
  if (client.connect(domoticzIp, domoticzPort)) {
    String url = "/json.htm?type=command&param=udevice&idx=124&nvalue=0&svalue=";
    url += String(temperature);

    client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + domoticzIp + "\r\n" + "Connection: close\r\n\r\n");
    client.stop();
  } else {
    Serial.println("Error connecting to Domoticz");
  }
}

void check_OTA() {
  WiFiClient client;
  // setup_wifi(); must be called before check_OTA();
  Serial.print("Firmware: ");
  Serial.println(FW_VERSION);
  Serial.println("Check for OTA");
  HTTPClient http;
  if (http.begin(client, fwVersionURL)) {
    Serial.println("http begin");
    int httpCode = http.GET();
    Serial.print("httpCode:");
    Serial.println(httpCode);
    if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
      String newFWVersion = http.getString();
      Serial.print("Server  FWVersion: ");
      Serial.println(newFWVersion);
      Serial.println(" / ");
      Serial.print("Current FWVersion: ");
      Serial.println(FW_VERSION);
      float newVersion = newFWVersion.toFloat();
      if (newVersion > FW_VERSION) {
        Serial.println("start OTA !");
        http.end();
        delay(100);
        t_httpUpdate_return ret = ESPhttpUpdate.update(client, fwImageURL);
        switch (ret) {
          case HTTP_UPDATE_FAILED:
            Serial.print("HTTP_UPDATE_FAILD Error ");
            Serial.print(ESPhttpUpdate.getLastError());
            Serial.print(": ");
            Serial.println(ESPhttpUpdate.getLastErrorString().c_str());
            // 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;
        }
      } else {
        Serial.println("no new version available");
      }
    }
  }  // end if http.begin
  Serial.println("End of OTA");
}  // end check_OTA()

Found the solution myself, because of the loading of a new firmware the server-name was not valid anymore. Change the server name in the ip-address and it is working.

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