TFT 3,5 HX8357 sensor read values overrides on screen

Hello,

I'm new on this forum and also on arduino programming , I've try to create mi first environment monitor...and I have a bug in my lines, everytime when the sensor are read, the old values remain on screen and the new one are override.

Board: Arduino Mega 2560
Sensor: Temp&Humidity DH11

Bellow are my sketch:

#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#include <TFT_HX8357.h>
byte fontSize4 = 4; // 26 px, FontSize 4, 6, 7, 8
byte fontSize6 = 6; // 48 px
TFT_HX8357 tft = TFT_HX8357(); // Invoke custom library

int timer1 = (3000);
#define DHTPIN 2 // Pin which is connected to the DHT sensor.
#define DHTTYPE DHT11 // DHT 11

DHT_Unified dht(DHTPIN, DHTTYPE);
uint32_t delayMS;

void setup() {
tft.init();
tft.setRotation(1);
dht.begin();
sensor_t sensor;
dht.temperature().getSensor(&sensor);

tft.fillScreen(TFT_YELLOW); // TFT_YELLOW = Blue - TFT_BLUE = YELLOW
tft.setTextColor(TFT_BLUE); // TFT_WHITE = Black - TFT_BLUE = White << Das muß raus, dann gehts!

tft.setCursor(25, 48, fontSize4); //shift Cursor in Pixel (Collum, Row, Fontsize)
tft.setTextFont(fontSize4);
tft.println("Senzor DHT11 Temperatura&Umiditate");
tft.setCursor(40, 172, fontSize4); //shift Cursor in Pixel (Collum, Row, Fontsize)
tft.print("T Interior: ");
tft.setCursor(380, 172, fontSize4); //shift Cursor in Pixel (Collum, Row, Fontsize)
tft.print("Grade C");
tft.setCursor(40, 248, fontSize4);
tft.print("Umiditate Aer: ");
tft.setCursor(380, 248, fontSize4); //shift Cursor in Pixel (Collum, Row, Fontsize)
tft.print("%");
}

void loop() {
sensors_event_t event;
dht.temperature().getEvent(&event);

// Delay between measurements.
delay(delayMS);
tft.setCursor(40, 98, fontSize4); // Spalte, Zeile, Font
tft.println("Citire Temperatura & Umiditate...");
tft.setCursor(190, 172, fontSize6); //shift Cursor in Pixel (Collum, Row, Fontsize)
tft.setCursor(190, 172, fontSize6);
tft.print(event.temperature);
delay (delayMS);
dht.humidity().getEvent(&event);
tft.setCursor(190, 172, fontSize6);
tft.setCursor(220, 248, fontSize6);
tft.print(event.relative_humidity);
delay (delayMS);
}

Attached u can see the screen after reset and the screen after first read

Please if anybody have any suggestions....

Thanks

If you want Blue letters on a White background:

    tft.setTextColor(TFT_BLUE, TFT_WHITE);

Note that regular Adafruit_GFX style libraries can not paint the background when using FreeFonts.
But Bodmer's library can draw all Fonts with background.

Untested. I just typed into the Browser.

David.

Thank you very much David!!!

Now its working perfect.....YEAH....I'm very happy

BR
Marius