Example_for_Yeelink_Lib.lua 760 B

12345678910111213141516171819202122232425
  1. -- ***************************************************************************
  2. -- Example for Yeelink Lib
  3. --
  4. -- Written by Martin
  5. --
  6. --
  7. -- MIT license, http://opensource.org/licenses/MIT
  8. -- ***************************************************************************
  9. wifi.setmode(wifi.STATION) --Step1: Connect to Wifi
  10. wifi.sta.config("SSID","Password")
  11. local dht = require("dht_lib") --Step2: "Require" the libs
  12. local yeelink = require("yeelink_lib")
  13. yeelink.init(23333,23333,"You api-key",function() --Step3: Register the callback function
  14. print("Yeelink Init OK...")
  15. tmr.create():alarm(60000, tmr.ALARM_AUTO, function() --Step4: Have fun~ (Update your data)
  16. dht.read(4)
  17. yeelink.update(dht.getTemperature())
  18. end)
  19. end)