Post your best Lua script examples here

User avatar
By btsimonh
#38437 hi everyone;
I've just started with Nodemcu, and one of the things I wanted to do was auto-update my lua scripts from a webserver.
being new to lua, this gave me a little trouble, but i got there in the end.
One of the difficult bits is realising that a response comes in multiple parts, and so you need to stick these together if your LUA file is going to be complete; then realising that you can't start another client session even within the 'disconnect' callback in nodemcu.

Anyways; the code is here:
https://github.com/btsimonh/NodeMCU-temp-to-ThingSpeak

loading from a http server is in 'loadfiles.lua' - it allows you to update multiple files from a webserver, and store them to the flash.

The other issue I had was getting ow to work for reading 1-wire - basically, the 'release' version of nodemcu is buggy, build yourself one from master.... issues have been resolved there.

s