Marcel Stör cb2808835d Fix Markdown syntax issues, fixes #2347 | 6 роки тому | |
---|---|---|
.. | ||
README.md | 6 роки тому | |
lm92.lua | 6 роки тому |
This module adds basic support for the LM92 +-0.33C 12bit+sign temperature sensor. More details in the datasheet. Works:
LM92 = require("lm92")
LM92 = nil
package.loaded["lm92"]=nil
Setting the address for lm92.
setup(sda, scl, address)
address: 0x48~0x4b, i2c address (depends on tha A0~A1 pins)
nil
LM92 = require("lm92")
gpio0 = 3
gpio2 = 4
sda = gpio0
scl = gpio2
addr = 0x48
i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once
LM92.setup(addr)
Returns the temperature register’s content.
getTemperature()
-
Temperature in degree Celsius.
t = LM92.getTemperature()
print("Got temperature: "..t.." C")
Makes the chip exit the low power shutdown mode.
wakeup()
-
-
LM92.wakeup()
tmr.delay( 1 * 1000 * 1000 )
Makes the chip enter the low power shutdown mode.
shutdown()
-
-
LM92.shutdown()
Set hysteresis Temperature.
setThyst(data_wr)
data_wr: 130~-55 ºC, hysteresis Temperature
nil
LM92.setThyst(3)
Set Critical Temperature.
setTcrit(data_wr)
data_wr: 130~-55 ºC, Critical Temperature
nil
LM92.setTcrit(100.625)
Set Low Window Temperature.
setTlow(data_wr)
####Parameters data_wr: 130~-55 ºC, Low Window Temperature
nil
LM92.setTlow(32.25)
####Description Set High Window Temperature.
setThigh(data_wr)
data_wr: 130~-55 ºC, High Window Temperature
nil
####Example
LM92.setThigh(27.5)
Get hysteresis Temperature.
getThyst()
–
Hysteresis Temperature in degree Celsius.
t = LM92.getThyst()
print("Got hysteresis temperature: "..t.." C")
Get Critical Temperature.
getTcrit()
–
Critical Temperature in degree Celsius.
t = LM92.getTcrit()
print("Got Critical temperature: "..t.." C")
Get Low Window Temperature.
getTlow()
–
Low Window Temperature in degree Celsius.
t = LM92.getTlow()
print("Got Low Window temperature: "..t.." C")
Get High Window Temperature.
getThigh()
–
High Window Temperature in degree Celsius.
t = LM92.getThigh()
print("Got High Window temperature: "..t.." C")
--node.compile("lm92.lua")
LM92 = require("lm92")
gpio0 = 3
gpio2 = 4
sda = gpio0
scl = gpio2
addr = 0x48
i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once
LM92.setup(addr)
t = LM92.getTemperature()
print("Got temperature: "..t.." C")
--Seting comparison temperatures
LM92.setThyst(3)
LM92.setTcrit(40.75)
LM92.setTlow(28.5)
LM92.setThigh(31.625)
t = LM92.getThyst()
print("Got hyster: "..t.." C")
t = LM92.getTcrit()
print("Got Crit: "..t.." C")
t = LM92.getTlow()
print("Got Low: "..t.." C")
t = LM92.getThigh()
print("Got High: "..t.." C")