In this example we take a look at the MAX6675 Cold-Junction-Compensated K-Thermocouple-to-Digital Converter
The MAX6675 performs cold-junction compensation and digitizes the signal from a type-K thermocouple. The data is output in a 12-bit resolution, SPI™-compatible, read-only format.
This converter resolves temperatures to 0.25°C, allows readings as high as +1024°C, and exhibits thermocouple accuracy of 8 LSBs for temperatures ranging from 0°C to +700°C.
Key Features
Cold-Junction Compensation
Simple SPI-Compatible Serial Interface
12-Bit, 0.25°C Resolution
Open Thermocouple Detection
Usually you use these in a breakout/module form and can also purchase a kit which includes a thermocouple. Here is a picture of the module that I purchased
Connection
Here are the connections , sometimes these are named differently on the modules, in particular the CS connection
Vcc connected to 3.3v
Gnd connected to Gnd
SO connected to Pin 19 (MISO)
SS/CS connected to Pin 23 (MOSI)
CSK connected to Pin 5 (SS)
Code
You will need the MAX6675 library – https://github.com/adafruit/MAX6675-library – I needed to edit the library for it to compile, this version works – MAX6675_library
[cpp]
#include “max6675.h”
int thermoDO = 19;
int thermoCS = 23;
int thermoCLK = 5;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
void setup()
{
Serial.begin(9600);
Serial.println(“MAX6675 test”);
delay(500);
}
void loop()
{
// basic readout test, just print the current temp
Serial.print(“C = “);
Serial.println(thermocouple.readCelsius());
Serial.print(“F = “);
Serial.println(thermocouple.readFahrenheit());
delay(1000);
}
[/cpp]
Results
Open the serial monitor window and you should see something like this
C = 26.50
F = 79.70
C = 26.75
F = 80.15
C = 26.25
F = 79.25
C = 26.50
F = 79.70
C = 27.00
F = 80.60
Links