Adding Code?

I connected MAX31855 to Arduino UNO.

MAX31855 UNO
CLK . . . . . Digital 3
CS . . . . . . Digital 4
DO . . . . . . Digital 5
GND . . . . . GND

I downloaded:
Adafruit_MAX31855.h
and
Adafruit_MAX31855.cpp

I clicked on Sketch, Add File, and selected Adafruit_MAX31855.h
Then pressed The Checkmark (Verify File)
Error compiling for board Arduino/Genino Uno

I did the same for Adafruit_MAX31855.cpp, with no errors.
It stated Done compiling.

I pressed the right arrow (Upload)

I have a thermocouple connect to the MAX31855, but when I open Serial Monitor, there are no temp. readings. I even tried pressing enter after opening Serial Monitor.

Any suggestions?

Any suggestions?

Post your code, post your schematic.

I clicked on Sketch, Add File, and selected Adafruit_MAX31855.h

Where did you save the .cpp and .h files that you downloaded ?

Did you mean to add the .h file to the sketch or to include the library ?
What code is in the main IDE tab ?

This site gave me the idea:

Here’s where I downloaded the code:

I made a drawing in Fritzing.

  1. Where did you save the .cpp and .h files that you downloaded ?
  2. Did you mean to add the .h file to the sketch or to include the library ?
  3. What code is in the main IDE tab ?
  1. In the file I created on my desktop called libraries.

  2. Not sure how to do this. It must be missing.

  3. Another thing that I must be missing? I just added the code I downloaded.

Let's go back to basics

1 The program that you compile will be on the first tab of the IDE and there will be only one tab with a name

2 The program can use code in one or more libraries

3 There will be two files for each library, both with the same name, one with an extension of .h and the second an extension of .cpp

4 To use the library files you use the #include directive like this

#include <name_of_library.h>

near the top of your program

5 Both library files should be in a folder with the same name as the files in the libraries folder of where your sketches are saved

6 The easiest way to install a library that you do not have is using the Library Manager in the IDE. Look at Sketch/Include Library/Manage Libraries in the IDE and enter the library name, or part of it in the search box

NOTE : There are possible exceptions to some of the points above but they are unlikely to be important in your case

Somewhat a duplicate of the reply UKHeliBob posted while I was writing, but there's some additional information so I'll post it anyway:

It sounds like you don't know how to install libraries and don't understand the difference between a sketch and a library. Do this:

  • Sketch > Include Library > Manage Libraries...
  • Wait for download to finish.
  • In the "Filter your search..." box, type "Adafruit MAX31855 library".
  • Click on "Adafruit MAX31855 library by Adafruit".
  • Click "Install".
  • Wait for installation to finish.
  • Click "Close".
  • File > Examples > Adafruit MAX31855 library > serialthermocouple
  • Sketch > Upload
  • Wait for the serialthermocouple example sketch to upload.
  • Tools > Serial Monitor

You should now see the thermocouple readings in the Serial Monitor.

More information on installing Arduino libraries:

Thank you UKHeliBob and Pert,

This is my first project, so it's nice that you gave me some basics information.
I'll also read the link Pert provided, as I'd like to learn Arduino to expand my project once the basics are obtained.

I'm now getting readings to appear, but both the Internal Temp. 0.00 and C = 0.00.
I have tried two MAX31855 with two thermocouples, both show 0.00.
What can I change to get temperature readings and in Fahrenheit?

Hi,
What are your thermocouples?

What type thermocouple is your MAX31855 breakout setup for?

Can you post a picture of your project so we can see your component layout?

Thanks.. Tom.. :slight_smile:

I know that you posted a link to the code being used but please post a copy of it taken directly from your IDE

Here’s the thermocouple I’m using:
K Type Temperature Sensor 1M Cable 3x10x1000mm 0-600 Degree Thermocouple

Here’s the MAX31855:
MAX31855 MAX6675 SPI K Thermocouple Temperature Sensor Module Board For Arduino

