Automatic OTA Updates

Most OTA schemes just allow you to push an update to your ESP8266, but Xose Pérez’s latest offering, “NoFUSS”,  is a plug-in for your ESP8266 project which enables your ESP8266 to regularly check in with a specified server and automatically download an update if there’s one  available.  Neat!

In addition to the simple update functionality, NoFuss allows you to configure whether updates will be offered to specific groups of ESPs (for instance, temperature sensors which might all use the BME280 module) and to configure a specific load sequence (so that the SPIFFS filesystem on the target ESP might be updated before the actual project firmware).

The requirements for implementing this on your home network are fairly simple.  The server side requires a web-server capable of supporting PHP.  The ESP side requires that you add Xose’s NoFUSSClient library to your ESP project.  The configuration for both sides is explained in Xose’s original article and the git repository for the project is available here.


Keeping your local ESP8266 source trees up to date

I have a burgeoning directory on my laptop which holds all of the source code for any ESP8266 project I’ve ever come across and thought “This looks interesting…”.  Through the magic of Git, it usually only takes a few seconds to clone a complete project to local disk and have a permanent local copy which you can play with.  The only problem being that the code usually gets stale fairly quickly and you never know when the original author has pushed out an update.  To this end, I knocked together a very simple script which simply lists all of the subdirectories in my ESP8266 master directory and then goes off and does a “git pull” for everything it finds …assuming that the subdirectory is actually a git structured repository and is not flagged with “Do Not Update”.

Git being git, it doesn’t actually care whether the remote, original repository is on GitHub, PasteBin or Bob’s_basement_box, it’ll happily update from the stored URL, whatever and where-ever it is.

The “Do Not Update” feature is there in case you’re lazy (like me) and tend to make working directories with local modifications (which would fail to update and cause errors), or just because you want to maintain a pristine, original snapshot of a repository at some particular point in time.  You can tell the script not to update a repository in two ways.  The first is to add the name of the subdirectory to the file Do_Not_Update.txt in the top-level ESP8266 directory.  The second is to create a file named “Do_Not_Copy” in the actual repository subdirectory itself (the file can be empty, or you can use it to store a note on why you wanted to prevent updates).

The script will keep a (fairly verbose) log of the update process (by default, it is written to /var/tmp/ESP8266_auto_update.log).

The only thing you must change for your particular installation is the path to the top-level ESP8266 directory on your machine (which can be called anything you wish, BTW), “WK_DIR”, which is right at the top of the script.  There’s a sample cron entry in the file which will run the script once per week.

I’ve been running this early every morning for my ESP8266, ESP32 and a couple of other directories for well over a year now and my morning routine now includes a quick “ls -alrt” of those directories to see what’s been updated in the last 24 hours  …a good way of staying abreast of Theo’s amazing update rate on TASMOTA.