From effb57247caefa89476b64824fa57bf08052aa42 Mon Sep 17 00:00:00 2001 From: Martin Han Date: Wed, 22 Apr 2015 13:16:37 +0800 Subject: [PATCH] Add Example to yeelink lib --- .../yeelink/Example_for_Yeelink_Lib.lua | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lua_modules/yeelink/Example_for_Yeelink_Lib.lua diff --git a/lua_modules/yeelink/Example_for_Yeelink_Lib.lua b/lua_modules/yeelink/Example_for_Yeelink_Lib.lua new file mode 100644 index 00000000..d5cae98c --- /dev/null +++ b/lua_modules/yeelink/Example_for_Yeelink_Lib.lua @@ -0,0 +1,25 @@ +-- *************************************************************************** +-- 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") + +dht = require("dht_lib") --Step2: "Require" the libs +yeelink = require("yeelink_lib") + +yeelink.init(23333,23333,"You api-key",function() --Step3: Register the callback function + + print("Yeelink Init OK...") + tmr.alarm(1,60000,1,function() --Step4: Have fun~ (Update your data) + + dht.read(4) + yeelink.update(dht.getTemperature()) + + end) +end)