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
@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.
Printout:
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
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
Blynk.begin( auth, ssid, pass ); // connect to blynk server
while (Blynk.connect() == false) {} // wait for connection
ArduinoOTA.begin(); // configure bootloader for 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??
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)
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.