A driver for the MAX31865 RTD-to-Digital converter, written using/for the esp-idf framework. Supports all documented features of the MAX31865 including fault detection and the DRDY output.
See examples/simple/main/main.cpp.
int miso, int mosi, int sck, int cs
- GPIO numbers for SPI communication to the chipint drdy
- GPIO number for the DRDY output of the MAX31865. Not used if equal to-1
. If set, RTD reads will block until DRDY is low.spi_host_device_t host
- ESP32 SPI host device, useful if the application needs to communicate with other SPI devices simultaneously.
uint16_t rtd
- 15-bit RTD resistance value read from the MAX31865max31865_rtd_config_t rtdConfig
- configuration relating to the RTD itself
float
- the temperature value in degrees Celsius represented by the RTD resistance with the given configuration. Uses the Callendar-van Dusen equation with constants taken from here.
float temperature
- a temperature in degrees Celsius.max31865_rtd_config_t rtdConfig
- configuration relating to the RTD itself
uint16_t
- 15-bit RTD resistance value as would be represented in the MAX31865 registers.
Max31865Error error
- an error type read from the MAX31865 fault register.
const char*
- a string describing the error type.
Initialises the communication with the MAX31865, and configures it. Must be called before any other instance methods!
max31865_config_t config
- configuration for the MAX31865
esp_err_t
- any error encountered when communicating with the chip.
Sets the configuration for an already initialized instance.
max31865_config_t config
- configuration for the MAX31865
Gets the current configuration from a MAX31865.
max31865_config_t *config
- pointer to the configuration struct to be populated with the current state.
Sets the threshold RTD resistances (not temperatures) below/above which the MAX31865 will declare a fault. Use with MAX31865::temperatureToRTD
for setting min/max temperatures.
uint16_t min
- minimum RTD resistance value (15-bit)uint16_t max
- maximum RTD resistance value (15-bit)
Clears the fault status bit in the config register.
Reads the specific fault type out of the fault status register.
Max31865Error *fault
- pointer to the fault type variable to be filled (output param).
Gets the current RTD resistance (15-bit value) from the MAX31865 and optionally populates a fault variable. Fails with ESP_ERR_INVALID_RESPONSE
if a fault is detected. Does the following in the process of reading:
- Enables a 1-shot read and/or Vbias if they are not available, and blocks for 65ms and 10ms, respectively, after doing so in order to have valid reads.
- If a pin for DRDY was given, blocks until receiving a negative edge interrupt on this pin.
- Reads the fault bit, and if equal to 1 reads the full fault status using
readingFaultStatus
- Restores Vbias to 0 if it was changed for the read.
uint16_t *rtd
- pointer to the RTD resistance value (15-bit) to populate.Max31865Error *fault
- optionally, an error type to populate if a fault is detected.
bool vbias
- Enables Vbias if truebool autoConversion
- Enables automatic conversion if true (otherwise 1-shot)Max31865NWires nWires
- 2, 3 or 4-wire RTD configurationMax31865FaultDetection faultDetection
- which fault detection cycle mode to enableMax31865Filter filter
- mains sinc filter frequenct
float ref
- reference resistor value (Ohms)float nominal
- nominal RTD resistance at 0 degrees C (eg PT100 or PT1000)
RTD wiring configuration
Three
Two
- defaultFour
- default
Fault detection cycle
NoAction
- defaultAutoDelay
- Fault detection with automatic delayManualDelayCycle1
- Run fault detection with manual delay (cycle 1)ManualDelayCycle2
- Finish fault detection with manual delay (cycle 2)
Mains frequency filter
Hz50
- filter 50Hz mainsHz60
- filter 60Hz mains (default)
Fault status register error type
NoError
- defaultVoltage
- Overvoltage or undervoltage faultRTDInLow
- RTDIN- < 0.85*VBIAS (FORCE- open)RefLow
- REFIN- < 0.85*VBIAS (FORCE- open)RefHigh
- REFIN- > 0.85*VBIASRTDLow
- RTD below low thresholdRTDHigh
- RTD above high threshold