# Running multiple MAX31856 boards

**URL:** <https://community.particle.io/t/running-multiple-max31856-boards/50481>\
**Category:** Firmware\
**Created:** [June 18, 2019, 2:43am UTC](https://community.particle.io/t/running-multiple-max31856-boards/50481 "2019-06-18T02:43:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![grahamb321](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@grahamb321](https://community.particle.io/u/grahamb321)\
**Post date:** [June 18, 2019, 2:43am UTC](https://community.particle.io/t/running-multiple-max31856-boards/50481/1 "2019-06-18T02:43:09Z")

</div>

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

```auto
#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;
}

```

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [June 18, 2019, 3:47am UTC](https://community.particle.io/t/running-multiple-max31856-boards/50481/2 "2019-06-18T03:47:37Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![grahamb321](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@grahamb321](https://community.particle.io/u/grahamb321)\
**Post date:** [June 19, 2019, 2:39am UTC](https://community.particle.io/t/running-multiple-max31856-boards/50481/3 "2019-06-19T02:39:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![grahamb321](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@grahamb321](https://community.particle.io/u/grahamb321)\
**Post date:** [June 19, 2019, 3:37am UTC](https://community.particle.io/t/running-multiple-max31856-boards/50481/4 "2019-06-19T03:37:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [June 19, 2019, 10:12am UTC](https://community.particle.io/t/running-multiple-max31856-boards/50481/5 "2019-06-19T10:12:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![markwkiehl](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/markwkiehl/32/23561_2.png) [@markwkiehl](https://community.particle.io/u/markwkiehl)\
**Post date:** [February 18, 2020, 10:06am UTC](https://community.particle.io/t/running-multiple-max31856-boards/50481/6 "2020-02-18T10:06:33Z")

</div>

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](http://www.savvysolutions.info/savvymicrocontrollersolutions/particle.php?topic=particle-thermocouple)
