This Christmas, I added a whole bunch of lights powered by 5V power sources. My goal was to switch them on at sunset, and switch them off on sunrise, by using a MOSFET for power control :)
While I was doing this, I wanted to send OTA updates of my Lua files to the ESP8266 via WiFi. For some unknown reason, I couldn’t use luatool.py’s TCP update method.
So, I ended up building my very own OTA update protocol (which turned out to be fun!). To begin, add ota.lua
to your project, and invoke it using dofile("ota.lua")
in your init.lua
:
Then, to use this shiny new TCP endpoint created on your ESP8266/NodeMCU, create a wrapper shell script:
Heads up! Replace HOST
with the IP of your NodeMCU.
The wrapper script will automatically trigger a restart at the end. To use the wrapper script:
$ chmod +x ota.sh
$ ./ota.sh file1.lua file2.lua init.lua
And that’s it! OTA update away!