Need Help with max31865

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
PiratePointBrewer
 
Posts: 4
Joined: Thu Nov 24, 2022 6:23 am

Need Help with max31865

Post by PiratePointBrewer »

I have built a home brew system and have used PIDs to control the temperatures. As that sysem is working well I want to use (2) max31865 modules to control and display the temperatures of the Brew Kettle = BkTemp, and the Mash Tun = MtTemp. Using the short code below. I can successfully measure one temperature but not two. I have checked and tested both the p100 rtd's and the max31865 modules. I would appreciate any help I can get to make this work. Code below:

in the Library inclusion at the start:

#include <Adafruit_MAX31865.h>

// For Software SPI use - CS, DI, Do, CLK
Adafruit_MAX31865 maxA = Adafruit_MAX31865(2, A3, A2, A1);
Adafruit_MAX31865 maxB = Adafruit_MAX31865(3, A3, A2, A1);

In setup:

maxA.begin(MAX31865_3WIRE); // set to 3WIRE
maxB.begin(MAX31865_3WIRE); // set to 3WIRE

The Function to read the temperatures:

void GetTemps() {

// Get BkTemp

float rtdA = maxA.readRTD();
float ratioA = rtdA;
ratioA /= 32768;
byte tempA = maxA.temperature(RNOMINAL, RREF);
tempA += .05;
byte tempCA = tempA;
byte tempFA = (tempA * 9 / 5 + 32);
BkTemp = tempFA;

delay(100);

//Get MtTemp

float rtdB = maxB.readRTD();
float ratioB = rtdB;
ratioB /= 32768;
byte tempB = maxB.temperature(RNOMINAL, RREF);
tempB += .05;
byte tempCB = tempB;
byte tempFB = (tempCB * 9 / 5 + 32);
MtTemp = tempFB;

return;
}

I appreciate any and all suggestion in advance!!

Thanks,
Preston

User avatar
dastels
 
Posts: 11706
Joined: Tue Oct 20, 2015 3:22 pm

Re: Need Help with max31865

Post by dastels »

Is there a reason you aren't using hardware SPI?

Also, what is happening?

Dave

User avatar
PiratePointBrewer
 
Posts: 4
Joined: Thu Nov 24, 2022 6:23 am

Re: Need Help with max31865

Post by PiratePointBrewer »

Yes! The reason is that the interface board I made is a wire wrap uno shield. The original design was to allow the PID's to control temperatures. The hardware SPI pins were used for other digital I/O to control the pumps and read the probes used to measure liquid volume. Everything came together well and I later decided to try the rtd's to control and display temps. I had only used (1) analog pin in a voltage divider scheme for keypad input. So I built a second layer interface board to hook up the two max31865 modules and use software SPI and an the unused analog pins as digital I/O. I have decided that there are improvements I can make to the interface design, but what I have works well with the PIDs and it is Winter, my brewing season!. Once our boats are out of the water I brew about 250 gallon of beer over the winter and keg it for next summer's use. Hard to turn down a cold draft beer at $0.25 a glass!! When I redesign and make a new interface board I will use hardware SPI.

When I try the max's, the one for maxA using cs pin 2 always works. the maxB reads either 57 or 123?? If I swap the modules and rtd's, they all work. I notice when maxB is activated I get activity on the LED pin 13. Nothing in the program or interface uses pin 13 as early on I didn't know if it would be needed. I wondered if there was somethin in the Library that was using the pin but loading the .h or .ccp to notepad++, I got in way over my head!

User avatar
PiratePointBrewer
 
Posts: 4
Joined: Thu Nov 24, 2022 6:23 am

Re: Need Help with max31865

Post by PiratePointBrewer »

I didn't mention that as long as I only have one max compiled either socket works just by changing the cs between 2 and 3. The rtd that is read always follows cs pin 2. To clarify, if i use pin 2 in maxb and pin 3 in maxA. Only maxB reads. If I change maxA to pin 2 and maxB to to pin 3, only maxA reads.

I didn't say it befoe, but thanks for responding!

Preston

User avatar
dastels
 
Posts: 11706
Joined: Tue Oct 20, 2015 3:22 pm

Re: Need Help with max31865

Post by dastels »

D13 is also the hardware SPI clock signal.

I don't see anything in the max31865 library that explains the behavior. Maybe it's something with the software SPI?

It may be worth an experiment to write a test sketch to just get and Serial.print the temperatures, using software SPI, then using hardware SPI. To see if it makes a difference.

Dave

User avatar
PiratePointBrewer
 
Posts: 4
Joined: Thu Nov 24, 2022 6:23 am

Re: Need Help with max31865

Post by PiratePointBrewer »

Hello Dave,

I really appreciate your follow up. At this point I will call the problem "resolved" but not "solved"!

Today I made an assumption that there was something in the library that did not like the way I was using it to have two temperature modules that it didn't like. Then I thought that that has to be bs!! I should be able to have as many on the spi bus as I had "cs pins"!! So I thought how that would look in software. I would declare each instance i.e. maxA and maxB:

Adafruit_MAX31865 maxA = Adafruit_MAX31865(2, A3, A2, A1); // was 2
Adafruit_MAX31865 maxB = Adafruit_MAX31865(3, A3, A2, A1); // was 3

Then in seup(){

maxA.begin(MAX31865_3WIRE); // set to 3WIRE
maxB.begin(MAX31865_3WIRE); // set to 3WIRE

But in the main loop I would call two separate functions to calculate the temperatures

void loop(){
GetBkTemp(); // Boil Kettle Temperature
GetMtTemp(); // Mash Tun Temperature

The functions are almost identical

void GetBkTemp() {

// Get BkTemp
float rtd = maxA.readRTD();
float ratio = rtd;
ratio /= 32768;
byte temp = maxA.temperature(RNOMINAL, RREF);
temp += .05;
byte tempC = temp;
byte tempF = (temp * 9 / 5 + 32);
BkTemp = tempF;
return;
}

void GetMtTemp() {
//Get MtTemp
float rtd = maxB.readRTD();
float ratio = rtd;
ratio /= 32768;
byte temp = maxB.temperature(RNOMINAL, RREF);
temp += .05;
byte tempC = temp;
byte tempF = (tempC * 9 / 5 + 32);
MtTemp = tempF;
return;
}

This works perfectly!! I am not sure exactly why but will assume it was MY Fault and move on with the project!
This works with my wife too!!! (smile)

Again, many thanks for your response and follow up. If you have another thought I will check up but certainly do not wish to take up more of your time on the issue. First brew completely controlled by the uno will be Tuesday after setup and prep Monday!

The first glass of the brew will be called DAVE!!

Thanks again,
Preston

User avatar
dastels
 
Posts: 11706
Joined: Tue Oct 20, 2015 3:22 pm

Re: Need Help with max31865

Post by dastels »

!!

I wish I could sample it with you.

Dave

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Arduino”