Hello all together,
right now I am unable to use a type K thermocouple module with an Arduino Mega. I'm really suffering from trying this for days!
My sensor module is the following: MAX6675/MAX31855 Thermoelement Typ K Temperatur Sensor Modul SPI Schnittstelle | eBay
I tried different example sketchs from MAX6675 libraries as well as examples from MAX31855 libraries - both should work as the module is labeled with both, is this assumption correct?!
What I've tried already: using different Arduinos (Nano, Uno, Mega), using another thermocouple module (I have two of them), connecting another thermocouple (I have two of them) and switching wires of the thermocouple (red should be minus afaik). Nothing helps me out.
Using an Adafruit thermocouple type K module works as a charm, but this particular module drives me crazy.
The following adafruit MAX31855 example code gives only:
Unable to start MAX31855. Waiting 3 seconds.
#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);
// Example creating a thermocouple instance with hardware SPI
// on SPI1 using specified CS pin.
//#define MAXCS 10
//Adafruit_MAX31855 thermocouple(MAXCS, SPI1);
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);
Serial.print("Initializing sensor...");
if (!thermocouple.begin()) {
Serial.println("ERROR.");
while (1) delay(10);
}
Serial.println("DONE.");
}
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.readFahrenheit());
delay(1000);
}
The following example code for an MAX6675 module only gives wrong temperatures, 5-10° but seems to respond on heating, but into wrong direction and only a few degrees. It also spits often an
ERROR!
// FILE: Demo_getRawData.ino
// AUTHOR: RobTillaart, (based upon FabioBrondo
// PURPOSE: thermocouple lib demo application
// URL: https://github.com/RobTillaart/MAX6675
#include "SPI.h"
#include "MAX6675.h"
#define MAXDO 7 // Defining the MISO pin
#define MAXCS 6 // Defining the CS pin
#define MAXCLK 5 // Defining the SCK pin
MAX6675 thermocouple;
void setup ()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.println();
delay(250);
thermocouple.begin(MAXCLK, MAXCS, MAXDO);
}
void loop ()
{
int status = thermocouple.read();
if (status != STATUS_OK)
{
Serial.println("ERROR!");
}
uint32_t value = thermocouple.getRawData(); // Read the raw Data value from the module
Serial.print("RAW:\t");
// Display the raw data value in BIN format
uint32_t mask = 0x80000000;
for (int i = 0; i < 32; i++)
{
if ((i > 0) && (i % 4 == 0)) Serial.print("-");
Serial.print((value & mask) ? 1 : 0);
mask >>= 1;
}
Serial.println();
Serial.print("TMP:\t");
Serial.println(thermocouple.getTemperature(), 3);
delay(100);
}
I am desperate - any help would be appreciated!