[SOLVED] Going into an "OTA Mode"


I was wondering if we have to partition our esp8266 ota code into an “OTA Mode” and a “normal mode” as described at 2:20 of this video or is this obsolete?

If yes, could someone explain why and also as far as implementation would I just have a variable (boolean maybe) connected to a button widget that send the device into a OTA mode? Maybe an if statement surrounding ArduinoOTA.handle(); possibly?

Just starting with this OTA stuff and already a bit confused so any clarification is much appreciated

@bmoe24x with the BasicOTA sketch you don’t really need to partition your code as the single line in loop() is constantly looking to see if an OTA update is being sent to the ESP.

You can use buttons and other tricks like they show in the video but it’s not technically required.

Thanks for the info, I am no longer just using the basic OTA sketch now though, I integrated the OTA operation into my full sketch which has many other parts (I parsed the OTA portion from a Blynk forum post and combined with my existing sketch).

I notice that when I try to upload OTA, it gives an error. And yes I did power down the board after the serial flash

Good that you found this issue.

What error do you see and have you tried several times?

Do you still have ArduinoOTA.handle(); in loop() and presumably the basicOTA worked for you?

Is the OTA tied to a Blynk widget e.g. button?

@bmoe24x how big is your flash as your sketch needs to take less than half the flash to do an OTA update?

If you have a very detailed Blynk project on a basic ESP like the 01 you may have run out of space.

Old ESP01’s had 512MB so if your sketch takes more than about 250MB the OTA will fail. Same applies with 1MB flash, sketch needs to be less than 500MB.

Using a NodeMCU the 12E v3 one.

Sketch uses 257091 bytes (24%) of program storage space. Maximum is 1044464 bytes.
Global variables use 35824 bytes (43%) of dynamic memory, leaving 46096 bytes for local variables. Maximum is 81920 bytes.

So I don’t think that is the issue (I also tried a much simpler program and had similar issues). I wouldn’t mind having a blynk button widget that throws it into OTA new firmware listening mode just wondering if it is necessary and if so, a few ideas on how to go about it

and this?

Thanks to you :stuck_out_tongue:

Hmm I think it was something like “no response” or something of that nature, as in it didn’t detect it to be “listening” was my guess.

Yes I still have ArduinoOTA.handle(); in loop(), yes the basicOTA worked (although the port didn’t show up several times), and no currently I do not have the OTA tied to a widget

@bmoe24x do you have ArduinoOTA.begin(); after Blynk.begin(); in setup();?

yup yup

  Blynk.begin( auth, ssid, pass ); // connect to blynk server
  while (Blynk.connect() == false) {} // wait for connection
  ArduinoOTA.begin(); // configure bootloader for OTA

@bmoe24x a few things to try:

  1. Remove the while in setup, that was used before Blynk made Blynk.begin() a blocking routine.

  2. Remove ArduinoOTA.begin from setup() and use this function:

  1. Are you using a hostname? I don’t think it’s required but sometimes it makes things easier so
1 Like

Is “PTA” correct? Not “OTA”?

I will try both of those. If they do work will this have any affect on the speed of my program (wifi wise)? And also will it continually poll for a new update so new firmware can be uploaded at any time??


Looks like a typo… what with O and P right next to each other on the KB :wink:

Yes OTA not PTA.

Okay that seems to work now, thank you for the help.

Can you (or anyone) answer these questions? Is there also any reason not to use a dedicated button? Other than the fact I am not 100% on implementation yet… (other than just having a button widget control when to go into a method/function that contains all of the OTA stuff)

Buttons can be a problem:

  1. Physical button isn’t much good if the device is thousands of miles away or just in a hard to access spot within your property.

  2. Blynk button will only work if the server is running.

So yes you can use buttons, timers whatever you want but it doesn’t create any noticeable issues with it being in loop() i.e. always available.

No connection speed decreases? And by server running, as in the Blynk server? Is there times it isn’t?

Never noticed any connection speed differences.
If you think about local OTA then if your internet goes down you can still do OTA updates if you use loop().

All internet connections and servers fail at some point, they are just machines.

Ahh I believe I understand. Forgot the differences between wifi and internet for a moment, thanks again