Bekomme Temperatur nicht angezeigt

Brauche mal bitte Eure hilfe.
Habe ein LCD Display, Nodemcu und Dallas Sensor.
Möchte nun die Temperatu im Display anzeigen lassen plus in Thingspeak.
Es kommen aber keine Daten an.
Thingspeak kommt korrekt an, aber im Dispay wird nur 0 angezeigt.

Kann mal bitte jemand schauen , wo ich einen Fehler habe.
Danke

#include <ESP8266WiFi.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"

#define myPeriodic 15 //in sec | Thingspeak pub is 15sec
#define ONE_WIRE_BUS 2  // DS18B20 on arduino pin2 corresponds to D4 on physical board
// For the LCD shield, these are the default.
#define TFT_DC D1
#define TFT_CS D2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
// Initialize LCD
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

// If using the breakout, change pins as desired
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
float temp; //Stores temperature value
float prevTemp = 0;
const char* server = "api.thingspeak.com";
String apiKey ="9PTOO5AE";
const char* MY_SSID = "FRIT7490"; 
const char* MY_PWD = "reimu7";
int sent = 0;
void setup() {
  Serial.begin(115200);
  connectWifi();
  //Initialize TFT LCD
  tft.begin();

  
    
  #ifdef SERIAL_DEBUG
    // read diagnostics (optional but can help debug problems)
    uint8_t x = tft.readcommand8(ILI9341_RDMODE);
    Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
    x = tft.readcommand8(ILI9341_RDMADCTL);
    Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
    x = tft.readcommand8(ILI9341_RDPIXFMT);
    Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
    x = tft.readcommand8(ILI9341_RDIMGFMT);
    Serial.print("Image Format: 0x"); Serial.println(x, HEX);
    x = tft.readcommand8(ILI9341_RDSELFDIAG);
    Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX);
  #endif 

 //Rotate the screen to right direction
 tft.setRotation(1);

 //Print the headers
 printHeader();


}

void loop() {
  float temp;
  //char buffer[10];
  DS18B20.requestTemperatures(); 
  temp = DS18B20.getTempCByIndex(0);
  //String tempC = dtostrf(temp, 4, 1, buffer);//handled in sendTemp()
  Serial.print(String(sent)+" Temperature: ");
  Serial.println(temp);
  
  //if (temp != prevTemp)
  //{
  //sendTeperatureTS(temp);
  //prevTemp = temp;
  //}
  
  sendTeperatureTS(temp);
  int count = myPeriodic;
  while(count--)
  delay(1000);
}
//Print headers
unsigned long printHeader(void )
{
  tft.fillScreen(ILI9341_GREEN);

  unsigned long start = micros();
  tft.setTextColor(ILI9341_BLACK);   
  tft.setTextSize(4);
  //
  tft.setCursor(50,0+20);
  tft.print("Aquarium");

  //
  tft.setCursor(50,64+20);
  tft.print("Temperatur");
  

  #ifdef SERIAL_DEBUG
    Serial.print("Celsius = ");
    Serial.print(temp);
    //Print degree symbol
    Serial.write(176); 
    Serial.println("C");
  #endif
        
  tft.setCursor(250,0+20);
  tft.print(temp);
  tft.print(" ");
  tft.print((char)247);
  tft.println("C");
  
  return micros() - start;
    
}


void connectWifi()
{
  Serial.print("Connecting to "+*MY_SSID);
  WiFi.begin(MY_SSID, MY_PWD);
  while (WiFi.status() != WL_CONNECTED) {
  delay(1000);
  Serial.print(".");
  }
  
  Serial.println("");
  Serial.println("Connected");
  Serial.println("");  
}//end connect

void sendTeperatureTS(float temp)
{  
   WiFiClient client;
  
   if (client.connect(server, 80)) { // use ip 184.106.153.149 or api.thingspeak.com
   Serial.println("WiFi Client connected ");
   
   String postStr = apiKey;
   postStr += "&field5=";
   postStr += String(temp);
   postStr += "\r\n\r\n";
   
   client.print("POST /update HTTP/1.1\n");
   client.print("Host: api.thingspeak.com\n");
   client.print("Connection: close\n");
   client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
   client.print("Content-Type: application/x-www-form-urlencoded\n");
   client.print("Content-Length: ");
   client.print(postStr.length());
   client.print("\n\n");
   client.print(postStr);
   delay(1000);
   
   }//end if
   sent++;
 client.stop();
}//end send

Es gibt eine eigene ESP8266-Lib für das Display. Hast Du diese in Benutzung?

Gruß Tommy

