Read temperature from 6 PT100 with ESP32

Dear fans of arduino projects,

I would like to ask for your help, advice, regarding my project. It involves connecting 6 PT100 sensors using max 31865 to ESP32. I have some experience with arduino boards (CNC) but I am a complete novice when it comes to ESP32. I used various forums and discussions to connect max 31865 to ESP32 (sharing pins CLK (pin 12), SDO (pin 13), SDI (pin 11), as well as GND and 3V) for individual CS I chose pins on ESP32 -2, 4, 5, 15, 16, 17. The problem is that when connecting ESP32 to Blynk, the connection is unstable (it often drops), which can also be a problem with wifi. However, a bigger problem is that the added sensors in Blynk do not show real temperatures (-200, -900). this is a sketch for ESP32:

// =====================================================
// ESP32-S3 + 6x MAX31865 PT100 (2-wire) + Blynk IoT
// CS pins: 2,4,5,15,16,17 | SPI2: MOSI=11,MISO=13,SCK=12
// == <Adafruit_MAX31865.h>

// === SENSORS (SPI2 default ESP32-S3: MOSI=11, MISO=13, SCK=12) ===
Adafruit_MAX31865 sensor1(11, 13, 12, 2); // CS pin 2
Adafruit_MAX31865 sensor2(11, 13, 12, 4); // CS pin 4
Adafruit_MAX31865 sensor3(11, 13, 12, 5); // CS pin 5
Adafruit_MAX31865 sensor4(11, 13, 12, 15); // CS pin 15
Adafruit_MAX31865 sensor5(11, 13, 12, 16); // CS pin 16
Adafruit_MAX31865 sensor6(11, 13, 12, 17); // CS pin 17

void setup() { 
Serial.begin(115200); 
delay(2000); 
Serial.println("Starting ESP32-S3 + 6x MAX31865..."); 

// Initialization MAX31865 (2-wire PT100) 
sensor1.begin(MAX31865_2WIRE); 
sensor2.begin(MAX31865_2WIRE); 
sensor3.begin(MAX31865_2WIRE); 
sensor4.begin(MAX31865_2WIRE); 
sensor5.begin(MAX31865_2WIRE); 
sensor6.begin(MAX31865_2WIRE); 

// connect WiFi + Blynk 
Blynk.begin(BLYNK_AUTH_TOKEN, WIFI_SSID, WIFI_PASS); 

Serial.println("READY! Check Serial Monitor + Blynk app.");
}

void loop() { 
Blynk.run(); 

//read all sensors 
float temps[6]; 
temps[0] = readTemp(&sensor1); 
temps[1] = readTemp(&sensor2); 
temps[2] = readTemp(&sensor3); 
temps[3] = readTemp(&sensor4); 
temps[4] = readTemp(&sensor5); 
temps[5] = readTemp(&sensor6); 

// Serial output 
Serial.printf("T1:%.1f T2:%.1f T3:%.1f T4:%.1f T5:%.1f T6:%.1f °C\n", 
temps[0],temps[1],temps[2],temps[3],temps[4],temps[5]); 

// Blynk Virtual Pins V1-V6 
Blynk.virtualWrite(V1, temps[0]); 
Blynk.virtualWrite(V2, temps[1]); 
Blynk.virtualWrite(V3, temps[2]);
Blynk.virtualWrite(V4, temps[3]);
Blynk.virtualWrite(V5, temps[4]);
Blynk.virtualWrite(V6, temps[5]);

delay(2500); // 2.5s
}

// === read temperatures with diagnostic ===
float readTemp(Adafruit_MAX31865* sensor) {
uint8_t fault = sensor->readFault();
if (fault) {
Serial.print("FAULT: 0x"); Serial.println(fault, HEX);
sensor->clearFault();
return -999.9;
}

float temp = sensor->temperature(RNOMINAL, RREF);
return temp;
}

Please could you help me? Advice on correcting the sketch?

Thank you very much and I wish you a pleasant day and many successful projects.

Hello

we would like to ask you a simple help and advice for our forum and your question: do yourself a favour and please read How to get the best out of this forum and post accordingly (including code with code tags).

Accordingly please correct your post and add code tags around your code.

There is a small pencil image below your existing posts.

  • click on this pencil ➜ that will let you edit your post.
  • Select the part of the text that corresponds to the code
  • Click on the <code/> icon in the toolbar to indicate that it is code
  • click image Save Edit

(Also make sure to properly indent the code in the IDE before copying and pasting it here. This can be done by pressing ctrlT on a PC or cmdT on a Mac)


To your question, the extreme values suggest a wiring or configuration fault on the MAX31865, but using software SPI with six devices can also cause unstable reads on an ESP32, especially when WiFi is active, so hardware SPI is preferable. The choice of CS pins (notably GPIO 2 and 15) could be an issue on some ESP32 (unstable boot or behavior depending on pull states) and the 2.5 s blocking delay can further destabilize operation and break Blynk synchronization.