How to set Arduino to stop at specific temperature using MAX31855K

I want my Arduino to stop working when the temperature of the thermocouple reachers <=1000 degree Celsius. How do I manage to do that? Here’s the code I got after installing Adafruit_MAX31888K library.

Thanks in advance :slight_smile:

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() {
Serial.begin(9600);

while (!Serial) delay(1); // wait for Serial on Leonardo/Zero, etc

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);
}

Is that less than 1000 degree Celcius?

while (temperature <= 1000);

It will stay in the loop (ie not working) as long as the condition is true one time.

Perehama:
Is that less than 1000 degree Celcius?

while (temperature <= 1000);

It will stay in the loop (ie not working) as long as the condition is true one time.

That’s less than or equal to. So, I want the arduino to stop working (say for the lack of better example, turn off the LED once the temperature is >1000 degree Celsius). Also, I didnt follow you when you said (ie not working). Sorry, English is not my first language.

"Stop working" is a phrase you might use when the Arduino bursts into flame and melts. Usually that happens at a temperature much less than 1000C.

The thing is, you never stop the processor. It has a fixed clock speed. So while you can't stop it, the infinite loop proposed above will make it stop responding to external inputs.

So a better way of asking the question might be to say you want it to do something when it measures 1000C. Then you would give more detail on what the something is and describe what happens if the temperature drops or maybe it was just a microsecond above 1000 and drops down again.

Thank for the reply. Let’s say when MAX31855K reads a temperature more than 600 degree Celsius then the fan turns on and when the temperature is more than 1000 degree celsius than the fan turns off. I realised last night that working with temperature range (600-1000 degree celsius) is better than just specific temperature (<=1000 Degree celsius) as the fan would still run in room temperature, 24 degree C is less than 1000 degree (TRUE) and that’s not what I want.

990614: That's less than or equal to. So, I want the arduino to stop working (say for the lack of better example, turn off the LED once the temperature is >1000 degree Celsius). Also, I didnt follow you when you said (ie not working). Sorry, English is not my first language.

I think for anyone to tell you how to do what you want to do, you need to clarify a little more what exactly you want to do. "stop working" was your words in your original post (OP). There are sections of this forum dedicated to languages other than English if one of those languages is more suited to your first. I will try to help you with the following multiple choice answer: 1) I want to monitor temperature, turn on and off fans and do micro controller things until the temperature reads greater than 1000 degree Celsius. Once the temperature is above this, I want the controller to do nothing forever more until I cycle power. 2) I want to turn on a fan when the temperature reads 600 Celsius and turn off the fan at 1000 Celsius. Should the temperature fall below 1000, I want the fan to turn back on, unless the temperature falls below 600, where I would turn off the fan again. 3) ___________________________________________________________________ (i e fill in the blank.)