Chat about current Lua tools and IDEs

User avatar
By Proximus
#54559 Hi I'am facing the following problem.

I've got the following custom build on my ESP-01
NodeMCU custom build by frightanic.com
branch: dev
commit: eccb2e4a53cfcdbfdf9a4024495930447930db07
SSL: false
modules: bme280,file,gpio,http,net,node,tmr,wifi
build built on: 2016-04-03 12:52
powered by Lua 5.1.4 on SDK 1.5.1(e67da894)


When I run the following code I get good temperature readings in my esplorer.
Code: Select allwifi.setmode(wifi.STATION)
wifi.sta.config("SSID","PASS")

tempa = 1

bme280.init(4, 3)
tmr.alarm(0,5000,1,function()
T = bme280.temp()
tempa = (string.format("%d.%02d", T/100, T%100))
print (tempa)

conn2=net.createConnection(net.TCP,2)
    conn2:on("receive", function(conn2, payload) print(payload) end)
    conn2:connect(8080,"192.168.2.18")
    conn2:send("GET /json.htm?type=command&param=udevice&idx=10&nvalue=0&svalue="..tempa.." HTTP/1.1\r\n")
    conn2:send("Host: 192.168.2.25\r\n")
    conn2:send("Accept: */*\r\n")
    conn2:send("User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n")
    conn2:send("\r\n")
        conn2:close();
        collectgarbage();


end)

But no update is send to Domoticz. When I inject the following code via a snippet the updates does get posted.
Code: Select allconn2=net.createConnection(net.TCP,2)
    conn2:on("receive", function(conn2, payload) print(payload) end)
    conn2:connect(8080,"192.168.2.18")
    conn2:send("GET /json.htm?type=command&param=udevice&idx=10&nvalue=0&svalue="..tempa.." HTTP/1.1\r\n")
    conn2:send("Host: 192.168.2.25\r\n")
    conn2:send("Accept: */*\r\n")
    conn2:send("User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n")
    conn2:send("\r\n")
        conn2:close();
        collectgarbage();


What am I doing wrong?
Putting the code in a different file and running it via dofile() in the loop doesn't work either.

Thank!