t = require('ds18b20') port = 80 pin = 3 -- gpio0 = 3, gpio2 = 4 gconn = {} -- global variable for connection function readout(temp) local resp = "HTTP/1.1 200 OK\nContent-Type: text/html\nRefresh: 5\n\n" .. "" .. "" .. "ESP8266
" for addr, temp in pairs(temp) do resp = resp .. string.format("Sensor %s: %s ℃
", ('%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X '):format(addr:byte(1,8)), temp) end resp = resp .. "Node ChipID: " .. node.chipid() .. "
" .. "Node MAC: " .. wifi.sta.getmac() .. "
" .. "Node Heap: " .. node.heap() .. "
" .. "Timer Ticks: " .. tmr.now() .. "
" .. "" gconn:send(resp) gconn:on("sent",function(conn) conn:close() end) end srv=net.createServer(net.TCP) srv:listen(port, function(conn) gconn = conn -- t:read_temp(readout) -- default pin value is 3 t:read_temp(readout, pin) end )