Funktioniert.
Allerdings noch ein Problem.
Sobald ich den Sketch übertrage habe, wird alles korrekt angezeigt.
Sobald ich aber den Strom wegnehmen und wieder anschliesse, weren 85 % Grad angezeigt.
Nicht mehr die aktuelle Temperatur.
Woran kann das noch liegen ?

#include <ESP8266WiFi.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085_U.h>
#include <jokerman_255.h>

#define myPeriodic 15 //in sec | Thingspeak pub is 15sec
#define ONE_WIRE_BUS D4  // DS18B20 on arduino pin2 corresponds to D4 on physical board
// For the LCD shield, these are the default.
#define TFT_DC D1
#define TFT_CS D2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
// Initialize LCD
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

// If using the breakout, change pins as desired
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);


const char* server = "api.thingspeak.com";
String apiKey ="9PAE";
const char* MY_SSID = 7490"; 
const char* MY_PWD = "reiy1957";
int sent = 0;
void setup() {
  Serial.begin(115200);
  connectWifi();
  //Initialize TFT LCD
  tft.begin();

  
    
  #ifdef SERIAL_DEBUG
    // read diagnostics (optional but can help debug problems)
    uint8_t x = tft.readcommand8(ILI9341_RDMODE);
    Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
    x = tft.readcommand8(ILI9341_RDMADCTL);
    Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
    x = tft.readcommand8(ILI9341_RDPIXFMT);
    Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
    x = tft.readcommand8(ILI9341_RDIMGFMT);
    Serial.print("Image Format: 0x"); Serial.println(x, HEX);
    x = tft.readcommand8(ILI9341_RDSELFDIAG);
    Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX);
  #endif 

 //Rotate the screen to right direction
 tft.setRotation(1);

 //Print the headers
 printHeader();


}

void loop() {
  float temp = DS18B20.getTempCByIndex(0);
  float prevTemp = 0;
  //char buffer[10];
  DS18B20.requestTemperatures(); 
  temp = DS18B20.getTempCByIndex(0);
  //String tempC = dtostrf(temp, 4, 1, buffer);//handled in sendTemp()
  Serial.print(String(sent)+" Temperature: ");
  Serial.println(temp);
  
  if (temp != prevTemp)
  {
  sendTeperatureTS(temp);
  prevTemp = temp;
  }
  
  sendTeperatureTS(temp);
  int count = myPeriodic;
  while(count--)
  delay(1000);
}
//Print headers
unsigned long printHeader(void )
{
  tft.fillScreen(ILI9341_BLACK);

  unsigned long start = micros();
  tft.setTextColor(ILI9341_GREEN); 
  //tft.setFont(jokerman_255.h);  
 
  tft.setTextSize(4);
//tft.setTextFont(4);
  tft.setCursor(66,0+20);
  tft.print("Aquarium");

  //
  tft.setCursor(50,54+20);
  tft.print("Temperatur");
 

  
  tft.drawRoundRect(300, 300, 120, 20, 7, ILI9341_WHITE);      
  tft.setCursor(66,130+20);
  tft.setTextColor(ILI9341_BLUE); 
  tft.print(DS18B20.getTempCByIndex(0));
  tft.print(" ");
  tft.print((char)247);
  tft.println("C");

  

  return micros() - start;
    
}


void connectWifi()
{
  Serial.print("Connecting to "+*MY_SSID);
  WiFi.begin(MY_SSID, MY_PWD);
  while (WiFi.status() != WL_CONNECTED) {
  delay(1000);
  Serial.print(".");
  }
  
  Serial.println("");
  Serial.println("Connected");
  Serial.println("");  
}//end connect

void sendTeperatureTS(float temp)
{  
   WiFiClient client;
  
   if (client.connect(server, 80)) { // use ip 184.106.153.149 or api.thingspeak.com
   Serial.println("WiFi Client connected ");
   
   String postStr = apiKey;
   postStr += "&field5=";
   postStr += String(temp);
   postStr += "\r\n\r\n";
   
   client.print("POST /update HTTP/1.1\n");
   client.print("Host: api.thingspeak.com\n");
   client.print("Connection: close\n");
   client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
   client.print("Content-Type: application/x-www-form-urlencoded\n");
   client.print("Content-Length: ");
   client.print(postStr.length());
   client.print("\n\n");
   client.print(postStr);
   delay(1000);
   
   }//end if
   sent++;
 client.stop();
}//end send

Diese Temperatur wird angezeigt wenn der Sensor nicht gelesen werden konnte. es kann an der Verdrahtung liegen z.B. an einem Wackelkontakt oder im Sketch ist irgendein Bug was den Kontakt zum Sensor hindert.