Danke für den Tipp:) eigentlich hätte ich das wissen müssen, ist mir einfach nicht aufgefallen:D.
Jetzt funktionieren beide Sketches,
hier ist jetzt nochmal alles aktualisiert:
Schltplan:
Sketch/ serieller Monitor:
#include <max6675.h>
int thermoDO = 2;
int thermoCS = 3;
int thermoCLK = 4;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
void setup()
{
Serial.begin(9600);
Serial.println("MAX6675 test");
delay(500);
}
void loop()
{
Serial.print("C = ");
Serial.println(thermocouple.readCelsius());
Serial.print("F = ");
Serial.println(thermocouple.readFahrenheit());
delay(1000);
}
Sketch/ 1602 LCD Display:
#include <max6675.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2); // so wenn ein 1602 display genutzt wird
#define MAX6675_CS 3
#define MAX6675_SO 2
#define MAX6675_SCK 4
void setup()
{
lcd.init(); // für den LCD- Monitor
lcd.backlight(); // für den LCD- Monitor
}
void loop() {
float temperature_read = readThermocouple();
lcd.setCursor(0, 0);
lcd.print(" TEMPERATURE");
lcd.setCursor(4, 1);
lcd.print(temperature_read, 2);
lcd.print ("\337C ");
delay(1000);
}
double readThermocouple() {
uint16_t v;
pinMode(MAX6675_CS, OUTPUT);
pinMode(MAX6675_SO, INPUT);
pinMode(MAX6675_SCK, OUTPUT);
digitalWrite(MAX6675_CS, LOW);
delay(1);
// Read in 16 bits,
// 15 = 0 always
// 14..2 = 0.25 degree counts MSB First
// 2 = 1 if thermocouple is open circuit
// 1..0 = uninteresting status
v = shiftIn(MAX6675_SO, MAX6675_SCK, MSBFIRST);
v <<= 8;
v |= shiftIn(MAX6675_SO, MAX6675_SCK, MSBFIRST);
digitalWrite(MAX6675_CS, HIGH);
if (v & 0x4)
{
// Bit 2 indicates if the thermocouple is disconnected
return NAN;
}
// The lower three bits (0,1,2) are discarded status bits
v >>= 3;
// The remaining bits are the number of 0.25 degree (C) counts
return v * 0.25;
}