2019-12-31 00:53:54 +01:00
|
|
|
local HDC1000 = require("HDC1000")
|
2015-03-07 03:11:17 +01:00
|
|
|
|
2019-12-31 00:53:54 +01:00
|
|
|
local sda, scl = 1, 2
|
|
|
|
local drdyn = false
|
2015-03-07 03:11:17 +01:00
|
|
|
|
2019-12-31 00:53:54 +01:00
|
|
|
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.
|
2015-03-07 03:11:17 +01:00
|
|
|
|
2019-12-31 00:53:54 +01:00
|
|
|
print(string.format("Temperature: %.2f °C\nHumidity: %.2f %%", HDC1000.getTemp(), HDC1000.getHumi()))
|
2015-03-07 03:11:17 +01:00
|
|
|
|
2019-12-31 00:53:54 +01:00
|
|
|
-- Don't forget to release it after use
|
|
|
|
HDC1000 = nil -- luacheck: no unused
|
|
|
|
package.loaded["HDC1000"] = nil
|
|
|
|
end
|