MAX31856
¶
CircuitPython module for the MAX31856 Universal Thermocouple Amplifier. See examples/simpletest.py for an example of the usage.
Author(s): Bryan Siepert
Implementation Notes¶
Hardware:
Adafruit Universal Thermocouple Amplifier MAX31856 Breakout (Product ID: 3263)
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- class adafruit_max31856.MAX31856(spi: SPI, cs: DigitalInOut, thermocouple_type: int = 3)¶
Driver for the MAX31856 Universal Thermocouple Amplifier
- Parameters:
spi (SPI) – The SPI bus the MAX31856 is connected to.
cs (Pin) – The pin used for the CS signal.
thermocouple_type (ThermocoupleType) – The type of thermocouple. Default is Type K.
sampling (~int) – Number of samples to be averaged [1,2,4,8,16]
filter_50hz (~bool) – Filter 50Hz mains frequency instead of 60Hz
Quickstart: Importing and using the MAX31856
Here is an example of using the
MAX31856
class. First you will need to import the libraries to use the sensorimport board from digitalio import DigitalInOut, Direction import adafruit_max31856
Once this is done you can define your
board.SPI
object and define your sensor objectspi = board.SPI() cs = digitalio.DigitalInOut(board.D5) # Chip select of the MAX31856 board. sensor = adafruit_max31856.MAX31856(spi, cs)
Now you have access to the
temperature
attributetemperature = sensor.temperature
- property averaging: int¶
Number of samples averaged together in each result. Must be 1, 2, 4, 8, or 16. Default is 1 (no averaging).
- property fault: Dict[str, bool]¶
A dictionary with the status of each fault type where the key is the fault type and the value is a bool if the fault is currently active
Key
Fault type
“cj_range”
Cold junction range fault
“tc_range”
Thermocouple range fault
“cj_high”
Cold junction high threshold fault
“cj_low”
Cold junction low threshold fault
“tc_high”
Thermocouple high threshold fault
“tc_low”
Thermocouple low threshold fault
“voltage”
Over/under voltage fault
“open_tc”
Thermocouple open circuit fault
- initiate_one_shot_measurement() None ¶
Starts a one-shot measurement and returns immediately. A measurement takes approximately 160ms. Check the status of the measurement with
oneshot_pending
; when it is false, the measurement is complete and the value can be read withunpack_temperature
.
- property noise_rejection: Literal[50, 60]¶
The frequency (Hz) to be used by the noise rejection filter. Must be 50 or 60. Default is 60.
- property oneshot_pending: bool¶
A boolean indicating the status of the one-shot flag. A True value means the measurement is still ongoing. A False value means measurement is complete.
- property reference_temperature: float¶
Wait to retrieve temperature of the cold junction in degrees Celsius. (read-only)
- property reference_temperature_thresholds: Tuple[float, float]¶
The cold junction’s low and high temperature thresholds as a
(low_temp, high_temp)
tuple
- property temperature: float¶
Measure the temperature of the sensor and wait for the result. Return value is in degrees Celsius. (read-only)
- class adafruit_max31856.ThermocoupleType¶
An enum-like class representing the different types of thermocouples that the MAX31856 can use. The values can be referenced like
ThermocoupleType.K
orThermocoupleType.S
Possible values areThermocoupleType.B
ThermocoupleType.E
ThermocoupleType.J
ThermocoupleType.K
ThermocoupleType.N
ThermocoupleType.R
ThermocoupleType.S
ThermocoupleType.T