Advantages and Disadvantages of OTA Upload

Can everybody tell their experience about Advantages and Disadvantages of OTA Upload method …
Thank you everybody

I have found it very good. When you need to change the sketch you don’t have to go to the actual mcu and put it in Upload mode to upload new sketches. It is done automatically. For OTA to work you just upload a sketch the first time using serial and then the device will show up in the IDE for OTA uploading.

I have only found 2 disadvantages with OTA. First one being is you need to have an ESP which has more memory that 1M ones. With Esp-01’s I never got it to work but the Wemos D1 Mini pro works.
Second one being that if you forget to set a password and impliment OTA in your sketch and Upload the device will no longer be able to use OTA and you need to upload the BASIC OTA sketch on the MCU again for it to show up.

1 Like

I have OTA running on 1M ESP-01’s. Should even run on the original 512K ESP-01’s providing your sketch is less than 256K (half the total available memory).

1 Like

this is not true! currently i’m using more than 25 sonoff devices, all with 1MB flash size, and ota is working perfectly on all of them. (of course, one can write such a big code that can not fit into 0.5MB, but “standard” projects can fit happily).

also, i didn’t find this to be true. for product develompent and testing i never set a password for ota, because it is very annoying if you upload new code frequently / have lots of devices.

1 Like

I agree with @wanek… And as long as you include the minimal basics in each sketch you load, it will work the next time… if you do mess up, you do NOT need the BasicOTA sketch, just double check your code and make sure these minimal commands are in there (based on my usage so far) and reload via USB.

#include <ESP8266mDNS.h>  // For OTA - For ESP8266... or...
// #include <WiFi.h>  // For OTA - For ESP32
// #include <ESPmDNS.h>  // For OTA - For ESP32

#include <WiFiUdp.h>  // For OTA
#include <ArduinoOTA.h>  // For OTA

// used for WiFi setup, depending on your method
char ssid[] = "xxxxx";
char pass[] = "xxxxx";

void setup()
{
  // Normal setup stuff here
  // Including WiFi setup, etc...

  ArduinoOTA.setHostname("My unique name for my device");  // For OTA - Optional if you don't mind deciphering which ESP is which.
  ArduinoOTA.begin();  // For OTA
}

void loop()
{
  // Normal loop stuff here

  ArduinoOTA.handle();  // For OTA
}
2 Likes

Is it possile with OTA we can Upload multi time on device?
or after any OTA Upload we missed it for Next time?

this feature by no means is new, is more than 1 year old.

here are the latest docs for esp core:
http://arduino-esp8266.readthedocs.io/en/2.4.0-rc1/ota_updates/readme.html?highlight=ota

and in arduino ide > file > examples > arduino ota you find the example sketches.

the minimal sketch for ota update is:

#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

const char* ssid = "..........";
const char* password = "..........";

void setup()
{
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  ArduinoOTA.begin();
}

void loop()
{
  ArduinoOTA.handle();
}

the first “ota” sketch you have to upload via usb, after that you have to restart the esp (plug out the usb cable then back). also, i observed that if i restart the ide, it will detect faster the new esp network port (in tools > port).

than, if you include the above code in your sketch, you can upload ota as many times as you wish!

after reading the docs and study the example sketches, feel free to experiment, you can not break anything. and if you have any issues you can not find in the docs, ask!

1 Like

EDIT - I moved the previous two posts over to this topic, so as to keep current info in current topic, and keep unnecessary duplication to a minimum when split between multi-topics (sorry @wanek, I hadn’t seen your post before almost totally duplicating it in my “prior” minimal OTA post.:wink: )

1 Like

Every time I try to upload to an ESP -01 I get No Response from device in the IDE and when I use a WEMOS D1 Mini Pro is uploads every time. The must be something on my end sorry for the false info :pensive: .

One time I uploaded a code to a wrong device and had to upload the Basic OTA sketch and then the right sketch.