Servus Leute, bin momentan dabei eine Temperaturanzeige für ein kleines Projekt zu bauen. Jedoch habe ich nun das Problem, dass ich den zweiten Temperaturwert nicht auf das Display bekomme.
Setup:
-Arduino Nano
-MAX6675 mit Typ K Temperatursensor
-100K Thermistor
-1.77 Zoll SPI TFT Display 128x160
Der Wert vom MAX6675 wird bereits auf dem Display angezeigt, jedoch schaffe ich es nicht den Wert vom 100K Thermistor auf dem Display anzeigen zu lassen. Auf dem Serial Monitor kann ich beide Temperaturen sehen.
Das Programm ist aus mehreren Bibliotheken zusammengestellt und sieht ein wenig aus wie ein Schlachtfeld (bitte Steinigt mich nicht ).
Es geht um die zwei Zeilen " TFTscreen.text( ...X... , 0, 70);", hier muss anstatt dem X der Temperaturwert für den 100K Thermistor rein kommen, aber ich bekomm es irgendwie nicht gebacken. Ich hoffe ihr könnt mir da weiter helfen.
MfG Alex
#include "max6675.h"
#include <SPI.h>
#include <TFT.h>
int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;
int vccPin = 3;
int gndPin = 2;
#define cs 10
#define dc 9
#define rst 8
//Thermistor
int ThermistorPin = 0;
int Vo;
float R1 = 10000;
float logR2, R2, T, Tc, Tf;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
//
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
TFT TFTscreen = TFT(cs, dc, rst);
char sensorPrintout[7];
void setup() {
Serial.begin(9600);
pinMode(vccPin, OUTPUT), digitalWrite(vccPin, HIGH);
pinMode(gndPin, OUTPUT), digitalWrite(gndPin, LOW);
Serial.println("MAX6675 test");
// wait for MAX chip to stabilize
delay(500);
//DISPLAY SETTINGS
TFTscreen.begin();
TFTscreen.background(0, 0, 0);
// write the static text to the screen
// set the font color to white
TFTscreen.stroke(255, 255, 255);
// set the font size
TFTscreen.setTextSize(2);
// write the text to the top left corner of the screen
TFTscreen.text("Temperatur ", 0, 0);
//Wassertemperatur 2
TFTscreen.text("Temperatur", 0, 50);
// ste the font size very large for the loop
TFTscreen.setTextSize(4);
}
void loop() {
// basic readout test, just print the current temp
Serial.print("C = ");
Serial.println(thermocouple.readCelsius());
// For the MAX6675 to update, you must delay AT LEAST 250ms between reads!
//DISPLAY LOOP
// Read the value of the sensor on A0
String sensorVal = String(thermocouple.readCelsius());
// convert the reading to a char array
sensorVal.toCharArray(sensorPrintout, 7);
// set the font color
TFTscreen.stroke(255, 255, 255);
//Wert für erste Temperatur
TFTscreen.text(sensorPrintout, 0, 20);
//Temperaturwert für die zweite Temperatur
TFTscreen.text( ...X... , 0, 70);
delay(1000);
//Wert eins löschen
TFTscreen.stroke(0, 0, 0);
TFTscreen.text(sensorPrintout, 0, 20);
// Wert zwei löschen
TFTscreen.text( ....X.... , 0 , 70);
//Thermistor 100k
Vo = analogRead(ThermistorPin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
Tc = T - 273.15;
Tf = (Tc * 9.0)/ 5.0 + 32.0;
Serial.print("Temperature: ");
Serial.print(Tc);
Serial.println(" C");
}