Adafruit MAX31855 [Ported]

You can use a multiplexer - here’s how I did it:

ADG609BRZ is a 4 channel analog multiplexer (PDF).

Photon offers me enogh free pins for more than 2 probes. I have checked out that also the Pins on the “A-side” works fine. So I suppose that it could be also handled by a modification of the class. But for this I am not experienced enough in coding :frowning:

Well, if you want to use multiple MAX31855 chips each connected to a probe, you could use the CS (chip select) to select which one you want to read from. Looks like you’d define two thermocouples, something like:

> // Define the thermocouple
> Adafruit_MAX31855 Thermocouple_A(thermoCLK, CS_PIN_1, thermoDO);
> // Define the thermocouple
> Adafruit_MAX31855 Thermocouple_B(thermoCLK, CS_PIN_2, thermoDO); 

then wire them up so they connect to the shared the CLK and MISO pins, but connect to different CS pins (CS_PIN_1, CS_PIN_2).

Then, use something like:

tempA = Thermocouple_A.readCelsius();
tempB = Thermocouple_B.readCelsius();

It’s been a while since I worked on this code, but I think I’ve got that right.

Or, if you’re thinking of just going crazy and hooking up max31855 chips willy-nilly, that should be fine, too. I think the library uses bit banging, not hardware SPI (see - uint32_t Adafruit_MAX31855::spiread32(void)), so just define multiple instances as above with the three connecting pins (CLK, CS, MISO) defined as you like them.

This was the right approach!
Here is my modifies code:

/*************************************************** 
  This is an example for the Adafruit Thermocouple Sensor w/MAX31855K

  Designed specifically to work with the Adafruit Thermocouple Sensor
  ----> https://www.adafruit.com/products/269

  These displays use SPI to communicate, 3 pins are required to  
  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 "math.h"
#include "Adafruit_MAX31855.h"

int thermoCLK = D0;
int thermoCS = D1;
int thermoDO = D2;

int thermoCLK_1 = A2;
int thermoCS_1 = A1;
int thermoDO_1 = A0;


Adafruit_MAX31855 thermocouple_0(thermoCLK, thermoCS, thermoDO);
Adafruit_MAX31855 thermocouple_1(thermoCLK_1, thermoCS_1, thermoDO_1);

  
void setup() {
  // open serial terminal and press ENTER to start
  Serial.begin(9600);
  while(!Serial.available()) Particle.process();
  
  Serial.println("MAX31855 test");
  // wait for MAX chip to stabilize
  delay(500);
}

void loop() {
  // basic readout test, just print the current temp
  
 double temp0 = thermocouple_0.readCelsius();
 double temp1 = thermocouple_1.readCelsius();
 
  double int_temp0 = thermocouple_0.readInternal();
  double int_temp1 = thermocouple_1.readInternal();

 //double c = thermocouple_0.readCelsius();
  
 //  Serial.print("Internal Temp = ");
 //  Serial.println(thermocouple.readInternal());
   Serial.print("Internal Temp 0= ");
     Serial.println(int_temp0);
   
 Serial.print("Internal Temp 1= ");
     Serial.println(int_temp1);
  
   if (isnan(temp0)) {
     Serial.println("Something wrong with thermocouple 0!");
   } else {
     Serial.print("C 0= "); 
     Serial.println(temp0);
   }
     
     if (isnan(temp1)) {
     Serial.println("Something wrong with thermocouple 1!");
   } else { 
      Serial.print("C 1= "); 
     Serial.println(temp1);
   }
   //Serial.print("F = ");
   //Serial.println(thermocouple.readFarenheit());
 
   delay(1000);
}

The internal temeprature is read proper and very exactly.
I was not able to run the MAX31855 with the Maverick thermo probe. Tomorrow my new probes will arrive and I hope that on the weekend I can fire up my smoker :wink:

Can you post the relevant code how to work with the multiplexer and an explanation/pic how to wire all this on a breadboard would be helpfull for a noob like me. Thank you in advance!

Can somebody help me figure this out? I’ve modified the code to publish to the cloud instead of to a serial monitor. I took the code that @MST67 posted in May, removed the lines of code which allowed a second thermocouple to work, and added code for publishing the temperature. It keeps publishing “Something wrong with thermocouple!” which means the temperature isn’t reading from the MAX31855. It does publish the internal temperature as being -127, which I’m not sure is correct.

Any help would be much appreciated.

> // This #include statement was automatically added by the Particle IDE.
> #include "Adafruit_MAX31855/Adafruit_MAX31855.h"


> #include "math.h"


> int thermoCLK = D2;
> int thermoCS = D3;
> int thermoDO = D4;


> Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);



> void setup() {
>     while(!Serial);
>     Serial.begin(9600);

>   // wait for MAX chip to stabilize
>     delay(500);
> }

> void loop() {
>   // basic readout test, just print the current temp

>     double temp = thermocouple.readCelsius();

>     double int_temp = thermocouple.readInternal();

>  //double c = thermocouple_0.readCelsius();

>  //  Serial.print("Internal Temp = ");
>  //  Serial.println(thermocouple.readInternal());
>     //Serial.print("Internal Temp 0= ");
>     //Serial.println(int_temp0);

>     //Serial.print("Internal Temp 1= ");
>     //Serial.println(int_temp1);

>     Particle.publish("internaltemperature", String(int_temp), 1, PRIVATE);

>     if (isnan(temp)) {
>      //Serial.println("Something wrong with thermocouple 0!");
>     Particle.publish("thermocouple0", "Something wrong with thermocouple!", 1, PRIVATE);
>     }
>     else {
>      //Serial.print("C 0= "); 
>      //Serial.println(temp0);
>      Particle.publish("thermocouple0", String(temp), 1, PRIVATE);
>    }
>    //Serial.print("F = ");
>    //Serial.println(thermocouple.readFarenheit());

>    delay(2000);
> }

@tkmonkeyboy does the original example work over Serial?

I don’t know if this is what you meant, but we moved the pins to A3-A5 (default serial pins, I guess) from D2-D4, and it worked! Thanks!

@tkmonkeyboy, that’s because you are using software SPI instead of the hardware SPI. Depending on the library you are using, either can be specified. Software SPI is great when you want different pins and speed is not an issue. :wink: