0

Multiple MAX31865
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Multiple MAX31865

by clintp on Mon Jul 24, 2017 4:34 pm

I am trying to Connect four MAX31865 break out boards to an arduino MEGA. I understand that each board needs to have its own CS pin assigned, however I have not be able to implement that. How would one go about making multiple boards work at the same time?

clintp
 
Posts: 7
Joined: Mon Jul 24, 2017 4:23 pm

Re: Multiple MAX31865

by adafruit_support_bill on Mon Jul 24, 2017 4:37 pm

Connect the CS pin for each board to a different pin. The clock and data pins can be shared. In the code, for each instance of Adafruit_MAX31865, specify the pins you are using.

adafruit_support_bill
 
Posts: 73190
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple MAX31865

by clintp on Mon Jul 24, 2017 5:11 pm

Thank you, I am getting an error stating no matching function for call to ''Adafruit_MAX31865::Adafruit_MAX31865(int, int)'

Adafruit_MAX31865 max = Adafruit_MAX31865(53,45);

here is the code I am trying to use.

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_MAX31865.h>
#include "SPI.h"

// use hardware SPI, just pass in the CS pin
Adafruit_MAX31865 max = Adafruit_MAX31865(53,45);

// The value of the Rref resistor. Use 430.0!
#define RREF 430.0


void setup() {
  Serial.begin(115200);
SPI.begin();
  max.begin(MAX31865_4WIRE);  // set to 2WIRE or 4WIRE as necessary
}

void loop() {
  uint16_t rtd = max.readRTD();

  Serial.print("RTD value: "); Serial.println(rtd);
  float ratio = rtd;
  ratio /= 32768;
  Serial.print("Ratio = "); Serial.println(ratio,8);
  Serial.print("Resistance = "); Serial.println(RREF*ratio,8);
  Serial.print("Temperature = "); Serial.println(max.temperature(100, RREF));

  // Check and print any faults
  uint8_t fault = max.readFault();

  Serial.println();
  delay(1000);
}
Last edited by adafruit_support_bill on Mon Jul 24, 2017 5:17 pm, edited 1 time in total.
Reason: Please use [code] tags when submitting code to the forums.

clintp
 
Posts: 7
Joined: Mon Jul 24, 2017 4:23 pm

Re: Multiple MAX31865

by adafruit_support_bill on Mon Jul 24, 2017 5:20 pm

You are only defining one instance of the sensor. You can't have one sensor with 2 CS pins. You need to define one instance for each sensor you are connecting:

Code: Select all | TOGGLE FULL SIZE
// use hardware SPI, just pass in the CS pin
Adafruit_MAX31865 max_1 = Adafruit_MAX31865(53);
Adafruit_MAX31865 max_2 = Adafruit_MAX31865(45);

adafruit_support_bill
 
Posts: 73190
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple MAX31865

by clintp on Mon Jul 24, 2017 5:43 pm

I tried to implement the code like in your example however I keep getting different errors depending on how I change the code. It only seems to work in its original format. which I will include below. I took this code from get Hub there was a link from the adafruit tutorial. So I don't really understand how the code works.

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_MAX31865.h>

// Use software SPI: CS, DI, DO, CLK
//Adafruit_MAX31865 max = A (37, 39, 41, 43);

 //use hardware SPI, just pass in the CS pin
Adafruit_MAX31865 max = Adafruit_MAX31865(54);

// The value of the Rref resistor. Use 430.0!
#define RREF 430.0


void setup() {
  Serial.begin(115200);

  max.begin(MAX31865_4WIRE);  // set to 2WIRE or 4WIRE as necessary
}

void loop() {
  uint16_t rtd = max.readRTD();

  Serial.print("RTD value: "); Serial.println(rtd);
  float ratio = rtd;
  ratio /= 32768;
  Serial.print("Ratio = "); Serial.println(ratio,8);
  Serial.print("Resistance = "); Serial.println(RREF*ratio,8);
  Serial.print("Temperature = "); Serial.println(max.temperature(100, RREF));

  // Check and print any faults
  uint8_t fault = max.readFault();

  Serial.println();
  delay(1000);
}


I added the _1 and _2 to like in your example and received the following error.



C:\Users\Clint\Desktop\Packless\arduino\multipal_sensors_rtd\multipal_sensors_rtd.ino: In function 'void setup()':

multipal_sensors_rtd:14: error: 'max' was not declared in this scope

