This guide explains how to build a simple ESP8266 firmware updater in NodeJS. The ESP8266 will send a GET request to my application with some key information stored in its header. This will then be used to serve up the appropriate binary. For this example I’m using the . But you can use the as well. ESP8266 ESP12E ESP32 NodeJS Application Let’s get started by generating a new Express app using the following command in terminal: express ota_updater This creates a fresh instance of Express which we’ll use as the foundation of our version controller. For the sketch that I want to upload to the ESP8266 I’m using the example Blink sketch from the Arduino library. { pinMode(LED_BUILTIN, OUTPUT); } { digitalWrite(LED_BUILTIN, HIGH); delay( ); digitalWrite(LED_BUILTIN, LOW); delay( ); } void setup () // initialize digital pin LED_BUILTIN as an output. // the loop function runs over and over again forever void loop () // turn the LED on (HIGH is the voltage level) 1000 // wait for a second // turn the LED off by making the voltage LOW 1000 // wait for a second We’ll need the compiled binary to upload to the sketch, which you can find in the debugger once you turn on the option “Show verbose output” for sketch compilations. After clicking the verify button you can find the compiled binary as per your debugger. Place your blink.ino.bin inside a new /updates folder and updating our index.js file inside the routes folder to serve up our binary. express = ( ); path = ( ); fs = ( ); router = express.Router(); md5 = ( ); router.get( , { .log(req.headers); filePath = path.join(__dirname, ); options = { : { : md5.sync(filePath) } } res.sendFile(file, { (err) { next(err) } { .log( , file) } }); }); .exports = router; var require 'express' var require 'path' var require "fs" var var require "md5-file" '/update' ( ) function req, res, next console var '../updates/blink.ino.bin' var headers "x-MD5" ( ) function err if else console 'Sent:' module After you confirm this works on your local machine it’s time to move your application to an external instance such as EC2 or Linode. After setting this all up you should be presented with the download dialog after navigating to your external domain. Now that you know your application works you can start testing it out on your ESP8266. ESP8266 sketch For the ESP8266 sketch we use the library. ESP8266httpUpdate.h * ssid = ; * password = ; { Serial.begin( ); Serial.setDebugOutput( ); WiFi.begin(ssid, password); (WiFi.status() != WL_CONNECTED) { Serial.print( ); delay( ); } t_httpUpdate_return ret = ESPhttpUpdate.update( , ); (ret) { HTTP_UPDATE_FAILED: Serial. ( , ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str()); ; HTTP_UPDATE_NO_UPDATES: Serial.println( ); ; HTTP_UPDATE_OK: Serial.println( ); ; } } { } # include <ESP8266httpUpdate.h> const char "ssid" // Set your router SSID const char "password" // Set your router password void setup () 74880 true /*connection to WiFi*/ while "." 1000 "http://domain.com/update" "1.0" switch case printf "[update] Update failed (%d): %s" break case "[update] Update no Update." break case "[update] Update ok." break void loop () Upload the sketch to your ESP8266 and your console will output the something similar to the following, after which your ESP8266 module resets and executes the blink sketch. And when looking at our NodeJS app we see information about the ESP8266 be outputted to the screen: { : , : , : , : , : , : , : , : , : , : , : , : , : , : } connection 'upgrade' host 'domain.com' 'content-length' '0' 'user-agent' 'ESP8266-http-Update' 'x-esp8266-chip-id' '14454826' 'x-esp8266-sta-mac' 'CC:50:E3:DC:90:2A' 'x-esp8266-ap-mac' 'CE:50:E3:DC:90:2A' 'x-esp8266-free-space' '659456' 'x-esp8266-sketch-size' '302832' 'x-esp8266-sketch-md5' '97bbf0d228c88673b9c040df1f7317f4' 'x-esp8266-chip-size' '4194304' 'x-esp8266-sdk-version' '2.2.2-dev(38a443e)' 'x-esp8266-mode' 'sketch' 'x-esp8266-version' '1.0' Now this appears to work very nicely. However, now that the blink sketch is uploaded there is no way for us to upload a new sketch to the module. The preferred outcome would be that your ESP8266 will periodically check whether there are new firmware updates available, and update the module if necessary. For all of that, and more, please see of this article. Part 2