MAX 31855 : I can't get one working and need help with Upload Error Message,

I have tried to get a MAX 31855 working without success.
I have tried using UNO, Mini Pro and MEGA 2560.
I have tried with the basic MAX 31855 module and a logic level converter as per “Henry’s Bench” with his code.
I have tried with Adafruit’s MAX 31855K module with the integral level converter and the Adafruit code and Adafruit MAX31855 library.
I might sound a bit desperate, I am.
With my last attempt I get a compile error while uploading, but then a “done Uploading” message.
The temperature results showing in the serial monitor are incorrect, showing negative dec C in my room and fluctuating wildly.
Please see the code below and the compile error message below that.

/***************************************************
  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 <SPI.h>
#include "Adafruit_MAX31855.h"

// Default connection is using software SPI, but comment and uncomment one of
// the two examples below to switch between software SPI and hardware SPI:

// Example creating a thermocouple instance with software SPI on any three
// digital IO pins.
#define MAXDO   4
#define MAXCS   5
#define MAXCLK  6

// initialize the Thermocouple
Adafruit_MAX31855 thermocouple(MAXCLK, MAXCS, MAXDO);

// Example creating a thermocouple instance with hardware SPI
// on a given CS pin.
//#define MAXCS   10
//Adafruit_MAX31855 thermocouple(MAXCS);

void setup() {
  Serial.begin(9600);

  while (!Serial) delay(1); // wait for Serial on Leonardo/Zero, etc

  Serial.println("MAX31855 test");
  // wait for MAX chip to stabilize
  delay(500);
  Serial.print("Initializing sensor...");
  if (!thermocouple.begin()) {
    Serial.println("ERROR.");
    while (1) delay(10);
  }
  Serial.println("DONE.");
}

void loop() {
  // basic readout test, just print the current temp
   Serial.print("Internal Temp = ");
   Serial.println(thermocouple.readInternal());

   double c = thermocouple.readCelsius();
   if (isnan(c)) {
     Serial.println("Something wrong with thermocouple!");
   } else {
     Serial.print("C = ");
     Serial.println(c);
   }
   //Serial.print("F = ");
   //Serial.println(thermocouple.readFahrenheit());

   delay(1000);
}
In file included from C:\Users\Windows PC\Documents\Arduino\serialthermocouple_Base\serialthermocouple_Base.ino:18:0:

C:\Users\Windows PC\Documents\Arduino\libraries\Adafruit_MAX31855_library/Adafruit_MAX31855.h:49:32: warning: passing NULL to non-pointer argument 1 of 'Adafruit_SPIDevice::Adafruit_SPIDevice(int8_t, uint32_t, BitOrder, uint8_t, SPIClass*)' [-Wconversion-null]

   Adafruit_SPIDevice spi_dev = NULL;

                                ^~~~

In file included from C:\Users\Windows PC\Documents\Arduino\libraries\Adafruit_MAX31855_library\Adafruit_MAX31855.cpp:36:0:

C:\Users\Windows PC\Documents\Arduino\libraries\Adafruit_MAX31855_library\Adafruit_MAX31855.h:49:32: warning: passing NULL to non-pointer argument 1 of 'Adafruit_SPIDevice::Adafruit_SPIDevice(int8_t, uint32_t, BitOrder, uint8_t, SPIClass*)' [-Wconversion-null]

   Adafruit_SPIDevice spi_dev = NULL;

                                ^~~~

Sketch uses 6574 bytes (21%) of program storage space. Maximum is 30720 bytes.
Global variables use 441 bytes (21%) of dynamic memory, leaving 1607 bytes for local variables. Maximum is 2048 bytes.

Ron47Walker:
Please see the code below and the compile error message below that.

You need to understand the difference between warnings and errors. A warning is the compiler telling you there is something in the code that could possibly cause a problem but doesn’t cause the compilation to fail. An error is a problem with the code that causes compilation to fail. In this case you have posted a warning, not an error.

You should always pay attention to warnings and fix them in your own code whenever possible. Unfortunately some library authors don’t hold themselves to such high standards so sometimes you do just need to ignore a warning from a library that you didn’t write. That can be quite annoying since you are always having to sort though a bunch of warnings in other people’s sloppy code to make sure your own code is of high quality. You may decide it’s worth editing the source of the library to fix the warning. If you do so, it’s a good idea to submit a pull request for the fix to the library’s repository to solve the problem upstream, otherwise the warnings will come back whenever you update to a new release of the library. This will also benefit all the other users of the library.


I just tried the code you posted with an Adafruit MAX31855K module and the latest version of the Adafruit MAX31855 library (1.2.0) and it works just fine for me, reasonable temperature and no fluctuations.

So my guess is that something is wrong with your hardware. Make sure your module is connected to the Arduino board correctly. Make sure the thermocouple is connected to the module correctly. Make sure you are using the correct type of thermocouple (type K). You might have problems if the module is connected to your Arduino board with long wires. Try it with short wires to see if that fixes the problem.

Try adding this line to the loop function of your sketch:

  Serial.print("Error code = ");
  Serial.println(thermocouple.readError());

If this is showing zero, then the MAX31855K is not reporting any errors. If it’s showing anything other than zero, then there’s a problem.

Thank you PERT,
The problem was the length of the breadboard jumperleads. The MAX31855 module comes with the pins soldered pointing up making it hard to insert into it a breadboard - bending the pins 90 deg solved that problem and eliminated the leads.
Working correctly now, thanks again.

You're welcome. I'm glad to hear it's working now. Enjoy!
Per