

These failures would seem to negate the benefit of using this methodology. A reset was necessary to get a successful connection to the network. The device did connect successfully immediately after the OTA update, but failed to connect after a further period of Deep Sleep. The first example is at the start, when one press of the reset button dis not result in the device connecting to the network another reset was needed. Unfortunately, it also shows two examples of Sod's, or Murphy's Law: "If something can go wrong, it will". The above output shows a complete automatic OTA update. Unsigned long int actSleepTime = sleepTimeSecs * 1000000 // Deep Sleep time expressed in usecondsĮSP.deepSleep(actSleepTime) // Go to sleep

The following segment of code which puts the device into Deep Sleep for 15 Seconds, is added to the sketch, immediately after the checkForUpdates() routine:

My final goal is to have the device go into Deep Sleep after checking for updates, thus producing a repetitive process, the repetition rate being approximately determined by the Sleep Time. Global variables use 30420 bytes (37%) of dynamic memory, leaving 51500 bytes for local variables. Sketch uses 279840 bytes (26%) of program storage space. It's a reasonable sized sketch, but well within the maximum 50% of available program space.

In order to test the system properly, I have used two PCs - one to power the device and display the device output on the IDE Serial Monitor and the second for Sketch modification and uploading to the HTTP Server.Īnd here is the output from the demonstration sketch, where there is NO update available:Īs can be seen from the TimeStamp (H:M:S), the OTA update starts at 16:28:28, the device is starting to reboot at 16:28:41 and is up and reporting its IP Address by 16:28:45, which is a total of approx 17 Seconds from start of update to completion of reboot. Else if the Version Numbers are the same, do nothing.Construct the URL for the firmware binary file.Check against the current Version Number.Flash the built-in LED at a specified interval for a specified number of times.Connect to the WiFi network (with fixed IP Address).Define necessary constants, including current Version Number.Here is a recap of the sketch functionality: The Blog ended at the point where I had just shown the last segment of code inserted into the sketch to enable a full demonstration of OTA updating from an HTTP Server. My previous Blog - Over the Air (OTA) Programming of ESP8266 - Part II - ended prematurely, because I clicked the "Publish" button by mistake!!
