MQTT - timings Issue?

Hello guys, thanks for the help so far, it is much appericated.
My project is seding fermentation data to a mqtt server, which is then read by a node red as well as a esp8266 with attached LCD screen. On the LCD screen I graph the data (temperature and gravity).
The ESP8266 receives and displays data when the data when the logging rate (or delay in the loop) is 10,000 however when I extend out to xxxxxx it simple does not receive data. I can see on the serial monitor that it is connecting to the mqtt server but I'm not seeing any data received. Node red Attached to the same mqtt server is receiving data no problem, so i know it's there!
Any thoughts, is the mqtt connection dropping out after a period of time???



#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <Fonts/FreeSerif9pt7b.h> // set font - must be included above at top. https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts
#include <Fonts/FreeSans9pt7b.h>
#include <stdlib.h>
#include <stdio.h>

// Update these with values suitable for your network.

const char* ssid = "xxxxx";
const char* password = "xxxxxx";
const char* mqtt_server = "192.168.1.118"; // currently set to the IP of the Pi

WiFiClient espClient;
PubSubClient client(espClient);
unsigned long lastMsg = 0;
#define MSG_BUFFER_SIZE  (50)

#define TFT_DC D4
#define TFT_CS D8

//https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
// offset for Sydney is + 10 or 11 hours dependant of daylight saving.
// offset is seconds calculated as follows: +10hours = 10x60x60=36000 11x60x60=39600
const long utcOffsetInSeconds = 3600;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

// Define NTP Client to get time
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", utcOffsetInSeconds);

char msg[MSG_BUFFER_SIZE];
int value = 0;

  

void setup_wifi() {
  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    
  }

  randomSeed(micros());

  Serial.println("");
  Serial.println("WiFi connected");
  
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}


float payload;
float temp;
float gravity;
char buffer[16];

/*
void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i = 0; i < length; i++) 
    {
   Serial.print((char)payload[i]);  
   }
 memcpy(buffer, payload,length);
 buffer[length]=0;
 temp=atof(buffer);
 Serial.print("temp=");
 Serial.print (temp);
}

*/



void callback(char* topic, byte* payload, unsigned int length) {
 if (strcmp(topic,"ispindel/iSpindel001/temperature")==0){
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i = 0; i < length; i++) 
    {
   Serial.print((char)payload[i]);  
   }
  memcpy(buffer, payload,length);
  buffer[length]=0;
  temp=atof(buffer);
  Serial.print("temp=");
  Serial.print (temp);

}

if (strcmp(topic,"ispindel/iSpindel001/gravity")==0) {

  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i = 0; i < length; i++) 
    {
   Serial.print((char)payload[i]);  
   }
  memcpy(buffer, payload,length);
  buffer[length]=0;
  gravity=atof(buffer);
  Serial.print("gravity=");
  Serial.print (gravity);

  }
}


