tsl2561_Example.lua 635 B

12345678910111213141516171819202122232425
  1. -- ***************************************************************************
  2. -- TSL2561 Example Program for ESP8266 with nodeMCU
  3. --
  4. -- Written by Marius Schmeding
  5. --
  6. -- MIT license, http://opensource.org/licenses/MIT
  7. -- ***************************************************************************
  8. tmr.alarm(0, 5000, 1, function()
  9. SDA_PIN = 6 -- sda pin
  10. SCL_PIN = 5 -- scl pin
  11. -- init module
  12. tsl2561 = require("tsl2561")
  13. tsl2561.init(SDA_PIN, SCL_PIN)
  14. -- read value
  15. l = tsl2561.readVisibleLux()
  16. print("lux: "..l.." lx")
  17. -- release module
  18. tsl2561 = nil
  19. package.loaded["tsl2561"]=nil
  20. end)