Millis delay - seems to pause?

I have this project, below, and it has issues!
I'm receiving the mqtt data and displaying it on a LCD screen / graph. However I also want to display the wifi and mqtt data connection status. I've setup two parts of the code to display these status (at the very bottom of the code) They seem to work the first time instance and report the status, however if wifi or database connection is lost everything seems to 'hang' and the screen does not report the change in status change and continues to report all is well!
Also the screen stays blank for the first rotation of the millis delay (10mins) and if does not get a wifi / database connection will never light up!
Help....I've been on this issue for days now and beer can't solve the problem anymore.

typ#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 = "xxx";
const char* password = "xxxxx";
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);

}









const unsigned long eventInterval = 600000; // logging rate in ms (may need to adjust and take into accout other delays)
unsigned long previousTime = 0;



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);

  /* Updates frequently */
  unsigned long currentTime = millis();

  /* This is the event */
  if (currentTime - previousTime >= eventInterval) {
    /* Event code */

  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;
    
     }

//0 : WL_IDLE_STATUS when Wi-Fi is in process of changing between statuses
//1 : WL_NO_SSID_AVAILin case configured SSID cannot be reached
//3 : WL_CONNECTED after successful connection is established
//4 : WL_CONNECT_FAILED if connection failed
//6 : WL_CONNECT_WRONG_PASSWORD if password is incorrect
//7 : WL_DISCONNECTED if module is not configured in station mode

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() == 4) {
  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());

/* Update the timing for the next time around */
  previousTime = currentTime;
  }

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


  
}
e or paste code here

Put the beer away, take an eight hour nap, and when you've recovered, please add code, schematic, etc. per the forum guidelines:
Forum Guidelines

sorry the beer must have soaked into the keyborad....ohh no sorry maybe it was my brain in soaked into..... :rofl:

Hello
Check all these calls of the delay() function are essential needed.

	Line  43:   delay(10);
	Line  53:     delay(500);
	Line 148:       delay(5000);
	Line 406: delay(2000);
	Line 749: // delay(del); //Data logging rate. (allowing 250ms for temp updtate 

paulpaulson
to be honest im not 100% sure if they are, but if they are responsible for my issue I'd like to know why?
I'll play around and remove some some to see what works.

nope....
removing some of the delays had no effect... everything seems to stop as always.??

update..
I'm removing the mqtt server from the loop as a test, and monitroing the sewrial moniotr i can see that it is still attempting to reconnect, so we don't have a 'freeze' as such...but why is the screen inot not updating???

Your code is too cryptic and monolithic for second parties to easily analyze. Answering that question really requires a sit down and digest almost the entire thing, and it is not a short piece.

If you had factored it and structured it top-down, it would be possible to isolate and test the part(s) that are involved in the screen update and narrow it down with some simple test code, substitution or the like.

You have discovered the practical implications of not following what may seem like lofty, academic advice - Design top down, design modularly, and use clear naming conventions and code formatting to make it easily understandable and readable.

There is nothing inherently wrong with following an individual approach. But as soon as you need help from other people, you have the limitation that they can't reach inside your mind to see what's going on there. They only have the code and any documentation that you have written and code comments. For that to work, it has to follow the "rules of the commons", or people will ask for money to look at it.

i understand and you are possibly right...however I'm a novice programmer and learning so I'm in the "cut and paste" part of my journey so this is code from others I've put together.
sorry if I'm made it too confusing or offended the community....i'm just trying to learn, but I learn differently to others I'm not very academic.

It's not a matter of offence. I don't care if your code is beautiful or not, except if you want me to analyze it. There's no feeling of disgust or anything about bad code here (well when accompanied by big ego it is...). It's just that it makes it unworthy of my time. I try to help but if someone has actually buried themselves in other peoples problems by adopting their problematic code, I have to point at the code.

Your learning method is only suitable for the first few days of programming. Cut and paste with little understanding will leave you forever dependent on other programmers. Fortunately, the Arduino is a learning platform with thousands of example sketches, tutorials and projects that can guide you in a linear way so that you can develop some independent skills.

In programming, as in math, skipping chapters will get you lost really fast.

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