The code works for 20+ posts then this happens...
temperature =229375
Posted OK
Posting...
Temperature= 22.8750 Celsius
228750
temperature =228750
DNS retry 1!
DNS retry 1!
DNS retry 2!
DNS retry 1!
DNS retry 2!
DNS retry 1!
DNS retry 2!
DNS retry 1!
DNS retry 2!
DNS retry 3!
my code (I have an init file and another function to read an 18B20 temperature sensor as well.)
function postThingSpeak(level)
connout = nil
connout = net.createConnection(net.TCP, 0)
--184.106.153.149 thingspeak static ip
connout:on("receive", function(connout, payloadout)
if (string.find(payloadout, "Status: 200 OK") ~= nil) then
print("Posted OK");
end
end)
connout:on("connection", function(connout, payloadout)
print ("Posting...");
local volt = node.readvdd33();
t=1
gettemp(t)
print ("temperature ="..t)
connout:send("GET /update?api_key=myapi&field1=" .. (t/10000) .. "." .. (t%10000)
.. " HTTP/1.1\r\n"
.. "Host: api.thingspeak.com\r\n"
.. "Connection: close\r\n"
.. "Accept: */*\r\n"
.. "User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n"
.. "\r\n")
end)
connout:on("disconnection", function(connout, payloadout)
connout:close();
collectgarbage();
end)
connout:connect(80,'api.thingspeak.com')
end