-->
Page 1 of 1

Trying to use OTA - not visible in mDNS

PostPosted: Wed Feb 07, 2018 7:18 am
by joshvm
I managed to get the basic OTA example code working on an ESP-07 with a custom breakout board, and to the point where I could easily flash my own firmware over our local network. I then tried to flash the code to a bunch of other boards, but I've not been successful. The rest of the firmware works - I'm streaming sensor data using MQTT, so I can connect to our WiFi and the MQTT broker, etc. What doesn't work is the OTA.

I'm using platformio and my ini is:

Code: Select all[env:esp07]
platform = espressif8266
board = esp07
framework = arduino
upload_port = COM16
upload_speed = 115200
build_flags = -Wl,-Tesp8266.flash.1m64.ld

monitor_port = COM16
monitor_baud = 115200


The OTA setup code is below. The rest of the code works, so I assume the issue is here:

Code: Select allvoid configure_OTA()
{
  /** OTA CONFIG **/
  ArduinoOTA.onStart([]() {
    String type;
    if (ArduinoOTA.getCommand() == U_FLASH)
      type = "sketch";
    else // U_SPIFFS
      type = "filesystem";

    // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
    Serial.println("Start updating " + type);
  });
  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");
  });

  // Should be default, but let's be explicit.
  String chip_id = String(system_get_chip_id());
  String hostname = "sensor_" + chip_id;

  ArduinoOTA.setHostname(hostname.c_str());
  ArduinoOTA.setPassword("my_password");
  ArduinoOTA.setPort(8266);

  ArduinoOTA.begin();

  Serial.println("OTA setup");
  /** OTA CONFIG **/
}


This doesn't work, even with the Basic OTA example. The chip outputs something like this on boot:

Code: Select allChip ID:4266305
Connecting.......Ready
IP address: 192.168.1.6
4266305: Trying to connect to MQQT Broker
4266305: Connected to MQTT Broker


So it's connecting to the WiFi, has an IP address and OTA is configured. However there doesn't seem to be a way of checking if the mDNS service is actually working - aside from seeing if it pops up in platformio's device manager.

Since it did work on the first prototype, what could be different? The firmware is flashed OK, so I don't think it's an upload error. Perhaps the other modules have a different config somehow? (Do I need to upload a different bootloader?)