Hello gentlemen (and ladies),
I want to read many RTDs (pt1000) using a max31865 module connected to an ESP32 SPI port. Reading one RTD is successful and steady and nice and dandy. But i need to read 3 sensors, so i saw on a PCB in an autoclave that they used ADG711 to switch between them. Those are analog switch ICs with low ON resistance (about 4 Ohms) so i decided to try that route.
I didn't have ADG711 near me, so i tried the equally same thing MAX4602, which has lower resistance (about 2.5 Ohm at 24V Vcc).
Then in software, i'm using a counter to switch between the RTDs, once a second, and read the temp, go to the next one... etc. My application will be using between 2-4 sensors so i can't just use two MAX31865. And then the trouble begins...
My minimal test code is this:
#include <Adafruit_MAX31865.h> //by adafruit
Adafruit_MAX31865 thermo = Adafruit_MAX31865(5);
#define RREF 3950.0
#define RNOMINAL 1000.0
#define ptc1Pin 25
#define ptc2Pin 33
float Ti, Tg, tmp;
uint8_t ptcID = 1; //index runs through PT sensors
//time stuff
unsigned long lastPTCUpdate;
unsigned long timeNow;
#define PTCChangeInterval 1000 //change PTC input every XX ms
void setup() {
Serial.begin(115200);
delay(100);
Serial.flush();
pinMode(25, OUTPUT);
pinMode(33, OUTPUT);
thermo.begin(MAX31865_2WIRE);
}
void loop() {
timeNow = millis();
//read temp and change ptc in intervals
if (timeNow - lastPTCUpdate > PTCChangeInterval) { //first read temperature, then change PT ;)
lastPTCUpdate = timeNow;
//first read the temperature (after it's settled)
uint16_t rtd = thermo.readRTD();
tmp = thermo.temperature(RNOMINAL, RREF);
if (ptcID == 1) Ti = tmp;
if (ptcID == 2) Tg = tmp;
Serial.print(Ti); Serial.print(","); Serial.println(Tg);
ptcID++; // then go to next ptc
if (ptcID == 3) ptcID = 1; //boundary condition for ptc id
if (ptcID == 1) { //switch on first ptc
digitalWrite(ptc1Pin, HIGH);
digitalWrite(ptc2Pin, LOW);
}
if (ptcID == 2) { //switch on second ptc
digitalWrite(ptc1Pin, LOW);
digitalWrite(ptc2Pin, HIGH);
}
}
}
and this is the schematic (forgive my drawing skills...)
The gist of the schematic is, i'm using the left 2 channels to switch both wires of the one RTD, and the right 2 channels to switch both wires of the second RTD. The initial thing i had tried was keep one RTD wire common and just switch the second one, but that went horribly wrong.
I'm not using delays anywhere, and i avoid reading the RTDs continuously, since it seems to be a bit slow blocking the loop for a few milliseconds, so i'm sampling the temp once per second, i don't need to to be faster anyway.
But printing these two temperatures (Ti and Tg in my example) sometimes works and sometimes it generates a mess. Mostly it's a mess... i'm having one RTD in a bottle of water (should be very steady temp) and i'm heating the other one with hot air to see how the system responds. I've been trying out stuff for 3 days and just can't get it to work... losing my mind!
Samples of using the plot monitor to read stuff...
Any ideas/comments/different way of doing it are more than welcome!
Thank you for your time!