MySql connector doesn't work with UTFT LCD

I am trying to write Arduino program which should be able to read and write MySql database and Display retrieved data using TFT LCD.

the MySql read/write function are working properly without LCD… when I try to program LCD to display result the Serial Monitor show below result and MySql read/write function not work…

Serial Monitor Result

æþþ`ffž†žæfþæþžþ˜æ~~fx`x`øþþþž†ffàà~ž†øž

the above mentioned error occured when i added to below code in to void setup()

myGLCD.setFont(BigFont)

without myGLCD.setFont(BigFont) code the rest of functions are working well…

Here is my program

#include <Ethernet.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
#include "DHT.h"
#include <UTFT.h>

#define DHTPIN 8     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE);

// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];

UTFT myGLCD(ITDB32S, 38, 39, 40, 41);

byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server_addr(192, 168, 1, 3); // IP of the MySQL *server* here
IPAddress device_ip(192, 168, 1, 8); // Arduino Ethernet IP address
char user[] = "root";              // MySQL user login username
char password[] = "";        // MySQL user login password

EthernetClient client;
MySQL_Connection conn((Client *)&client);
// Create an instance of the cursor passing in the connection
MySQL_Cursor cur = MySQL_Cursor(&conn);

char query[] = "SELECT d1,d2,d3,d4,a1,a2,a3,a4 FROM test_arduino.sensor where d1 > 0 order by id DESC limit 1";
int d1,d2,d3,d4,a1,a2,a3,a4 = 0;

void setup() {
  Serial.begin(115200);
  dht.begin();
  while (!Serial); // wait for serial port to connect

  for(int i=14; i<18; i++)
  {
    pinMode(i, OUTPUT);
    digitalWrite(i, LOW);
  }

  for(int i=8; i<12; i++)
  {
    pinMode(i, OUTPUT);
    analogWrite(i, 0);
  }

  myGLCD.InitLCD();
  myGLCD.clrScr();

  myGLCD.setBackColor(0,0,0);
  myGLCD.setColor(211,84,0);  

  myGLCD.setFont(BigFont);
  
  Ethernet.begin(mac_addr, device_ip);
  Serial.println("Connecting...");
  if (conn.connect(server_addr, 3306, user, password)) {
    delay(1000);
  }
  else
    Serial.println("Connection failed.");
}

void loop() {
  row_values *row = NULL;
  long head_count = 0;
  
  delay(2000);

  // Initiate the query class instance
  MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
  // Execute the query
  cur_mem->execute(query);
  // Fetch the columns (required) but we don't use them.
  column_names *columns = cur_mem->get_columns();

  // Read the row (we are only expecting the one)
  do {
    row = cur_mem->get_next_row();
    if (row != NULL) {
      d1 = atol(row->values[0]);
      d2 = atol(row->values[1]);
      d3 = atol(row->values[2]);
      d4 = atol(row->values[3]);
      a1 = atol(row->values[4]);
      a2 = atol(row->values[5]);
      a3 = atol(row->values[6]);
      a4 = atol(row->values[7]);
    }
  } while (row != NULL);
  // Deleting the cursor also frees up memory used
  delete cur_mem;

  Serial.print("d1:");
  Serial.print(d1);
  Serial.print(", d2:");
  Serial.print(d2);
  Serial.print(", d3:");
  Serial.print(d3);
  Serial.print(", d4:");
  Serial.print(d4);
  Serial.print(", a1:");
  Serial.print(a1);
  Serial.print(", a2:");
  Serial.print(a2);
  Serial.print(", a3:");
  Serial.print(a3);
  Serial.print(" a4:");
  Serial.println(a4);

  float h = dht.readHumidity();
  // Read temperature as Celsius
  float t = dht.readTemperature();

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  char INSERT_SQL[128] = "INSERT INTO test_arduino.sensor (`temperature`,`humidity`) VALUES ('";

  char float_bufT[6], float_bufH[6];

  dtostrf(t, 3, 2, float_bufT);

  strcat(INSERT_SQL, float_bufT);
  strcat(INSERT_SQL, "','");

  dtostrf(h, 3, 2, float_bufH);

  strcat(INSERT_SQL, float_bufH);
  strcat(INSERT_SQL, "')");

  // Initiate the query class instance
  MySQL_Cursor *cur_memm = new MySQL_Cursor(&conn);
  // Execute the query
  cur_memm->execute(INSERT_SQL);
  // Note: since there are no results, we do not need to read any data
  // Deleting the cursor also frees up memory used
  delete cur_memm;

  Serial.println(INSERT_SQL);

}

please help me to solve this problem…

Assuming you did set the console to 115200 :slight_smile:

Are you on a UNO? Check how much free memory you have

  char INSERT_SQL[128] =... --> that is a lot of memory
Same for query

With the font on top what's left?

Consider using F() macro where possible

J-M-L:
Assuming you did set the console to 115200 :slight_smile:

Are you on a UNO? Check how much free memory you have

  char INSERT_SQL[128] =... --> that is a lot of memory
Same for query

With the font on top what's left?

Consider using F() macro where possible

I am using Arduino Mega 2560.. Here i attached memory details after upload sketch.. please consider it and help me..

Sketch uses 36,036 bytes (14%) of program storage space. Maximum is 253,952 bytes.
Global variables use 1,176 bytes (14%) of dynamic memory, leaving 7,016 bytes for local variables