herosdevices.hardware.raspberrypi.max318xx.max318xx¶
Implements the MAX31865 resistance-to-digital converter interface.
The MAX31865 chip communicates via SPI, and in this implementation, SPI communication is carried out through bit-banging using the RPi.GPIO library. For better performance, using an SPI library such as spidev is recommended, but this code is a first approach.
Note: numpy is only required if implementing the full Calendar-Van Dusen equations.
This code is adapted from steve71’s work: https://github.com/steve71/MAX31865
Module Contents¶
- exception herosdevices.hardware.raspberrypi.max318xx.max318xx.FaultError¶
Bases:
ExceptionException class for handling faults detected in the RTD or wiring.
- class herosdevices.hardware.raspberrypi.max318xx.max318xx.MAX318xx(cs_pins: dict, miso_pin: int = 9, mosi_pin: int | None = 10, clk_pin: int = 11)¶
Base class for MAX318xx series resistance-to-digital converters.
Handles SPI communication via bit-banging using GPIO pins.
- cs_pin¶
{“description”: “Chip select GPIO pin number”}.
- Type:
dict
- miso_pin¶
Master In Slave Out GPIO pin number.
- Type:
int
- mosi_pin¶
Master Out Slave In GPIO pin number.
- Type:
int
- clk_pin¶
Clock GPIO pin number.
- Type:
int
- cs_pins¶
- miso_pin = 9¶
- mosi_pin = 10¶
- clk_pin = 11¶
- write_register(reg_num: int, data_byte: int) None¶
Write a byte to a specified register.
- Parameters:
regNum (int) – Register number to write to.
dataByte (int) – Data byte to write.
- read_register(cs_pin: int, num_registers: int, reg_num_start: int | None = None) list[int]¶
Read one or more bytes starting from a specified register.
- Parameters:
cs_pin (int) – Chip select GPIO pin number.
numRegisters (int) – Number of bytes to read.
regNumStart (int, optional) – Starting register number for the read operation.
- Returns:
List of bytes read from the device.
- Return type:
list
- send_byte(byte: int) None¶
Send a byte via SPI by bit-banging.
- Parameters:
byte (int) – Byte value to send.
- recv_byte() int¶
Receive a byte via SPI by bit-banging.
- Returns:
Byte received.
- Return type:
int
- create_dict(values: list[float], observable: str, unit: str) dict¶
Build dictionary of observables to be returned by the sensor.