max.begin(MAX31865_4WIRE); // set to 2WIRE or 4WIRE as necessary

^

C:\Users\Clint\Desktop\Packless\arduino\multipal_sensors_rtd\multipal_sensors_rtd.ino: In function 'void loop()':

multipal_sensors_rtd:18: error: 'max' was not declared in this scope

uint16_t rtd = max.readRTD();

^

exit status 1
'max' was not declared in this scope

Again thank you for the help.
Attachments
2.PNG
please use [code] tags when submitting code to the forums.
2.PNG (61.74 KiB) Viewed 1382 times
1.PNG
1.PNG (26.05 KiB) Viewed 1382 times

clintp
 
Posts: 7
Joined: Mon Jul 24, 2017 4:23 pm

Re: Multiple MAX31865

by adafruit_support_bill on Mon Jul 24, 2017 6:02 pm

Please use [ code ] tags when submitting code to the forums.

'max' was not declared in this scope


You no longer have a Adafruit_MAX31865 named "max". You have two of them named "max_1" and "max_2".

To use those sensors in your code, you need to reference them separately. And reference them by the names you have assigned them.

Code: Select all | TOGGLE FULL SIZE
  max.begin(MAX31865_4WIRE);

becomes:
Code: Select all | TOGGLE FULL SIZE
  max_1.begin(MAX31865_4WIRE);
  max_2.begin(MAX31865_4WIRE);

adafruit_support_bill
 
Posts: 73190
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple MAX31865

by clintp on Fri Jul 28, 2017 11:21 am

I am still having errors occur. I still don't understand how to name the max functions individually. Whenever I try to they turn from orange to black. I understand the max function is used to compare two numbers and finds the maximum which in this case i'm guessing is the resistance between the wire pairs. I am also wondering if because I am renaming things if it will affect the ability to use the library used to run one board.

This is the code I am trying to use now. The error I am getting says 'class Adafruit_MAX31865' has no member named 'temperature1'
How can I fix this?

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_MAX31865.h>
#include "SPI.h"

// use hardware SPI, just pass in the CS pin
Adafruit_MAX31865 max_1 = Adafruit_MAX31865(53);
Adafruit_MAX31865 max_2= Adafruit_MAX31865(46);
// The value of the Rref resistor. Use 430.0!
#define RREF 430.0


void setup() {
  Serial.begin(115200);
SPI.begin();
  max_1.begin(MAX31865_4WIRE);  // set to 2WIRE or 4WIRE as necessary
   max_2.begin(MAX31865_4WIRE);
}

void loop() {
  uint16_t rtd1 = max_1.readRTD();
  uint16_t rtd2 = max_2.readRTD();

  Serial.print("RTD value1: "); Serial.println(rtd1);
    Serial.print("RTD value2: "); Serial.println(rtd2);
  float ratio1 = rtd1;
    float ratio2 = rtd2;
  ratio1 /= 32768;
    ratio2 /= 32768;
  Serial.print("Resistance1 = "); Serial.println(RREF*ratio1,8);
    Serial.print("Resistance2 = "); Serial.println(RREF*ratio2,8);
   
  Serial.print("Temperature1 = "); Serial.println(max_1.temperature1(100, RREF));
    Serial.print("Temperature2 = "); Serial.println(max_2.temperature2(100, RREF));

  // Check and print any faults
  uint8_t fault1 = max_1.readFault1();
  uint8_t fault2 = max_2.readFault2();
 
  Serial.println();
  delay(1000);
}

Thank you

Also I don't understand what was meant by "tags when submitting code to the forums."

clintp
 
Posts: 7
Joined: Mon Jul 24, 2017 4:23 pm

Re: Multiple MAX31865

by adafruit_support_bill on Fri Jul 28, 2017 12:02 pm

Press the [code] button and paste your code between the tags.

If you are getting compile errors, please post the exact text of the error. That will tell you which line the error was detected on and what the compiler does not like.

adafruit_support_bill
 
Posts: 73190
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple MAX31865

by clintp on Fri Jul 28, 2017 12:03 pm

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_MAX31865.h>
#include "SPI.h"

// use hardware SPI, just pass in the CS pin
Adafruit_MAX31865 max_1 = Adafruit_MAX31865(53);
Adafruit_MAX31865 max_2= Adafruit_MAX31865(46);
// The value of the Rref resistor. Use 430.0!
#define RREF 430.0


