aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClemens Fries <git-iot@xenoworld.de>2017-07-25 10:38:12 +0200
committerClemens Fries <git-iot@xenoworld.de>2017-07-25 10:38:51 +0200
commitc7c63ab77969e3b532079f0977495c7fc31334ba (patch)
tree420c1f2154aaf522eb4e9d54eacffb5b04b15375
parentd2c85c44d19c2c99c1f8ce212015c1964a795205 (diff)
added a TSL2561 sensor to the project
-rw-r--r--application.lua10
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)