max31856 - max31856 Thermocouple temperature detection#
Adaptation status unknown
Note
This page document is automatically generated by this file. If there is any error, please submit issue or help modify pr, thank you!
Example
--Note: due to the use of sys.wait() all api need to be used in the coroutine
--Note: The configuration of the ads1115 needs to be configured according to the project requirements. You need to reconfigure the ADS1115_CONF_HCMD and ADS1115_CONF_LCMD !!!
-- Usage Examples
max31856 = require("max31856")
sys.taskInit(function()
max31856_spi_device = spi.deviceSetup(1,pin.PB11,1,1,8,5*1000*1000,spi.MSB,1,0)
max31856.init(max31856_spi_device)
while 1 do
local cj_temp = max31856.read_cj_temp()
if cj_temp then
log.info("max31856 cj_temp: ", cj_temp)
end
local tc_temp = max31856.read_tc_temp()
if tc_temp then
log.info("max31856 tc_temp: ", tc_temp)
end
log.info("max31856 fault: ", max31856.read_fault())
sys.wait(1000)
end
end)
max31856.set_tc_type(type)#
Setting the Thermocouple Type
Parameters
Incoming Value Type |
Explanation |
---|---|
number |
type max31856.TCTYPE_B max31856.TCTYPE_E max31856.TCTYPE_J max31856.TCTYPE_K max31856.TCTYPE_N max31856.TCTYPE_R max31856.TCTYPE_S max31856.TCTYPE_T |
Return Value
None
Examples
max31856.set_tc_type(max31856.TCTYPE_K) -- Set the type K
max31856.set_avgsel(sample_count)#
Setting the Thermocouple Voltage Transition Averaging Mode
Parameters
Incoming Value Type |
Explanation |
---|---|
number |
sample_count max31856.SAMPLE1 max31856.SAMPLE2 max31856.SAMPLE4 max31856.SAMPLE8 max31856.SAMPLE16 |
Return Value
None
Examples
max31856.set_avgsel(max31856.SAMPLE1) -- Set the average mode to 1 sample
max31856.set_cmode(type)#
Set conversion mode
Parameters
Incoming Value Type |
Explanation |
---|---|
number |
type max31856.ONESHOT max31856.CONTINUOUS |
Return Value
None
Examples
max31856.set_cmode(max31856.ONESHOT) -- Set the conversion mode to single conversion
max31856.read_fault()#
Read error code
Parameters
None
Return Value
return value type |
explanation |
---|---|
number |
Error Code |
Examples
local fault = max31856.read_fault()
max31856.read_cj_temp()#
Read cold junction temperature
Parameters
None
Return Value
return value type |
explanation |
---|---|
number |
Cold End Temperature |
Examples
local cj_temp = max31856.read_cj_temp()
max31856.read_tc_temp()#
Read tc temperature
Parameters
None
Return Value
return value type |
explanation |
---|---|
number |
tc Temperature |
Examples
local tc_temp = max31856.read_tc_temp()
max31856.init(spi_device)#
max31856 Initialization
Parameters
Incoming Value Type |
Explanation |
---|---|
userdata |
spi_device spi Device Handle |
Return Value
return value type |
explanation |
---|---|
boolean |
Initialization successful return true |
Examples
max31856.init(spi_device)