Update from a web page


The next incredibly useful feature for the ESP8266 is the ability to program it directly over the Wifi. This would allow you to build devices that didn't even need a usb serial connection and you can easily update any devices that have been sent out to people already (would have been very handy for me this week).

The HTTP web updater is actually part of the standard arduino core and it's incredibly simple to set up. We're going to build upon the web server tutorial but this functionality can be included in all future programs.



Include the ESP8266HTTPUpdateServer.h and declare a new instance of the class for use in the program. The only other thing required to make this work is to tell the update server which web server it should be working with. This is done just before you start the local web server.


The arduino environment is able to prepare a new image to upload to the device. In the menu system you can go to "Sketch->Export Compiled Binary", this will be all the information about your program contained in a single file.


Now when you connect to the device via wifi you should be able to navigate the browser to "192.168.4.1/update", this will load a page that allows you to select a new image to upload to the device. Select the binary image from your sketch folder and click the update button, you should see the status of the upload displayed at the bottom of the page.


If the device has successfully updated, you will receive an message informing you of it's completion. It says the device is rebooting but the wemos D1 needs to be manually restarted using the reset button.


Once the device has actually rebooted you should be able to connect again to the wifi and load the root page to see that your changes have taken effect. For this demo I used the update to change the basic text response from 'Hello World' to 'Wifi Updated'



Here is the complete example code,



Popular posts from this blog

Wiring the Ruida Controller

Laser Cut Cryptex

Rainbow Puzzle Box