bme280.init(3, 4, nil, nil, nil, 0) -- initialize to sleep mode status = tsl2561.init(3, 4, tsl2561.ADDRESS_FLOAT, tsl2561.PACKAGE_T_FN_CL) if status == tsl2561.TSL2561_OK then status = tsl2561.settiming(tsl2561.INTEGRATIONTIME_101MS, tsl2561.GAIN_1X) end srv=net.createServer(net.TCP) srv:listen(80,function(conn) conn:on("receive",function(conn) bme280.startreadout(0, function () T, P, H = bme280.read() lux = tsl2561.getlux() lux_bs, lux_ir, lux_st = tsl2561.getrawchannels() -- local Tsgn = (T < 0 and -1 or 1); T = Tsgn*T conn:send(string.format([[HTTP/1.1 200 OK Content-Type: application/json Access-Control-Allow-Origin: * Connection: close {"temperature": %s, "pressure": %s, "humidity": %s, "lux": %s, "lux_ir": %s, "lux_bs": %s}]], T, P, H, lux, lux_ir, lux_bs)) end) end) conn:on("sent", function(conn) conn:close() end) end)