Since | Origin / Contributor | Maintainer | Source |
---|---|---|---|
2015-05-17 | Levente Tamas | Levente Tamas | lm92.lua |
This Lua module provides access to LM92 I²C ±0.33C 12bit+sign temperature sensor.
!!! note
This module requires `i2c` C module built into firmware.
lm92 = require("lm92")
lm92 = nil
package.loaded["lm92"] = nil
Function used to setup the address for lm92.
lm92.setup(address)
address
: I²C address used by LM92. Depends on the connection of A0
and A1
pins. Can be either 0x48
, 0x49
, 0x4a
or 0x4b
according to page 9 of LM92 datasheetnil
lm92 = require("lm92")
sda = 3 -- GPIO 0
scl = 4 -- GPIO 2
addr = 0x48
i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once
lm92.setup(addr)
Returns the temperature register’s content.
lm92.getTemperature()
None
Temperature in degree Celsius.
Makes the chip enter the low power shutdown mode.
lm92.shutdown()
None
nil
Makes the chip exit the low power shutdown mode.
lm92.wakeup()
None
nil
Set hysteresis Temperature.
lm92.setThyst(htemp)
htemp
: Hysteresis temperature from 130 to -55 in ºCnil
Set Critical Temperature.
lm92.setTcrit(ctemp)
ctemp
: Critical temperature from 130 to -55 in ºC
nil
Set Low Window Temperature.
lm92.setTlow(lwtemp)
####Parameters
lwtemp
: Low window temperature from 130 to -55 in ºCnil
Set High Window Temperature.
lm92.setThigh(hwtemp)
hwtemp
: High window temperature from 130 to -55 in ºCnil
Get hysteresis Temperature.
lm92.getThyst()
None
Hysteresis Temperature in degree Celsius.
Get Critical Temperature.
lm92.getTcrit()
None
Critical Temperature in degree Celsius.
Get Low Window Temperature.
lm92.getTlow()
None
Low Window Temperature in degree Celsius.
Get High Window Temperature.
lm92.getThigh()
None
High Window Temperature in degree Celsius.
--node.compile("lm92.lua")
lm92 = require("lm92")
sda = 3 -- GPIO 0
scl = 4 -- GPIO 2
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")