Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

Multiple MAX31865 Boards to MCU Arduino Code
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Multiple MAX31865 Boards to MCU Arduino Code

by Feynman137 on Sun Oct 17, 2021 9:23 pm

Hello,

I have a couple questions about the max31865. The first is can the library that Adafruit created for MAX31865 be used on ESP32? The second is how does one configure the arduino code for the multiple connections? Just some basic guidance here would help me I am a little stuck. The example code is below:

Code: Select all | TOGGLE FULL SIZE
 interface
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries. 
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include <Adafruit_MAX31865.h>

// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31865 thermo = Adafruit_MAX31865(10, 11, 12, 13);
// use hardware SPI, just pass in the CS pin
//Adafruit_MAX31865 thermo = Adafruit_MAX31865(10);

// The value of the Rref resistor. Use 430.0 for PT100 and 4300.0 for PT1000
#define RREF      430.0
// The 'nominal' 0-degrees-C resistance of the sensor
// 100.0 for PT100, 1000.0 for PT1000
#define RNOMINAL  100.0

void setup() {
  Serial.begin(115200);
  Serial.println("Adafruit MAX31865 PT100 Sensor Test!");

  thermo.begin(MAX31865_3WIRE);  // set to 2WIRE or 4WIRE as necessary
}


void loop() {
  uint16_t rtd = thermo.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(thermo.temperature(RNOMINAL, RREF));

  // Check and print any faults
  uint8_t fault = thermo.readFault();
  if (fault) {
    Serial.print("Fault 0x"); Serial.println(fault, HEX);
    if (fault & MAX31865_FAULT_HIGHTHRESH) {
      Serial.println("RTD High Threshold");
    }
    if (fault & MAX31865_FAULT_LOWTHRESH) {
      Serial.println("RTD Low Threshold");
    }
    if (fault & MAX31865_FAULT_REFINLOW) {
      Serial.println("REFIN- > 0.85 x Bias");
    }
    if (fault & MAX31865_FAULT_REFINHIGH) {
      Serial.println("REFIN- < 0.85 x Bias - FORCE- open");
    }
    if (fault & MAX31865_FAULT_RTDINLOW) {
      Serial.println("RTDIN- < 0.85 x Bias - FORCE- open");
    }
    if (fault & MAX31865_FAULT_OVUV) {
      Serial.println("Under/Over voltage");
    }
    thermo.clearFault();
  }
  Serial.println();
  delay(1000);
}

Feynman137
 
Posts: 16
Joined: Sat Sep 14, 2019 8:31 pm

Re: Multiple MAX31865 Boards to MCU Arduino Code

by dastels on Mon Oct 18, 2021 8:35 am

Using SPI, you can use different CS pins for each one.

As for using it with the ESP32, I suspect it will work fine.

Dave

dastels
 
Posts: 7983
Joined: Tue Oct 20, 2015 3:22 pm

Re: Multiple MAX31865 Boards to MCU Arduino Code

by Feynman137 on Tue Oct 19, 2021 11:11 am

@dastels thanks for the reply. What confuses me is in the adafruit max31865 library there is an option to use the software SPI or the hardware SPI connection. I would like to use the hardware config, but there are 2 SPI buses on the ESP32 the V bus and the H bus. I am using the V bus but nowhere in the code is there an option to specify which bus you are using. One just specifies the CS pin and the hardware pins are defaulted I believe.

Do you know what I should do?

Feynman137
 
Posts: 16
Joined: Sat Sep 14, 2019 8:31 pm

Re: Multiple MAX31865 Boards to MCU Arduino Code

by dastels on Tue Oct 19, 2021 11:15 am

I'm afraid that's beyond my knowledge of the ESP32. I'll ask around.

Dave

dastels
 
Posts: 7983
Joined: Tue Oct 20, 2015 3:22 pm

Re: Multiple MAX31865 Boards to MCU Arduino Code

by adafruit_support_carter on Tue Oct 19, 2021 11:23 am

Which specific ESP32 based board are you using?

adafruit_support_carter
 
Posts: 21956
Joined: Tue Nov 29, 2016 2:45 pm

Re: Multiple MAX31865 Boards to MCU Arduino Code

by Feynman137 on Tue Oct 19, 2021 12:05 pm

@adafruit_support_carter, I am using ESP32-WROOM-32UE module on a custom PCB.

Feynman137
 
Posts: 16
Joined: Sat Sep 14, 2019 8:31 pm

Re: Multiple MAX31865 Boards to MCU Arduino Code

by adafruit_support_carter on Tue Oct 19, 2021 2:36 pm

The Arduino core for that board is what sets where the hardware SPI pins show up. The pinout diagram for the board should show the location of MOSI/MISO/SCLK, which are the hardware SPI pins. If you really need to know if it's HSPI or VSPI, you may need to look further under the hood.

adafruit_support_carter
 
Posts: 21956
Joined: Tue Nov 29, 2016 2:45 pm

Re: Multiple MAX31865 Boards to MCU Arduino Code

by Feynman137 on Tue Oct 19, 2021 3:06 pm

Are you talking about the fact that I use the Node32s board in the arduino IDE for my esp32? This is what is dictating the default SPI bus that the MAX31865 uses?

Feynman137
 
Posts: 16
Joined: Sat Sep 14, 2019 8:31 pm

Re: Multiple MAX31865 Boards to MCU Arduino Code

by adafruit_support_carter on Tue Oct 19, 2021 3:33 pm

Yes

adafruit_support_carter
 
Posts: 21956
Joined: Tue Nov 29, 2016 2:45 pm

Re: Multiple MAX31865 Boards to MCU Arduino Code

by Feynman137 on Tue Oct 19, 2021 10:59 pm

Looks like it works on the ESP32 I am just specifying each pin as below:

Code: Select all | TOGGLE FULL SIZE
// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31865 thermo = Adafruit_MAX31865(5,23,19,18);

Feynman137
 
Posts: 16
Joined: Sat Sep 14, 2019 8:31 pm

Re: Multiple MAX31865 Boards to MCU Arduino Code

by adafruit_support_carter on Tue Oct 19, 2021 11:06 pm

That will use software SPI.

If you want hardware SPI, you'll want to use the other constructor:
https://github.com/adafruit/Adafruit_MA ... 65.ino#L22

But also, if the current code is working OK for your use case, then maybe software SPI is OK.

adafruit_support_carter
 
Posts: 21956
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.