1.8 KiB
1.8 KiB
si7021 module
##Require
si7021 = require("si7021")
Release
si7021 = nil
package.loaded["si7021"]=nil
##init()
####Description
Setting the i2c pin of si7021.
####Syntax init(sda, scl)
####Parameters
sda: 1~12, IO index.
scl: 1~12, IO index.
####Returns nil
####Example
si7021 = require("si7021")
gpio5 = 1
gpio4 = 2
sda = gpio5
scl = gpio4
si7021.init(sda, scl)
-- Don't forget to release it after use
si7021 = nil
package.loaded["si7021"]=nil
####See also -
##read()
####Description
Read temperature and humidity from si7021.
####Syntax read()
####Parameters
nil.
####Returns
nil(Why?).
####Example
si7021 = require("si7021")
sda = 1
scl = 2
si7021.init(sda, scl)
r = si7021.read()
print(r)
-- Don't forget to release it after use
si7021 = nil
package.loaded["si7021"]=nil
####See also -
##getHumidity()
####Description
Get humidity from si7021.
####Syntax getHumidity()
####Parameters
nil.
####Returns h: Integer, humidity from si7021.
####Example
si7021 = require("si7021")
sda = 1
scl = 2
si7021.init(sda, scl)
h = si7021.getHumidity()
print(h)
-- Don't forget to release it after use
si7021 = nil
package.loaded["si7021"]=nil
####See also -
##getTemperature()
####Description
Get temperature from si7021.
####Syntax getTemperature()
####Parameters
nil.
####Returns t: Integer, temperature from si7021.
####Example
si7021 = require("si7021")
sda = 1
scl = 2
si7021.init(sda, scl)
t = si7021.getTemperature()
print(t)
-- Don't forget to release it after use
si7021 = nil
package.loaded["si7021"]=nil
####See also -