Running multiple MAX31856 boards

I’m trying to read multiple MAX31856 boards. I can read one just fine, but can’t seem to get the second one to read. Here’s part of my code it’s failing setting/reading the thermocouple type.

I’m using software SPI, I can’t get hardware SPI to work even with only 1 board.

I get therm1 just fine, but therm2 in the switch returns Unknown

They both are sharing DI,DO,CLK and therm1 is on A3 and therm2 is on A4

#include <Adafruit_MAX31856.h>

// Use software SPI: CS, DI, DO, CLK

Adafruit_MAX31856 maxthermo = Adafruit_MAX31856(14, 11, 12, 13);
Adafruit_MAX31856 maxthermo2 = Adafruit_MAX31856(15, 11, 12, 13);
// use hardware SPI, just pass in the CS pin
//Adafruit_MAX31856 maxthermo = Adafruit_MAX31856(14);
String therm1 = "";
String therm2 = "";
String storetemp1 = "";
float read1 = 0;
float read2 = 0;
float read3 = 0;
float read4 = 0;
float read5 = 0;
int count = 0;

void setup() {
  Serial.begin(115200);
  
  maxthermo.begin();
  maxthermo2.begin();
  
  maxthermo.setThermocoupleType(MAX31856_TCTYPE_K);
  maxthermo2.setThermocoupleType(MAX31856_TCTYPE_K);


  switch (maxthermo.getThermocoupleType() ) {
    case MAX31856_TCTYPE_B: Particle.publish("B Type", PUBLIC); break;
    case MAX31856_TCTYPE_E: Particle.publish("E Type", PUBLIC); break;
    case MAX31856_TCTYPE_J: Particle.publish("J Type", PUBLIC); break;
    case MAX31856_TCTYPE_K: Particle.publish("Therm1: K Type", PUBLIC); break;
    case MAX31856_TCTYPE_N: Particle.publish("N Type", PUBLIC); break;
    case MAX31856_TCTYPE_R: Particle.publish("R Type", PUBLIC); break;
    case MAX31856_TCTYPE_S: Particle.publish("S Type", PUBLIC); break;
    case MAX31856_TCTYPE_T: Particle.publish("T Type", PUBLIC); break;
    case MAX31856_VMODE_G8: Particle.publish("Voltage x8 Gain mode", PUBLIC); break;
    case MAX31856_VMODE_G32: Particle.publish("Voltage x8 Gain mode", PUBLIC); break;
    default: Particle.publish("Therm1: Unknown1234", PUBLIC); break;
  }
  switch (maxthermo2.getThermocoupleType() ) {
    case MAX31856_TCTYPE_B: Particle.publish("B Type", PUBLIC); break;
    case MAX31856_TCTYPE_E: Particle.publish("E Type", PUBLIC); break;
    case MAX31856_TCTYPE_J: Particle.publish("J Type", PUBLIC); break;
    case MAX31856_TCTYPE_K: Particle.publish("Therm2: K Type", PUBLIC); break;
    case MAX31856_TCTYPE_N: Particle.publish("N Type", PUBLIC); break;
    case MAX31856_TCTYPE_R: Particle.publish("R Type", PUBLIC); break;
    case MAX31856_TCTYPE_S: Particle.publish("S Type", PUBLIC); break;
    case MAX31856_TCTYPE_T: Particle.publish("T Type", PUBLIC); break;
    case MAX31856_VMODE_G8: Particle.publish("Voltage x8 Gain mode", PUBLIC); break;
    case MAX31856_VMODE_G32: Particle.publish("Voltage x8 Gain mode", PUBLIC); break;
    default: Particle.publish("Therm2: Unknown1234", PUBLIC); break;
  }
    
    Particle.variable("therm1",therm1);
    Particle.variable("therm2",therm2);
    Particle.variable("storetemp1",storetemp1);
    read1 = 0;
    read2 = 0;
    read3 = 0;
    read4 = 0;
    read5 = 0;
    count = 0;
}

Are you using a Particle board? Which?
Here in the Particle community we prefer using the pin labels rather than anonymous pin numbers.

When you tried HW SPI which code did you try?

I’m using the Adafruit MAX31856 daughter board along with a Particle Boron.

When I tried hardware SPI, I just commented out the first maxthermo lines and uncommented the one under hardware SPI. I just got nan readings from what I remember.

I can get one to work just fine, if I’m reading the code right doing 2 boards, I would wire the DI/DO/CLK pins from both boards in parallel and simply use 2 different pins for the CS.

Ok, I was actually able to solve this. I got Hardware SPI to work and got 2 boards reading.

Can you tell us what you did to solve the issue?
It may help others to solve similar issues for fellow members :wink:

Follow the link to see sample code for the MAX31856 that works on the Argon / Boron. Add the library using the name “Adafruit_MAX31856_library”.

http://www.savvysolutions.info/savvymicrocontrollersolutions/particle.php?topic=particle-thermocouple