void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Create a random client ID
    String clientId = "ESP8266Client-";
    clientId += String(random(0xffff), HEX);
    // Attempt to connect
    if (client.connect(clientId.c_str())) {
      Serial.println("connected");
 // Once connected, publish an announcement...
 // ... and resubscribe
      client.subscribe("ispindel/iSpindel001/temperature");
      client.subscribe("ispindel/iSpindel001/gravity");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

float xscale;
float del;
//float temp_readings;
//float temperature;
// Use hardware SPI (on Uno use #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

float min_temp = 100, max_temp = -100;

#define max_readings 290

#define del 12000 // 599250 for 48 hours -measurement rate in ms - take off 750ms for the time needed to update temp readings.

float history6;
float history12;
float history18;
float history24;
float history30;
float history36;
float history42;
float history48;
float historyA;
float historyB;
float historyC;
float historyD;
float historyE;
float historyF;
float historyG;
float historyH;
float temp_error_offset;

float temp_readings[max_readings+1] = {0};
float gravity_readings[max_readings+1] = {0};

int   reading = 290; //  starting point of graph

#define temp_error_offset   0  // calibration factor?

#define autoscale_on  true
#define autoscale_off false
#define barchart_on   true
#define barchart_off  false

// Assign names to common 16-bit color values:
#define BLACK       0x0000
#define BLUE        0x001F
#define RED         0xF800
#define GREEN       0x07E0
#define CYAN        0x07FF
#define YELLOW      0xFFE0
#define WHITE       0xFFFF
#define MAGENTA     0xF81F
#define GREY        0x4228





/* (C) D L BIRD
 *  This function will draw a graph on a TFT / LCD display, it requires an array that contrains the data to be graphed.
 *  The variable 'max_readings' determines the maximum number of data elements for each array. Call it with the following parametric data:
 *  x_pos - the x axis top-left position of the graph
 *  y_pos - the y-axis top-left position of the graph, e.g. 100, 200 would draw the graph 100 pixels along and 200 pixels down from the top-left of the screen
 *  width - the width of the graph in pixels
 *  height - height of the graph in pixels
 *  Y1_Max - sets the scale of plotted data, for example 5000 would scale all data to a Y-axis of 5000 maximum
 *  data_array1 is parsed by value, externally they can be called anything else, e.g. within the routine it is called data_array1, but externally could be temperature_readings
 *  auto_scale - a logical value (TRUE or FALSE) that switches the Y-axis autoscale On or Off
 *  barchart_on - a logical value (TRUE or FALSE) that switches the drawing mode between barhcart and line graph
 *  barchart_colour - a sets the title and graph plotting colour
 *  If called with Y!_Max value of 500 and the data never goes above 500, then autoscale will retain a 0-500 Y scale, if on, it will increase the scale to match the data to be displayed, and reduce it accordingly if required.
 *  auto_scale_major_tick, set to 1000 and autoscale with increment the scale in 1000 steps.
 */


 
 void DrawGraph(int x_pos, int y_pos, int width, int height, int Y1Max, String title, float DataArray[max_readings], boolean auto_scale, boolean barchart_mode, int graph_colour) {
  #define auto_scale_major_tick 5 // Sets the autoscale increment, so axis steps up in units of e.g. 5
  #define yticks 15                // 5 y-axis division markers
  int maxYscale = 0;
  if (auto_scale) {
    for (int i=1; i <= max_readings; i++ ) if (maxYscale <= DataArray[i]) maxYscale = DataArray[i];
    maxYscale = ((maxYscale + auto_scale_major_tick + 2) / auto_scale_major_tick) * auto_scale_major_tick; // Auto scale the graph and round to the nearest value defined, default was Y1Max
    if (maxYscale < Y1Max) Y1Max = maxYscale; 
  }
  //Graph the received data contained in an array
  // Draw the graph outline
  tft.drawRect(x_pos,y_pos,width+2,height+3,WHITE);
  tft.setTextSize(2);
  tft.setTextColor(graph_colour);
  tft.setCursor(x_pos + (width - title.length()*12)/2,y_pos-20); // 12 pixels per char assumed at size 2 (10+2 pixels)
  tft.print(title);
  tft.setTextSize(1);
  // Draw the data
  int x1,y1,x2,y2;
  for(int gx = 1; gx <= max_readings; gx++){
    x1 = x_pos + gx * width/max_readings; 
    y1 = y_pos + height;
    x2 = x_pos + gx * width/max_readings; // max_readings is the global variable that sets the maximum data that can be plotted 
    y2 = y_pos + height - constrain(DataArray[gx],0,Y1Max) * height / Y1Max + 1;
    if (barchart_mode) {
      tft.drawLine(x1,y1,x2,y2,graph_colour);
    } else {
      tft.drawPixel(x2,y2,graph_colour);
      tft.drawPixel(x2,y2-1,graph_colour); // Make the line a double pixel height to emphasise it, -1 makes the graph data go up!
      
    }
  }
  //Draw the Y-axis scale
  for (int spacing = 0; spacing <= yticks; spacing++) {
    #define number_of_dashes 80
    for (int j=0; j < number_of_dashes; j++){ // Draw dashed graph grid lines
      if (spacing < yticks) tft.drawFastHLine((x_pos+1+j*width/number_of_dashes),y_pos+(height*spacing/yticks),width/(2*number_of_dashes),GREY);
    }

    tft.setFont(); 
    tft.setTextSize(1);
    tft.setTextColor(YELLOW);
    tft.setCursor((x_pos-25),y_pos+height*spacing/yticks-4);
    tft.print(Y1Max - Y1Max / yticks * spacing);
    tft.setFont(); 
// draws the y scale (both above and below code)
//    tft.setFont(); 
//    tft.setTextSize(1);
//    tft.setTextColor(RED);
//    tft.setCursor((x_pos-10),y_pos+height*spacing/yticks-4);
//    tft.print(Y1Max - Y1Max / yticks * spacing);
//    tft.setFont(); 


    
  }

  tft.drawRect(x_pos,y_pos,width+2,height+3,WHITE);
  tft.setTextSize(2);
  tft.setTextColor(graph_colour);
  tft.setCursor(x_pos + (width - title.length()*12)/2,y_pos-20); // 12 pixels per char assumed at size 2 (10+2 pixels)
  tft.print(title);
  tft.setTextSize(1);

}


void DrawGraph2(int x_pos, int y_pos, int width, int height, int Y1Max, String title, float DataArray[max_readings], boolean auto_scale, boolean barchart_mode, int graph_colour) {
  #define auto_scale_major_tick 5 // Sets the autoscale increment, so axis steps up in units of e.g. 5
  #define yticks 15                // 5 y-axis division markers
  int maxYscale = 0;
  if (auto_scale) {
    for (int i=1; i <= max_readings; i++ ) if (maxYscale <= DataArray[i]) maxYscale = DataArray[i];
    maxYscale = ((maxYscale + auto_scale_major_tick + 2) / auto_scale_major_tick) * auto_scale_major_tick; // Auto scale the graph and round to the nearest value defined, default was Y1Max
    if (maxYscale < Y1Max) Y1Max = maxYscale; 
  }
  //Graph the received data contained in an array
  // Draw the graph outline
  tft.drawRect(x_pos,y_pos,width+2,height+3,WHITE);
  tft.setTextSize(2);
  tft.setTextColor(graph_colour);
  tft.setCursor(x_pos + (width - title.length()*12)/2,y_pos-20); // 12 pixels per char assumed at size 2 (10+2 pixels)
  tft.print(title);
  tft.setTextSize(1);
  // Draw the data
  int x1,y1,x2,y2;
  for(int gx = 1; gx <= max_readings; gx++){
    x1 = x_pos + gx * width/max_readings; 
    y1 = y_pos + height;
    x2 = x_pos + gx * width/max_readings; // max_readings is the global variable that sets the maximum data that can be plotted 
    y2 = y_pos + height - constrain(DataArray[gx],0,Y1Max) * height / Y1Max + 1;
    if (barchart_mode) {
      tft.drawLine(x1,y1,x2,y2,graph_colour);
    } else {
      tft.drawPixel(x2,y2,graph_colour);
      tft.drawPixel(x2,y2-1,graph_colour); // Make the line a double pixel height to emphasise it, -1 makes the graph data go up!
      
    }
  }
  //Draw the Y-axis scale
  for (int spacing = 0; spacing <= yticks; spacing++) {
    #define number_of_dashes 80
    for (int j=0; j < number_of_dashes; j++){ // Draw dashed graph grid lines
      if (spacing < yticks) tft.drawFastHLine((x_pos+1+j*width/number_of_dashes),y_pos+(height*spacing/yticks),width/(2*number_of_dashes),GREY);
    }

//    tft.setFont(); 
//    tft.setTextSize(1);
//    tft.setTextColor(YELLOW);
//    tft.setCursor((x_pos-20),y_pos+height*spacing/yticks-4);
//    tft.print(Y1Max - Y1Max / yticks * spacing);
 //   tft.setFont(); 
// draws the y scale (both above and below code)
    tft.setFont(); 
    tft.setTextSize(1);
    tft.setTextColor(RED);
    tft.setCursor((x_pos-13),y_pos+height*spacing/yticks-4);
    tft.print(Y1Max - Y1Max / yticks * spacing);
    tft.setFont(); 


    
  }

  tft.drawRect(x_pos,y_pos,width+2,height+3,WHITE);
  tft.setTextSize(2);
  tft.setTextColor(graph_colour);
  tft.setCursor(x_pos + (width - title.length()*12)/2,y_pos-20); // 12 pixels per char assumed at size 2 (10+2 pixels)
  tft.print(title);
  tft.setTextSize(1);

}













void setup() {
  pinMode(BUILTIN_LED, OUTPUT);     // Initialize the BUILTIN_LED pin as an output
  Serial.begin(115200);
  setup_wifi();
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);

  timeClient.begin();

  tft.begin(); // Start the TFT display
  tft.setRotation(3);
  tft.setTextSize(2);
  tft.setTextColor(BLACK);
  tft.fillScreen(BLACK);   // Clear the screen

  analogWriteFreq(500);    // Enable TFT display brightness
  analogWrite(D0, 750);    // Set display brightness using D0 as driver pin, connects to TFT Backlight pin

  for (int x = 0; x <= max_readings; x++){
    temp_readings[x] = 0;
    gravity_readings[x] = 0;
    
  } // Clears the arrays
  // Preset the max and min values of temperature and humidity

 tft.setFont();//reset font
  
xscale = (290 * ((((del+750) / 1000))/60)/60);

timeClient.update();

delay(2000);


}

