max6675 library

Hey all,

I am currently working on a progam utilizing the max6675 library found here. The problem that I am having is that the functions that return temperature (both Celsius and Fahrenheit) do not work without a delay() command after them.

Is there any way around this? With the my program constantly executing a delay like this there is a noticeable lag in the other inputs ( such as switches) because if they are pressed during the delay they are ignored.

Thanks in advance Mike

You are doing something wrong. Just load the simple example found here: and see that it doesn't have delays after every time it reads the chip.

If you showed us your code (all of it) then maybe I could have told you exactly what it was that you did wrong.

Hey, thanks for the reply. I know there isn't a delay after each function call, but there is a delay before each function is called again. I ran the code you provided without a delay and the function keeps returning the same value no matter what I do to the thermocouple (ie put it in ice water). I also tried with a delay(100) function call at the end which still didn't work, and with a delay(250) call which did work but there was still noticeable lag in my code. I'll post my code below:

#include  //LCD library
#include  //MAX6675 K type thermocouple amp interface library

const int thermo_so_pin  = A1; //naming I/O pin termocouple amp so pin
const int thermo_cs_pin  = A2; //naming I/O pin termocouple amp cs pin
const int thermo_sck_pin = A3; //naming I/O pin termocouple amp sck pin

LiquidCrystal lcd(7, 8, 9, 10, 11, 12); // instance lcd of class LiquidCrystal
MAX6675 thermocouple(thermo_sck_pin, thermo_cs_pin, thermo_so_pin); //instance thermocouple of class MAX6675

void loop ()

int temp;

temp = thermocouple.readFahrenheit();


again, this code works, but it does not work when i remove the "delay(250); function call

Well, you probably have something useful to do during that delay. You obviously don't need to be hammering the poor 6675 thousands of times per second.

void myDelay(unsigned long ms) {
  //delay for ms milliseconds, while checking the inputs and processing them
  unsigned long start = millis();
  while(millis() - start < ms) {
    if(checkSwitches()) return; //leave the delay early if checkSwitches returns true

Herein i confirm that even the simplest code reading max6675 doesn't work for me without proper delay between readings. I found delay(200) is minimum to make max6675 work corectly. Apparently max needs some delay between readings to read TC and stabilize reading.

const unsigned long measurementPeriod = 250;
unsigned long timer;

void setup() {
  timer  = millis();

void loop () {
  int temp;
  if (millis() - timer >= measurementPeriod) {
    timer += measurementPeriod;
    temp = thermocouple.readFahrenheit();

  // Do useful stuff here with no delay