Here’s the Arduino:
Geekcreit® Arduino Compatible UNO R3 ATmega16U2 AVR USB Development Main Board

Here are links to view the pieces:

Here’s a pic of my project and a zoomed in pic of the MAX31855


UKHeliBob:
I know that you posted a link to the code being used but please post a copy of it taken directly from your IDE

Doing what Pert said, here's the 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 <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(MAXCS);

void setup() {
 while (!Serial); // wait for Serial on Leonardo/Zero, etc
 
 Serial.begin(9600);
 
 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.readFarenheit();
  if (isnan(c)) {
    Serial.println("Something wrong with thermocouple!");
  } else {
    Serial.print("F = "); 
    Serial.println(c);
  }
  //Serial.print("F = ");
  //Serial.println(thermocouple.readFarenheit());

  delay(1000);
}

Hi,

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.


You will have to redo those solder joints, longer time for the iron to be on the joint, before adding solder.
Do not be scared of leaving the iron there too long, place the hot iron on the joint and count to three before adding solder, hold another second, then take the iron away.
What sort of solder are you using?

Thanks.. Tom.. :slight_smile:

TomGeorge:
You will have to redo those solder joints, longer time for the iron to be on the joint, before adding solder.
Do not be scared of leaving the iron there too long, place the hot iron on the joint and count to three before adding solder, hold another second, then take the iron away.
What sort of solder are you using?

Thanks.. Tom.. :slight_smile:

Tom, thank you. I was worried about holding it on too long, overheating the part. I will do as you said.
The solder I'm using is RadioShack Rosin Core with Oatey Lead-Free Tinning Flux.

Hi,
You shouldn't need the Tinning Flux, the Rosin Core should do the job.
The "trick" is to let the molten solder flow, it is a typical beginner reaction, but most parts can take quite a bit of heat and you will soon get the knack.

At my work we got one work experience guy who was having trouble with soldering to desolder an old throwout PCB, leave the components in and resolder them, the fact that solder had been on the surfaces helped, but he could safely see how much and how long he could apply the iron and the feel for feeding the solder in.

Check out some YouTube, and look at how flow solder and wave soldering is done in industry, pretty impressive stuff.

Tom... :slight_smile:

Doing what Pert said, here's the code:

And do you still get errors when you try and compile the code?

If so then copy and paste the errors you get. Paste it like you would code for the forum.

Grumpy_Mike:
And do you still get errors when you try and compile the code?

If so then copy and paste the errors you get. Paste it like you would code for the forum.

I'm not getting any errors on the code I posted, just no temp. readings.

Hi,
Your code;

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

Your circuit;
MAXD0 5
MAXCS 4
MAXCLK 3

Tom... :slight_smile:

TomGeorge:
Hi,
Your code;

// Example creating a thermocouple instance with software SPI on any three

// digital IO pins.
#define MAXDO 3
#define MAXCS 4
#define MAXCLK 5



Your circuit;
MAXD0 5
MAXCS 4
MAXCLK 3

Tom... :)

I switched them now I get:
MAX31855 test
Internal Temp = 30.06
Something wrong with thermocouple!
Internal Temp = 30.87
Something wrong with thermocouple!
Internal Temp = 31.37
Something wrong with thermocouple!
Internal Temp = 31.69
Something wrong with thermocouple!
Internal Temp = 31.94
Something wrong with thermocouple!
Internal Temp = 32.13
Something wrong with thermocouple!
Internal Temp = 32.31
Something wrong with thermocouple!

It looks like it's reading Celsius, and it looks like it's the thermocouple. Where is the Internal Temp coming from, as it keeps increasing over time?
Here's an updated circuit pic.

Where is the Internal Temp coming from,

From the internal thermistor, it is part of the A/D converter section of the processor. If the analogRead command would allow it, it comes from multiplexer settings above 7.

It looks like it's reading Celsius, and it looks like it's the thermocouple.

I doubt it. It will increase over the short term until the processor stabilises.

From what you said then the libiary is working and your hardware is not.

Either a mistake in wiring, or in the code you wrote, or your hardware is faulty.