diff options
Diffstat (limited to 'application.lua')
-rw-r--r-- | application.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/application.lua b/application.lua index 63f477e..ad90814 100644 --- a/application.lua +++ b/application.lua @@ -1,16 +1,24 @@ 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 Connection: close -{"temperature": %s, "pressure": %s, "humidity": %s}]], T, P, H)) +{"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) |