This project demonstrates precise temperature measurement using the MAX31865 RTD-to-digital converter with an STM32F103C6 microcontroller. The system supports PT100/PT1000 sensors (2/3/4-wire) and communicates through the SPI protocol. Data such as raw RTD value, resistance, ratio, and calculated temperature is sent to a UART terminal. The project also integrates fault detection mechanisms to ensure reliability.
The MAX31865 is a high-precision digital converter designed specifically for use with PT100 and PT1000 temperature sensors (RTDs). It integrates essential signal conditioning, a 15-bit analog-to-digital converter (ADC), and input protection onto a single chip to deliver accurate and reliable temperature measurements.
It communicates via a simple 4-wire SPI interface (SCLK, SDI, SDO, and CS), making it easy to connect to an STM32 microcontroller. In this setup, the STM32 acts as the master controller, managing the communication clock to read temperature data and monitor the system for any faults in real-time
STM32CubeMX Setup- MCU Selection: STM32F103C6 (8 MHz clock)
- SPI1 Configuration:
-
Mode: Full-Duplex Master
-
Prescaler: 32 (250 kHz clock)
-
CPOL: Low, CPHA: 1 Edge
-
GPIO Configuration:
-
PA4 → Output (Chip Select)
- UART1 Configuration:
-
Mode: Asynchronous
-
Baud Rate: 9600
-
Word Length: 8 bits
- Generate initialization code in STM32CubeIDE.
Important Functions (from main.c)
- readRTD() → Reads raw 15-bit RTD value
- temperature() → Converts resistance to °C
- readFault() / clearFault() → Fault detection and reset
- UART print section:
-
Prints RTD raw value
-
Prints ratio and resistance
-
Prints temperature with decorative formatting
-
Reports fault conditions (high/low threshold, REFIN errors, open RTD, under/over voltage)
Required Components
- STM32F103C6 microcontroller
- MAX31865 module
- PT100 RTD sensor (4-wire type shown)
- Virtual Terminal (for UART1 output)
- SPI Debugger (optional for monitoring)
- Power (3.3V, GND)
Steps
- Connect SPI lines:
-
PA5 → SCLK, PA6 → MISO, PA7 → MOSI, PA4 → CS
- Connect UART1 (PA9 → TX) to Virtual Terminal.
- Connect RTD (PT100) to MAX31865 (4-wire configuration).
- Load STM32 .hex file generated from CubeIDE into Proteus.
- Run simulation → Observe RTD values, resistance, and temperature in the Virtual Terminal.
If you have any questions or suggestions don't hesitate to leave a comment below
Comments