void setup() {
  Serial.begin(115200);
SPI.begin();
  max_1.begin(MAX31865_4WIRE);  // set to 2WIRE or 4WIRE as necessary
   max_2.begin(MAX31865_4WIRE);
}

void loop() {
  uint16_t rtd1 = max_1.readRTD();
  uint16_t rtd2 = max_2.readRTD();

  Serial.print("RTD value1: "); Serial.println(rtd1);
    Serial.print("RTD value2: "); Serial.println(rtd2);
  float ratio1 = rtd1;
    float ratio2 = rtd2;
  ratio1 /= 32768;
    ratio2 /= 32768;
  Serial.print("Resistance1 = "); Serial.println(RREF*ratio1,8);
    Serial.print("Resistance2 = "); Serial.println(RREF*ratio2,8);
   
  Serial.print("Temperature1 = "); Serial.println(max_1.temperature1(100, RREF));
    Serial.print("Temperature2 = "); Serial.println(max_2.temperature2(100, RREF));

  // Check and print any faults
  uint8_t fault1 = max_1.readFault1();
  uint8_t fault2 = max_2.readFault2();
 
  Serial.println();
  delay(1000);
}


The compiling error is happening with
Code: Select all | TOGGLE FULL SIZE
  Serial.print("Temperature1 = "); Serial.println(max_1.temperature1(100, RREF));
I think it is happening because the library im trying to use doesn't have temperature1 only a single temperature. Can I modify the code some how or will I need to wright my own code to be able to use more than one board?

clintp
 
Posts: 7
Joined: Mon Jul 24, 2017 4:23 pm

Re: Multiple MAX31865

by adafruit_support_bill on Fri Jul 28, 2017 12:15 pm

please post the exact text of the error

adafruit_support_bill
 
Posts: 73190
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple MAX31865

by clintp on Fri Jul 28, 2017 12:21 pm

Sorry I and kind of new to all of this, you are referring to the text from the error messages box correct? If so this is what I am getting.

Code: Select all | TOGGLE FULL SIZE
multipal_sensors_rtd:31: error: 'class Adafruit_MAX31865' has no member named 'temperature1'

   Serial.print("Temperature1 = "); Serial.println(max_1.temperature1(100, RREF));

                                                         ^

multipal_sensors_rtd:32: error: 'class Adafruit_MAX31865' has no member named 'temperature2'

     Serial.print("Temperature2 = "); Serial.println(max_2.temperature2(100, RREF));

                                                           ^

multipal_sensors_rtd:35: error: 'class Adafruit_MAX31865' has no member named 'readFault1'

   uint8_t fault1 = max_1.readFault1();

                          ^

multipal_sensors_rtd:36: error: 'class Adafruit_MAX31865' has no member named 'readFault2'

   uint8_t fault2 = max_2.readFault2();

                          ^

exit status 1
'class Adafruit_MAX31865' has no member named 'temperature1'


clintp
 
Posts: 7
Joined: Mon Jul 24, 2017 4:23 pm

Re: Multiple MAX31865

by adafruit_support_bill on Fri Jul 28, 2017 12:44 pm

You are trying to call a function that does not exist. Adafruit_MAX31865 does not have a member function named 'temperature1' or 'temperature2'. But it does have a member function named 'temperature'. That is what you should be using.

adafruit_support_bill
 
Posts: 73190
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple MAX31865

by clintp on Fri Jul 28, 2017 12:52 pm

That fixed it. Thank you for all the help.

clintp
 
Posts: 7
Joined: Mon Jul 24, 2017 4:23 pm

Re: Multiple MAX31865

by kkralicek on Mon Dec 31, 2018 8:21 am

Hello CLINTP,

Can you please post your final code for the MAX31865's that was working for you? I am a newby as well and am doing a board with 5 max31865's on it. So your final code would help me greatly.

TIA!!!

kkralicek
 
Posts: 4
Joined: Mon Dec 31, 2018 8:19 am

Re: Multiple MAX31865

by ilteo85 on Sat Apr 06, 2019 2:42 am

Hi everybody
i need to connect two MAX31865 to..
can you please post the code and the wiring to??
I m new and i rally don't know how to do it :(

thank you for all your help

ilteo85
 
Posts: 1
Joined: Sat Apr 06, 2019 2:34 am

Please be positive and constructive with your questions and comments.