Basic thermal couple circuit.
Basic thermal couple circuit uses heat on junction of
2 different metals produces a small voltage.

Simple 3-Wire MAX6675 Thermocouple ADC Arduino Interface

by Lewis Loflin

  
  

Warning: the temperatures used in this project can cause burns - be cautious.

More:

March 10, 2015

WiringPi for Raspberry Pi and MAX6675 thermal-couple sensor
WiringPi Blink an LED Demo

YouTube Videos:
Using Geany Text editor https://youtu.be/yMSRxplChBw
Blink Demo https://youtu.be/eHuGpL7mNWQ
MAX6675 Raspberry Pi Demo https://youtu.be/mpXW4QsejxE

In this project we will interface a MAX6675 Cold-Junction-Compensated K-Thermocouple- to-Digital Converter to an Arduino micro-controller. A Type K thermal couple is inexpensive and fairly accurate. Here we have a temperature range of 0 deg. C to 1024 deg. C.

At that temperature range one can measure molten lead or zinc, flue gases in a woodstove pipe, etc. This could measure cooking oil in a deep fryer or the temperature in an oven as we bake a cake.

This is far above what we could with solid state sensors such as a TMP37 or thermistors.

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.

The MAX6675 is available in a small, 8-pin SO (surface mount) package.

Also see Build a Thermocouple Voltage Amplifier

Simple 3-wire SPI interface between MAX6675 and Arduino.
Simple 3-wire SPI interface between MAX6675 and Arduino.

Arduino Code

Above is the 3-wire connection between the MAX6675 Cold-Junction-Compensated K-Thermocouple- to-Digital Converter and Arduino. This is a read only device with a 12-bit output (16 total bits) with bit 15 (MSB) output first.

Bit 15 is a dummy sign bit and is discarded. Bits 14-3 are the actual temperature reading, bit 2 is normally 0 but if the sensor is not attached is a 1. Useful for detecting if sensor is attached. Bits 0 and 1 are discarded.

There are several "libraries" on the web for Arduino to read the MAX6675 but to me are a mess - I wrote my own more portable code anyone can use. The code works as follows in subroutine spiRead():

We declare variable "value" as an integer and set to zero. An integer variable in Arduino is 16-bits.

CS is taken LOW for 2 mSec. then HIGH to start the conversion process. We delay 200 mSec. for the process to complete.

The CS is taken LOW again to read the data. One CLK cycle from LOW to HIGH to LOW discards bit 15.

Next we use a "for" loop to retrieve the next 15 bits (14-0) that are stored in variable "value".

Next we test bit 2 to see if the sensor is connected. A 1 means no sensor and a value of -1 is returned to the main program.

If bit 2 is 0 everything is OK, "value" is shifted right three places and the Centigrade integer value is returned to the main program.

Back in "loop" if a -1 is returned to variable v a message "No sensor" is generated. Otherwise v is multiplied by 0.25 to get the temperature in Celsius which is converted to Fahrenheit then displayed on the serial monitor or on a LCD display.

Arduino Code


#define CLK 9
#define DBIT 10 // so
#define CS 13

#include <SoftwareSerial.h>

int v = 0;
float Ctemp, Ftemp;

void setup()   {
  Serial.begin(9600);
  pinMode(CLK, OUTPUT);
  pinMode(DBIT, INPUT);
  pinMode(CS, OUTPUT);
  digitalWrite(CS, HIGH);
  digitalWrite(CLK, LOW);
}

void loop()   {
  v = spiRead();
  if (v == -1)   {
    Serial.print("No sensor \n");
  }
  else   {
    Ctemp =  v * 0.25;
    Ftemp = (Ctemp * 9 / 5) + 32;
    Serial.println(Ftemp);
   // Serial.print("\n");
  }
  delay(100);
}

int spiRead()   {
  int value = 0;
  digitalWrite(CS,LOW);
  delay(2);
  digitalWrite(CS,HIGH);
  delay(220);

  /* Read the chip and return the raw temperature value */
  /* Bring CS pin low to allow us to read the data from
   the conversion process */

  digitalWrite(CS,LOW);
  /* Cycle the clock for dummy bit 15 */
  digitalWrite(CLK,HIGH);
  delay(1);
  digitalWrite(CLK,LOW);

  /*
   Read bits 14-3 from MAX6675 for the Temp. Loop for each bit reading
   the value and storing the final value in 'temp'
   */

  for (int i=14; i>=0; i--) {
    digitalWrite(CLK,HIGH);
    value += digitalRead(DBIT) << i;
    digitalWrite(CLK,LOW);
  }
  // check bit D2 if HIGH no sensor
  if ((value & 0x04) == 0x04) return -1;

  // shift right three places
  return value >> 3;
}
MAX6675 Thermal Couple amp with Type K sensor.
MAX6675 Thermal Couple amp
with Type K sensor.



Optical Isolation of H-Bridge Motor Controls YouTube
Optical Isolation of H-Bridge Motor Controls

Opto-Couplers Theory and Circuits YouTube
Opto-Isolated Transistor Drivers for Micro-Controllers

All NPN Transistor H-Bridge Motor Control YouTube
All NPN Transistor H-Bridge Motor Control

Pulse-Width Modulation Tutorial YouTube
Pulse-Width Modulation Tutorial

PIC12F683 Microcontroller and Circuits YouTube
PIC12F683 Microcontroller and Circuits

 


donate