nodemcu-firmware/lua_modules/hdc1000/HDC1000-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
526 B
Lua

local HDC1000 = require("HDC1000")
local sda, scl = 1, 2
local drdyn = false
do
i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once
HDC1000.setup(drdyn)
-- prototype is config(address, resolution, heater)
HDC1000.config() -- default values are used if called with no arguments.
print(string.format("Temperature: %.2f °C\nHumidity: %.2f %%", HDC1000.getTemp(), HDC1000.getHumi()))
-- Don't forget to release it after use
HDC1000 = nil -- luacheck: no unused
package.loaded["HDC1000"] = nil
end