Max31855 Library

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
project_zero
 
Posts: 86
Joined: Tue Sep 10, 2013 11:22 pm

Max31855 Library

Post by project_zero »

Hi guys,

I'm trying to understand how to use the max31855 thermocouple breakout board library. In the tutorial, it tells us to define the pins for data out, clock, and data in. But when I look inside the library, I see to include an SPI.h library. Is this bitbanged SPI, or do I actually need to use SPI pins to make the board work?

Thank you!

User avatar
adafruit_support_bill
 
Posts: 88090
Joined: Sat Feb 07, 2009 10:11 am

Re: Max31855 Library

Post by adafruit_support_bill »

It is 'bit-banged' SPI. You can use any pins with it.

User avatar
project_zero
 
Posts: 86
Joined: Tue Sep 10, 2013 11:22 pm

Re: Max31855 Library

Post by project_zero »

Hi Bill,

According to the library it works with either Hardware SPI or bitbanged software SPI. For my project it would be useful to use the ICSP pins, so I'm trying to use the Hardware SPI. This text is within the example code that comes with the library:

Code: Select all

// Default connection is using software SPI, but comment and uncomment one of
// the two examples below to switch between software SPI and hardware SPI:
However, though it works with software spi, I haven't gotten it to work with Hardware. I've double checked my wiring several times.

GND --> GND
Vin --> 5V
DO --> MISO ICSP Pin
CS --> Pin 7
CLK --> CLK ICSP Pin

And here is my code. It is the example code in its entirety, simply commented/uncommented to use hardware instead of software. I also added thermocouple.begin() to make sure SPI was being started. I do not get the message "Something wrong with thermocouple". I simply get that the internal temp is 0, C=0, and F=32. Those values do not change.

I know my thermocouple, board, and Arduino are working properly because the setup works with software spi. Do you have any idea why it isn't with hardware?

Code: Select all

/*************************************************** 
  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   3
#define MAXCS   4
#define MAXCLK  5

// 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(7);

void setup() {
  while (!Serial); // wait for Serial on Leonardo/Zero, etc
  
  Serial.begin(9600);
  thermocouple.begin();
  Serial.println("MAX31855 test");
  // wait for MAX chip to stabilize
  delay(500);
}

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.readFarenheit());
 
   delay(1000);
}

User avatar
adafruit_support_bill
 
Posts: 88090
Joined: Sat Feb 07, 2009 10:11 am

Re: Max31855 Library

Post by adafruit_support_bill »

Hmmm Looks like hardware SPI support was added later. But the library code looks pretty straightforward. What processor are you using this with?

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”