MAX31856

Hello all,

I am a complete beginner to Arduino and I could use some assistance. I am working on a project with cryogenic temperatures (down to -320F) and I want to use Arduino to read data from five type T thermocouples by way of 5 MAX31856 thermocouple amplifiers. I have an Arduino Uno and an Arduino Mega at my disposal.

  1. Is it possible to connect all five amplifiers to one of or both of my Arduinos? If possible, I have two USB ports on my computer… will this be sufficient in terms of power?

  2. What are the best options to house my amplifiers? I need something a little more reliable than a breadboard.

I have already downloaded the SPI and MAX31856 libraries to my IDE, I am just waiting on my amplifiers to come in and I can get started testing.

Any help is appreciated. Thanks in advance!

babyshark:

  1. Is it possible to connect all five amplifiers to one of or both of my Arduinos?

It should be. These use a SPI communication interface. SPI is a bus. That means you can connect the SDI, SDO, and SCK pins from all the MAX31856 to the same 3 pins on your Mega. You only need to use a separate pin for each of the CS pins. That will determine which of the MAX31856 are enabled so that you are only communicating with one at a time.

We could probably give more information on how to do this code-wise if you provide a link to the MAX31856 library you're using.

babyshark:
If possible, I have two USB ports on my computer.. will this be sufficient in terms of power?

I think it will be fine. These amplifiers probably don't require a lot of current.

babyshark:
2. What are the best options to house my amplifiers? I need something a little more reliable than a breadboard.

Since you're using a Mega, the best solution is probably to get a proto shield and then solder the amplifiers to the shield. You can get proto shields that are specifically made for the Mega, which connect all the pins and give a bit more room to work with. You can also get Uno-style proto shields that only connect to the pins that are available on the Uno/Leonardo/Zero style boards. I prefer the proto shields that are completely made of plated through holes, rather than the ones with some random surface mount footprints that only waste space if you don't happen to need them:


Don't get the style of proto shield with the breadboard stuck to it.

You can buy enclosures in a wide variety of sizes on eBay, Aliexpress, or the usual electronic supply sites.

Very useful information. Much appreciated.. here is the MAX31856 library I am using GitHub - adafruit/Adafruit_MAX31856: Arduino Library for Adafruit MAX31856

I’m glad I was able to be of assistance.

In the example sketch for the library you can see these lines:

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

That’s where you create a Adafruit_MAX31856 object. You can create as many of those as you like. They just each need to have a different CS pin:

Adafruit_MAX31856 thermocouple1 = Adafruit_MAX31856(8, 11, 12, 13);
Adafruit_MAX31856 thermocouple2 = Adafruit_MAX31856(9, 11, 12, 13);
Adafruit_MAX31856 thermocouple3 = Adafruit_MAX31856(10, 11, 12, 13);

You can do the same with the hardware SPI if you prefer.

A little more complicated at first, but it may actually make your code more simple in the end is to put all the Adafruit_MAX31856 objects in an array. This allows you to use for loops to do operations on all the thermocouples with only a few lines of code. Here’s some code that will give you an idea of how that could work:

#include <Adafruit_MAX31856.h>

// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31856 thermocouples[] = {Adafruit_MAX31856(8, 11, 12, 13),
                                     Adafruit_MAX31856(9, 11, 12, 13),
                                     Adafruit_MAX31856(10, 11, 12, 13)
                                    };


void setup() {
  for (byte thermocoupleCounter = 0; thermocoupleCounter < (sizeof(thermocouples) / sizeof(thermocouples[0])); thermocoupleCounter++) {
    thermocouples[thermocoupleCounter].begin();
    thermocouples[thermocoupleCounter].setThermocoupleType(MAX31856_TCTYPE_K);
  }
}

Hopefully I got the object array code right this time around. I did something a bit less than ideal last time I was helping someone do something of the sort and someone here pointed it out but I’m a bit hazy on the exact details and can’t find that thread.

This code:

sizeof(thermocouples) / sizeof(thermocouples[0])

Automatically determines how many thermocouples you have. Doing this allows you to add or remove thermocouples by only changing the array, and then the code adapts to it automatically.

Some years ago, I did a project where I used the Adafruit MAX31855 library and a W5100 Ethernet controller. I found that I was not able to share the hardware SPI between these devices so I had to use hardware SPI for the W5100 and software SPI for the MAX31855. The SPI bus is supposed to work with different devices but my understanding is that the SPI implementation has some variation between different devices and this can cause them to be incompatible. I suspect that’s why Adafruit uses the otherwise inferior software SPI as a default in the examples for their MAX31855 and MAX31856 libraries. It’s also possible that I made some mistake, as I was still pretty green to Arduino at that time. You should have no problem sharing a single SPI bus between multiple of the same device though.