nodemcu-firmware/lua_modules/ds3231/ds3231-example.lua
galjonsfigur 6926c66b16 Polish Lua examples (#2846)
* Add missing globals from luacheck config

* Fix luacheck warnings in all lua files

* Re-enable luacheck in Travis

* Speed up Travis by using preinstalled LuaRocks

* Fix more luacheck warnings in httpserver lua module

* Fix DCC module and add appropriate definitions to luacheck config.

* Change inline comments from ignoring block to only ignore specific line

* Add Luacheck for Windows and enable it for both Windows and Linux

* Change luacheck exceptions and fix errors from 1st round of polishing

* Add retry and timeout params to wget
2020-06-09 22:26:52 +02:00

17 lines
492 B
Lua

local ds3231 = require("ds3231")
-- ESP-01 GPIO Mapping
local gpio0, gpio2 = 3, 4
do
i2c.setup(0, gpio0, gpio2, i2c.SLOW) -- call i2c.setup() only once
local second, minute, hour, day, date, month, year = ds3231.getTime(); -- luacheck: no unused
-- Get current time
print(string.format("Time & Date: %s:%s:%s %s/%s/%s", hour, minute, second, date, month, year))
-- Don't forget to release it after use
ds3231 = nil -- luacheck: no unused
package.loaded["ds3231"] = nil
end