Es ist frustierend.
Habe eine Schaltung mit WemosD1, TFT ILI9341, 7 Fühler 1-Wire, 2 Taster und ein Relais als Ausgang
Da das TFT in jeglicher Beschaltung ab und zu weiß wird (Kommt von den elektrischen Schiebern) habe ich gedacht, es ist sinnvoll, den Bildschirm nach jedem Relais an und aus, neu zu starten (Auslesen des Bildschirms, ob er noch arbeitet, ist nach ca 30verschiedenen Varianten aufgegeben worden). Funktioniert auch, nur brauch der Bildschirm eine ewigkeit bis er sich aufgebaut hat.
Also habe ich mich für den superschnellen TFT_eSPI entschieden. Ein Traum. ABER:
Ich kann den Pin 6 nicht mehr als Tastereingang (zählt ständig weiter, auch mit Pullup oder Widerstand) oder als Relais-Ausgang benutzen (Relais schaltet nicht)
HAb auch schon den Chip gewechselt.
Es muss an der Bibliothek liegen, da die Beschaltung mit dem Adafruit funktioniert…
/* MOSI D1, TFT ILI9341 SPI, 7x Temp-Sensoren oneWire, Relais,
* TFT: TFT CS - WemosD1 D0, TFT RST - WemosD1 D3, TFT D/C - WemosD1 D4, TFT SCK - WemosD1 D5, TFT SDI - WemosD1 D7
* oneWire - WemosD1 D1 ,
* Taster Minus - WemosD1 D6, Taster Plus - WemosD1 D2
* Relais - WemosD1 D8
* D0 - TFT CS, D1 - oneWire, D2 - Taster Plus, D3 - TFT RST, D4 - TFT D/C, D5 -TFT SCK/CLK, D6 - Taster Minus, D7 - TFT SDI, D8 - Relais,
* UPLoad to NodeMCU 1.0(ESP-12E Module), TFT Reset nach Relaisbetätigung auf Grund Absturz
* Bibliothek "TFT_eSPI_ILI9341" wurde für diesen Sketch im User-Setup angeglichen (Treiber ILI9341, Pin siehe oben, )
*/
//#include "Adafruit_GFX.h"
//#include "Adafruit_ILI9341.h"
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <ESP8266WiFi.h>
#include <SPI.h>
#include "TFT_eSPI_ILI9341.h" // Hardware-specific library
//#define TFT_CS D0 //lila
#define ONE_WIRE_BUS D1 // gelb/sw
#define tasterPin1 D2 // Rosa
#define TFT_RST D3 // orange
#define TFT_DC D4 // Orange/weiß
#define TFT_CLK D5 // SCK
#define tasterPin2 D6 // grün/sw
#define TFT_MOSI D7 // gelb/sw
#define relais D8 // grün/sw
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress sensor1 = {0x28, 0x7A, 0x57, 0x57, 0x04, 0xE1, 0x3C, 0xE1};
DeviceAddress sensor2 = {0x28, 0x9B, 0x47, 0x57, 0x04, 0xE1, 0x3C, 0x83};
DeviceAddress sensor3 = {0x28, 0x27, 0x11, 0x81, 0xE3, 0x9E, 0x3C, 0xEB};
DeviceAddress sensor4 = {0x28, 0xAD, 0x59, 0x81, 0xE3, 0xC1, 0x3C, 0x76};
DeviceAddress sensor5 = {0x28, 0xFB, 0x99, 0x57, 0x04, 0xE1, 0x3C, 0xBC};
DeviceAddress sensor6 = {0x28, 0x28, 0x4F, 0x57, 0x04, 0xE1, 0x3C, 0xE3};
DeviceAddress sensor7 = {0x28, 0x49, 0xcd, 0x57, 0x04, 0xE1, 0x3C, 0x5F};
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
#define BLACK 0x0000
#define RED 0x001F
#define BLUE 0xF800
#define GREEN 0x07E0
#define WHITE 0xFFFF
int counter = 55;
float temp1;
float temp2;
float temp3;
float temp4;
float temp5;
float temp6;
float temp7;
int ein = 0;
int aus = 0;
void handleGetTemps() {
sensors.requestTemperatures();
temp1 = sensors.getTempC(sensor1);
temp2 = sensors.getTempC(sensor2);
temp3 = sensors.getTempC(sensor3);
temp4 = sensors.getTempC(sensor4);
temp5 = sensors.getTempC(sensor5);
temp6 = sensors.getTempC(sensor6);
temp7 = sensors.getTempC(sensor7); }
void resetDisplay() {
tft.begin(); // bzw. tft.init();
tft.setRotation(1);
tft.fillScreen(BLACK);
tft.fillRect(10, 55, 150, 180, (BLUE));
}
void setup() {
Serial.begin(115200);
pinMode(tasterPin1, INPUT_PULLUP);
pinMode(tasterPin2, INPUT_PULLUP);
pinMode(relais, OUTPUT);
tft.begin();
tft.setRotation(1);
tft.fillScreen(BLACK); // tft.fillScreen(random(0xFFFF));
tft.fillRect(10, 55, 150, 180, (BLUE));
sensors.begin(); }
void loop() {
sensors.requestTemperatures();
temp1 = sensors.getTempC(sensor1);
temp2 = sensors.getTempC(sensor2);
temp3 = sensors.getTempC(sensor3);
temp4 = sensors.getTempC(sensor4);
temp5 = sensors.getTempC(sensor5);
temp6 = sensors.getTempC(sensor6);
temp7 = sensors.getTempC(sensor7);
// TFT-Anzeige aktualisieren
tft.setTextColor((WHITE), (BLUE)); tft.setTextSize(3);
tft.setCursor(20, 75); if (temp2 < 10) {tft.print(" ");} if (temp2 < 99) {tft.print(temp2, 1);tft.println(" \xF7""C");} else {tft.print(" -- ");}
tft.setCursor(20, 115); if (temp3 < 10) {tft.print(" ");} if (temp3 < 99) {tft.print(temp3, 1); tft.println(" \xF7""C");} else {tft.print(" -- ");}
tft.setCursor(20, 155); if (temp4 < 10) {tft.print(" ");} if (temp4 < 99) {tft.print(temp4, 1); tft.println(" \xF7""C");} else {tft.print(" -- ");}
tft.setCursor(20, 195); if (temp5 < 10) {tft.print(" ");} if (temp5 < 99) {tft.print(temp5, 1); tft.println(" \xF7""C");} else {tft.print(" -- ");}
tft.setCursor(185, 60); tft.setTextSize(2); tft.setTextColor(RED, BLACK); tft.print("Vorlauf");
tft.setCursor(175, 85); tft.setTextSize(3); if (temp6 < 10) {tft.print(" ");} if (temp6 < 99) {tft.print(temp6, 1); tft.println(" \xF7""C");} else {tft.print(" -- ");}
tft.setCursor(185, 135); tft.setTextSize(2); tft.setTextColor(BLUE, BLACK); tft.print("R"); tft.write(0x81);tft.print("cklauf");
tft.setCursor(185, 160); tft.setTextSize(3); if (temp1 < 10) {tft.print(" ");} if (temp1 < 99) {tft.print(temp1, 1); tft.println(" \xF7""C");} else {tft.print(" -- ");}
tft.setCursor(175, 210); tft.setTextSize(2); tft.setTextColor(WHITE, BLACK); tft.print("SP: "), tft.print(counter); tft.print("-"); tft.print(counter-6); tft.println(" \xF7""C");
tft.setCursor(35, 20); tft.setTextSize(3); tft.setTextColor(RED, BLACK); tft.print(temp7, 1); tft.println(" \xF7""C");
// Relais steuern
if (temp7 > counter) {
tft.setCursor(185, 20); tft.setTextSize(3); tft.setTextColor(GREEN, RED); tft.print("ACTIV"); digitalWrite(relais, HIGH);
if (ein == 0) {delay(1000); resetDisplay(); ein = 1; aus = 0;}
}
if (temp7 < counter-6) {
tft.setCursor(185, 20); tft.setTextSize(3); tft.setTextColor(RED, BLACK); tft.print(" OFF "); digitalWrite(relais, LOW);
if (aus == 0) {delay(1000); resetDisplay(); ein = 0; aus = 1;}
}
// Schaltpunkt ändern
if (digitalRead(tasterPin1) == LOW) {while(digitalRead(tasterPin1)== LOW){delay(600); counter++; Serial.print(" counter :"); Serial.print(counter); Serial.print(" counter -6 :"); Serial.println(counter-6);
tft.setCursor(175, 210); tft.setTextSize(2); tft.setTextColor(WHITE, BLACK); tft.print("SP: "), tft.print(counter); tft.print("-"); tft.print(counter-6); tft.println(" \xF7""C");
} }
if (digitalRead(tasterPin2) == LOW) {while(digitalRead(tasterPin2)== LOW){delay(600); counter--; Serial.print(" counter :"); Serial.print(counter); Serial.print(" counter -6 :"); Serial.println(counter-6);
tft.setCursor(175, 210); tft.setTextSize(2); tft.setTextColor(WHITE, BLACK); tft.print("SP: "), tft.print(counter); tft.print("-"); tft.print(counter-6); tft.println(" \xF7""C");
} }
delay(100);
}
Nicht wundern, es befinden sich noch einige “serial.Print” im Code, die mir helfen sollten einen Fehler zu finden.
Hier noch der Code aus der “USER.Setup”, die gesetzt sind:
// For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation
#define TFT_CS PIN_D0 // lila
#define TFT_DC PIN_D4 // Orange/weiß
#define TFT_RST PIN_D3 // Orange
#define TFT_MOSI PIN_D7 // gelb/schwarz
#define TFT_CLK PIN_D5 // lila
// Only define one driver, the other ones must be commented out
#define ILI9341_DRIVER // Generic driver for common displays
// #define SPI_FREQUENCY 1000000
// #define SPI_FREQUENCY 5000000
// #define SPI_FREQUENCY 10000000
// #define SPI_FREQUENCY 20000000
#define SPI_FREQUENCY 27000000
// #define SPI_FREQUENCY 40000000
// #define SPI_FREQUENCY 55000000 // STM32 SPI1 only (SPI2 maximum is 27MHz)
// #define SPI_FREQUENCY 80000000
// Optional reduced SPI frequency for reading TFT
#define SPI_READ_FREQUENCY 20000000
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
#define SPI_TOUCH_FREQUENCY 2500000
Lt Datenblatt kann ich den D6 als Ein- und Ausgang nutzen, irgendwo sagt aber jemand “nein”
Den Chip und das TFT kann ich gegen keine andersartigen tauschen (Gehäusetechnisch), umlötarbeiten sind auf Grund des Platzmangels eingeschränkt möglich.
Programmtechnisch bi ich eher ein Anfänger
Danke schon mal fürs lesen des ganzen Blockes, vieleicht ist eine Lösung nah…
P.s. Habe diesen Beitrag in Deutsch verfasst und in die deutschen Beiträge integriert, das sollte diesmal passen



