nodemcu-firmware/lua_modules/yeelink/Example_for_Yeelink_Lib.lua

26 lines
760 B
Lua
Raw Permalink Normal View History

2015-04-22 07:16:37 +02:00
-- ***************************************************************************
-- Example for Yeelink Lib
--
-- Written by Martin
--
--
-- MIT license, http://opensource.org/licenses/MIT
-- ***************************************************************************
wifi.setmode(wifi.STATION) --Step1: Connect to Wifi
wifi.sta.config("SSID","Password")
local dht = require("dht_lib") --Step2: "Require" the libs
local yeelink = require("yeelink_lib")
2015-04-22 07:16:37 +02:00
yeelink.init(23333,23333,"You api-key",function() --Step3: Register the callback function
print("Yeelink Init OK...")
tmr.create():alarm(60000, tmr.ALARM_AUTO, function() --Step4: Have fun~ (Update your data)
2019-02-17 19:26:29 +01:00
2015-04-22 07:16:37 +02:00
dht.read(4)
yeelink.update(dht.getTemperature())
2019-02-17 19:26:29 +01:00
2015-04-22 07:16:37 +02:00
end)
end)