PT100 + MAX31865 + SKR 1.4 Turbo + Marlin, revisited

In PT100 + MAX31865 + SKR 1.4 Turbo + Marlin: how to get it all working, I got an RTD sensor working on my printer by sharing its SPI bus connection with the Trinamic motor drivers I’m using. What if you’re using “dumb” drivers like the DRV8825 or A4988, or you’re using some of Trinamic’s other drivers (like the TMC2209) that are configured over a UART connection? This post describes how to use the MicroSD-card SPI connection instead.

One disadvantage is that you can’t use a display that runs on the EXP1/EXP2 headers (such as the ReprapDiscount full-graphic display). (You could, but then you’d need to tap into the SPI bus going to the display’s SD-card slot, which is beyond the scope of this post.) I have one of Bigtreetech’s full-color touchscreens on the way; those plug into a designated connector that uses a UART connection. Until then (and probably after), I have an ESP-01S (running ESP3D) plugged into the 8-pin “WiFi” connector and can control the printer through that. The TFT35 went tango-uniform this past weekend. I pressed the ReprapDiscount display back into service, and it works just fine. I’m still using the MicroSD slot on the SKR instead of the display’s SD slot…not much of a difference.

Hardware Configuration

This is largely similar to my previous post, except that you’ll want to make up your cable with female connectors all around. Connections between the MAX31865 board and the SKR Pro 1.4 Turbo are as follows. The SPI connector is near the MicroSD slot; E1-CLS is the closed-loop motor connector for E1 from which we’re drawing 3.3V. The colored boxes overlaid on the board diagram show visually where everything plugs in.

MAX31865 pincolorsignalSKR connection typeSKR connection pin
2whiteGNDfemaleSPI, pin 6
3blackVDDfemaleE1-CLS, pin 2
4brownSCKfemaleSPI, pin 3
5redSDOfemaleSPI, pin 1
6orangeSDIfemaleSPI, pin 4
7yellowCSfemaleSPI, pin 5

Software Configuration

This varies a bit from the software-SPI config. First, the changes to Configuration.h in the thermal-settings section:

#define TEMP_SENSOR_0 -5
#define MAX6675_SS_PIN P0_26
#define MAX31865_SENSOR_OHMS_0 100
#define MAX31865_CALIBRATION_OHMS_0 430
#define MAX31865_USE_60HZ // omit if you're in a 50-Hz part of the world
#define MAX31865_USE_AUTO_MODE

Make sure SDSUPPORT is enabled:


Make sure you’re using the zeleps port of the Adafruit driver, and not the original…the original has lengthy delay loops that will slow your printer considerably. Go into ini/features.ini and look for this line:

TEMP_.+_IS_MAX31865 = Adafruit MAX31865 library@~1.1.0

Change it to this (all on one line):

TEMP_.+_IS_MAX31865 = AdafruitMAX31865Library=

Next, if you’re using a display plugged into EXP1 and EXP2, you’ll need to disable it. Other features you may have enabled that depend on having a working display may need to be disabled as well. A UART-connected display can be left enabled.

#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER // if it's what you're using

In Configuration_adv.h, make sure the onboard MicroSD slot is selected instead of a display-connected SD slot:


Due to a pullup on the SCK line, we need to use SPI mode 3 instead of mode 0. AFAIK, this doesn’t affect performance; it just changes signaling a little bit. Three changes need to be made to Marlin/src/HAL/LPC1768/HAL_SPI.cpp, which will be presented below as a patch…basically, there are three occurrences of SPI_MODE0 that need to be changed to SPI_MODE3:

diff --git a/Marlin/src/HAL/LPC1768/HAL_SPI.cpp b/Marlin/src/HAL/LPC1768/HAL_SPI.cpp
index 99db15f6e9..ee2bc1fa3d 100644
--- a/Marlin/src/HAL/LPC1768/HAL_SPI.cpp
+++ b/Marlin/src/HAL/LPC1768/HAL_SPI.cpp
@@ -123,7 +123,7 @@
-    SPI.setDataMode(SPI_MODE0);
+    SPI.setDataMode(SPI_MODE3);
@@ -187,7 +187,7 @@ SPIClass::SPIClass(uint8_t device) {
   #if BOARD_NR_SPI >= 1
     _settings[0].spi_d = LPC_SSP0;
-    _settings[0].dataMode = SPI_MODE0;
+    _settings[0].dataMode = SPI_MODE3;
     _settings[0].dataSize = DATA_SIZE_8BIT;
     _settings[0].clock = SPI_CLOCK_MAX;
     //_settings[0].clockDivider = determine_baud_rate(_settings[0].spi_d, _settings[0].clock);
@@ -195,7 +195,7 @@ SPIClass::SPIClass(uint8_t device) {
   #if BOARD_NR_SPI >= 2
     _settings[1].spi_d = LPC_SSP1;
-    _settings[1].dataMode = SPI_MODE0;
+    _settings[1].dataMode = SPI_MODE3;
     _settings[1].dataSize = DATA_SIZE_8BIT;
     _settings[1].clock = SPI_CLOCK_MAX;
     //_settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock);

If you haven’t previously fixed Adafruit_MAX31865.h (look for it under .pio/libdeps/LPC1769/), find this line near the top: Skip this step, as the zeleps driver includes this fix already:

#if (ARDUINO >= 100)


#if (ARDUINOLPC >= 100)


At first, I had noticed a bit of lag in the printer with the temperature sensor using a soft-SPI connection and thought I’d try switching to a hardware SPI port to see if it’ll lighten the load a bit. It didn’t. It was mainly noticeable in the display and when homing the printer. It didn’t seem to affect print speed or quality when printing from local storage, but streaming a print from something like OctoPrint or Pronterface stumbled pretty badly. What finally fixed this issue was the updated MAX31865 driver.

If you want to use the SD-card slot on the ReprapDiscount display, you might try using the SPI bus on the EXP2 connector instead. This might require driving the MAX31865 board with 5V instead of 3.3V to match the display’s 5V interface. The easiest way to tap into the signals would likely be a 2×5 female insulation-displacement connector on the EXP2 ribbon cable, into which pins can be stuck in the appropriate places. Set SDCARD_CONNECTION to LCD instead of ONBOARD if you go this route.