I'm new to esp8266 so my goal is simple, to make a loop that connects to a web server wait for data from it (or error) and do something depending of what command it receives or if an error accurs.
My limited knowledge led me to http library, but looks like it is a asynhronous function and my lua script do not work preperly, so I use a variable and make rest of the script until http function call it fallback funtion. But looks like board restart by some reason, I tried of different version of nodemcu, even with net library instead of http one, and board still restarts
here is my simple script:
Tstart = tmr.now()
print('httpget.lua started at ' .. Tstart)
code = nil
http.get("http://r-control.eu/esp8266.php?reportfrom=", nil, function(code, data)
if (code < 0) then
print("HTTP request failed")
print ("waiting for function to complete\n")
print ( tmr.now())
print ("here is the data\n")
I never see "here is the data" message, probabbly restart after while condition ends.
Thank you in advance for your attention.