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;
}