Post your best Lua script examples here

User avatar
By kieranc
#34176 allow you to update your IP by requesting "", it also works via HTTP so I've used this to create a simple updater for the ESP8266. Hope someone else finds it useful.

Code: Select alldr=net.createConnection(net.TCP, 0)
conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload) print(payload) end)
conn:send("GET /update/your-domain-here/your-token-goes-here HTTP/1.1\r\n")
conn:send("Accept: */*\r\n")
conn:send("User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n")

Since conn:connect only seem to work with an IP address, the first part resolves the IP for, then creates the http request.
The IP address for the update is determined automatically by DuckDNS, you can also specify it manually as a 3rd argument to the http request if you like.
User avatar
By Varcon
#59607 This is exactly what i am lookin for, but in Arduino IDE.
Can somebody help me? I have ESP in Station mode connected to my wifi network, now i just need to update my DuckDDNS, how to do this in Arduino IDE?
User avatar
By josmaroal
#84045 Hola amigo, me interesa mucho tu aporte por favor podrias darme indicaciones como instalarlo en mi programa, estoy trabajando en ESP-12 con ESPBasic, pero si tengo que aprender el lenguaje que usas, ayudame.
Saludos y gracias .