void loop() {

  if (!client.connected()) {
    reconnect();
  }
  client.loop();

  unsigned long now = millis();

timeClient.update();

if ((timeClient.getHours() >=18) && (timeClient.getHours() <=6)) { analogWrite(D0,050);}  // time for screen to go off and onn
else { analogWrite(D0,750);}

xscale = (290 * ((((del+750) / 1000))/60)/60);

  tft.fillScreen(BLACK);

  tft.setFont();             //reset font
  tft.setTextColor(YELLOW);
  tft.setTextSize(1);

//-48 hours
  tft.setCursor(11,205);
  history24 = (timeClient.getHours()-24);
  history48 = (timeClient.getHours()-48);
  if (history48 <0) {tft.setTextColor(MAGENTA);}
  else {tft.setTextColor(YELLOW);}
  if (history48 < -24) {tft.setTextColor(CYAN);}
  if (history24 <0){historyD = history24 + 24;}
  if (history24 <0){
    if (historyD<10) {tft.print("0");}
    tft.print(historyD,0);
  }
  else {
    if (history24<10) {tft.print("0");}
    tft.print(history24,0);
    }
  tft.print(":");
  if (timeClient.getMinutes() <10)tft.print("0");
  tft.print(timeClient.getMinutes(),1);
  tft.drawLine(25,20,25,204,GREY);

// past 42 hours
  tft.setCursor(47,205);
  history18 = (timeClient.getHours()-18);
  history42 = (timeClient.getHours()-42);
  if (history42 <0) {tft.setTextColor(MAGENTA);}
  else {tft.setTextColor(YELLOW);}
  if (history42 < -24) {tft.setTextColor(CYAN);}
  if (history18 <0){historyC = history18 + 24;}
  if (history18 <0){
    if (historyC<10) {tft.print("0");}
    tft.print(historyC,0);
  }
  else {
    if (history18<10) {tft.print("0");}
    tft.print(history18,0);
    }
  tft.print(":");
  if (timeClient.getMinutes() <10)tft.print("0");
  tft.print(timeClient.getMinutes(),1);
  tft.drawLine(61,20,61,204,GREY);




//- 36 hours (based on 48 hours)

  tft.setCursor(83,205);
  history12 = (timeClient.getHours()-12);
  history42 = (timeClient.getHours()-36);
  if (history42 <0) {tft.setTextColor(MAGENTA);}
  else {tft.setTextColor(YELLOW);}
  if (history42 < -24) {tft.setTextColor(CYAN);}
  if (history12 <0){historyB = history12 + 24;}
  if (history12 <0){
    if (historyB<10) {tft.print("0");}
    tft.print(historyB,0);
  }
  else {
    if (history12<10) {tft.print("0");}
    tft.print(history12,0);
    }
  tft.print(":");
  if (timeClient.getMinutes() <10)tft.print("0");
  tft.print(timeClient.getMinutes(),1);
  tft.drawLine(97,20,97,204,GREY);

 
// -30 hours (based on 48 hours)
  tft.setCursor(119,205);
  history6 = (timeClient.getHours()-30);
  if (history6 < 0) {tft.setTextColor(MAGENTA);}
  else {tft.setTextColor(YELLOW);}
  if (history6 <-24) {tft.setTextColor(CYAN);}
  if (history6 <0){historyA = history6 + 24;}
  if (history6 <0){
    if (historyA<10) {tft.print("0");}
    tft.print(historyA,0);
  }
  else {
    if (history6<10) {tft.print("0");}
    tft.print(history6,0);
    }
  tft.print(":");
  if (timeClient.getMinutes() <10)tft.print("0");
  tft.print(timeClient.getMinutes(),1);
  tft.drawLine(133,20,133,204,GREY);



// -24 hours (based on 48hour trend)
  tft.setCursor(155,205);
  history24 = (timeClient.getHours()-24);
  if (history24 <0) {tft.setTextColor(MAGENTA);}
  else {tft.setTextColor(YELLOW);}
  if (history24 <-24) {tft.setTextColor(CYAN);}
  if (history24 <0){historyD = history24 + 24;}
  if (history24 <0){
    if (historyD<10) {tft.print("0");}
    tft.print(historyD,0);
  }
  else {
    if (history24<10) {tft.print("0");}
    tft.print(history24,0);
    }
  tft.print(":");
  if (timeClient.getMinutes() <10)tft.print("0");
  tft.print(timeClient.getMinutes(),1);
  tft.drawLine(169,20,169,204,GREY);


// -18 hours (based on 48hour trend)  
  tft.setCursor(191,205);
  history18 = (timeClient.getHours()-18);
  if (history18 <0) {tft.setTextColor(MAGENTA);}
  else {tft.setTextColor(YELLOW);}
  if (history18 <0){historyC = history18 + 24;}
  if (history18 <0){
    if (historyC<10) {tft.print("0");}
    tft.print(historyC,0);
  }
  else {
    if (history18<10) {tft.print("0");}
    tft.print(history18,0);
    }
  tft.print(":");
  if (timeClient.getMinutes() <10)tft.print("0");
  tft.print(timeClient.getMinutes(),1);
  tft.drawLine(205,20,205,204,GREY);






  tft.setCursor(227,205);
  history12 = (timeClient.getHours()-12);
  if (history12 <0) {tft.setTextColor(MAGENTA);}
  else {tft.setTextColor(YELLOW);}
  if (history12 <0){historyB = history12 + 24;}
  if (history12 <0){
    if (historyB<10) {tft.print("0");}
    tft.print(historyB,0);
  }
  else {
    if (history12<10) {tft.print("0");}
    tft.print(history12,0);
    }
  tft.print(":");
  if (timeClient.getMinutes() <10)tft.print("0");
  tft.print(timeClient.getMinutes(),1);
  tft.drawLine(241,20,241,204,GREY);


// -6 hours (based on 48hour trend) xscale = (290 * ((((del+750) / 1000))/60)/60);
  tft.setCursor(262,205);
  history6 = (timeClient.getHours()-6);
  if (history6 <0) {tft.setTextColor(MAGENTA);}
  else {tft.setTextColor(YELLOW);}
  if (history6 <0){historyA = history6 + 24;}
  if (history6 <0){
    if (historyA<10) {tft.print("0");}
    tft.print(historyA,0);
  }
  else {
    if (history6<10) {tft.print("0");}
    tft.print(history6,0);
    }
  tft.print(":");
  if (timeClient.getMinutes() <10)tft.print("0");
  tft.print(timeClient.getMinutes(),1);
  tft.drawLine(277,20,277,204,GREY);


//NOW
  tft.setCursor(300,205);
  tft.drawLine(314,202,314,204,BLACK);
  tft.print("NOW");
  
  tft.setFont(&FreeSans9pt7b); // set font - must be included above at top. https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts
  tft.setTextColor(YELLOW);
  tft.setTextSize(1);
  tft.setCursor(200,230);
  tft.print("Temp: ");
  tft.print(temp,1);
  tft.print(char(247));            //Deg-C symbol
  tft.print("C");
  temp_readings[reading] = temp;
  gravity_readings[reading] = gravity;
  
  if (temp > max_temp) max_temp = temp;
  if (temp < min_temp) min_temp = temp;
 
  tft.setTextSize(1);
  tft.setTextColor(RED);
  tft.setCursor(10,230);
  tft.print("Gravity:");
  tft.print(char(247));          // Deg-C symbol
  tft.print(gravity,1);   // needs tidying up to display better
 // tft.setTextColor(CYAN);
 // tft.setCursor(100,230);
 // tft.print(min_temp,1);
 // tft.print(char(251));          // Deg-C symbol
 // tft.print("C min");

  tft.setFont();             //reset font
  tft.setTextColor(YELLOW);
  tft.setFont(&FreeSans9pt7b);
  tft.setCursor(120,13);
  tft.setTextSize(1);
  tft.print("Fermentation");
 // tft.print(xscale,1);
 // tft.print(" hrs");
  
 
 tft.setFont();//reset font

temp_readings[reading] = temp;
gravity_readings[reading] = gravity;


// Display temperature readings on graph
// DrawGraph(int x_pos, int y_pos, int width, int height, int Y1_Max, String title, float data_array1[max_readings], boolean auto_scale, boolean barchart_mode, int colour)
DrawGraph(25,20,290,180,30,"",temp_readings, autoscale_off,  barchart_off, YELLOW); //YI_Max is the Y scale max figure.

DrawGraph2(25,20,290,180,60,"",gravity_readings, autoscale_off,  barchart_off, RED); //YI_Max is the Y scale max figure.
// Serial.print((char)payload[i]);


reading = reading + 1;
  if (reading > max_readings) { // if number of readings exceeds max_readings (e.g. 100) then shift all array data to the left to effectively scroll the display left
    reading = max_readings;
    for (int i = 1; i < max_readings; i++) {
      temp_readings[i] = temp_readings[i+1];
     
    }
    temp_readings[reading] = temp;
    
    
  }
reading = reading + 1;
  if (reading > max_readings) { // if number of readings exceeds max_readings (e.g. 100) then shift all array data to the left to effectively scroll the display left
    reading = max_readings;
    for (int i = 1; i < max_readings; i++) {
      gravity_readings[i] = gravity_readings[i+1];
     
    }
    gravity_readings[reading] = gravity;
    
    
  }



if (WiFi.status() == 3) {
  tft.setTextColor(BLACK);
  tft.setTextSize(1);
  tft.setCursor(265,10);
  tft.print("WiFi:Fail");
  tft.setTextColor(GREEN);
  tft.setTextSize(1);
  tft.setCursor(265,10);
  tft.print("WiFi:OK");
  }
  if (WiFi.status() == 6) {
  tft.setTextColor(BLACK);
  tft.setTextSize(1);
  tft.setCursor(265,10);
  tft.print("WiFi:OK");
  tft.setTextColor(RED);
  tft.setTextSize(1);
  tft.setCursor(265,10);
  tft.print("WiFi:Fail");
  }

   String clientId = "ESP8266Client-";
   clientId += String(random(0xffff), HEX);
if (client.connect(clientId.c_str())) {
      Serial.println("connected");
  tft.setTextColor(GREEN);
  tft.setTextSize(1);
  tft.setCursor(0,233);
  tft.print("Remote Database: Conneted");
}


// Prints time in TOP LEFT corner.

tft.setTextColor(YELLOW);
tft.setTextSize(1);
tft.setCursor(1,1); 
tft.print("Last Update:");
tft.print(timeClient.getHours());
tft.print(":");
if (timeClient.getMinutes() <10)tft.print("0");
tft.print(timeClient.getMinutes());



 delay(del); //Data logging rate. (allowing 250ms for temp updtate 


  
}

Using a long delay() in loop() is a bad idea because it stops the code in loop() running for the period of the delay()

Use millis() and implement non blocking timing so that other code can run

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.