corrupted text
-
@witchdoc Ooof! This is a classic case of not clearing the printed text before the next display update!
The text 'compounds' until it is filled in completely.
Your time display is the clue.
At the top of your print results put in:tft.fillScreen(TFT_BLACK);
or if that causes flickering try
tft.fillRect(h, v, h size, v size, TFT_BLACK);
for example, where needed.
This second one is a pain to get the horizontal, vertical and box dimensions perfect.Try that!
-Terry -
@teastain2 Ok that worked a treat. The temperature is displaying as it should. Now to figure out why it's all over the place. Thermometer on my desk reads 23.5 while my Lilygo is displaying Anywhere from 17 to 20 degrees. And it's changing every loop of the void loop. And I still have to deal with the time display being corrupted.
Gonna look more into millis().
Thanks for the assistance.WD
-
@witchdoc what temperature sensor are you using?
I see an LM-35, but they are analog, and the ESP32 is a terrible ADC, with linearity and stability issues, because its value changes with the ESP32 core temp and internal voltage fluctuations! -
@teastain2 Thanks for that information. How about the DS18B20? Would it work better? Looking now for the datasheet on the DS.
-
@witchdoc DS18B20 is the best low-end temp sensor I’ve seen.
It is digital, with a simple serial interface.
You need two libraries to run it, but its use is well documented.
Cheers,I have a test sketch for it running on LilyGO if you are interested, I will post it here.
-
@teastain2 I'd be interested to see how you did it. I've got it running on my T-Display. My multimeter with a thermocouple on it reads 22 degrees. My cheap 3 dollar Chinese thermometer reads 23.4 and my DS18B20 is reading 23.87. At the moment the temperature is flashing on and off as the loop, loops. And I've yet to deal with the time display getting corrupted.
-
@witchdoc
Prints to serial as I do not have a TTGO!#include <OneWire.h> #include <DallasTemperature.h> OneWire oneWire(1); //pin 1 or your choice! DallasTemperature sensors(&oneWire); void setup() { Serial.begin(115200); delay(200); Serial.println(" setup DS18B20 "); delay(200); sensors.begin(); } void loop() { sensors.requestTemperatures(); float temperatureC = sensors.getTempCByIndex(0); Serial.print(temperatureC); Serial.println("ºC"); Serial.println(" "); delay(2000); }
-
@teastain2 Thanks for the script. I found a solution to the blinking text. I have another display running on another ESP32 and I realized that it wasn't blinking. It is running a GPS program and displaying the time which always looks crisp and clean so I took a look at that script and realized it was using a different display library. TFT_eSPI. Took a bit of tinkering but I got a display that shows the temperature perfectly.```
#include <TFT_eSPI.h> // Hardware-specific library
#include <OneWire.h>
#include <DallasTemperature.h>TFT_eSPI tft = TFT_eSPI();
// GPIO where the DS18B20 is connected to
const int oneWireBus = 32;float getTemperature(){
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(oneWireBus);// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
sensors.begin();
//delay(dT) ;sensors.requestTemperatures();
float temperatureC = sensors.getTempCByIndex(0);
//float temperatureF = sensors.getTempFByIndex(0);
return(temperatureC);
}void setup() {
Serial.begin(115200);
//delay(dT) ;
pinMode(TFT_BL, OUTPUT); // TTGO T-Display enable Backlight pin 4
digitalWrite(TFT_BL, HIGH); // T-Display turn on Backlight
tft.init(); // Initialize ST7789 240x135
Serial.println(F("Initialized"));
tft.fillScreen(TFT_BLACK);
}void loop() {
tft.setRotation(1);
tft.setTextColor(TFT_GREENYELLOW,TFT_BLACK);
tft.setCursor(0, 0);
tft.print("Temperature: ");
tft.setCursor(74, 50);
tft.setTextSize(3);
tft.print(getTemperature());
} -
@witchdoc Well it looks like I spoke to soon. I converted my thermometer sketch to the tft_espi library and it's doing the same thing that the adafruit library does. Initially it is very clear but within the first second the temperature reading begins to corrupt as does the time display. Not sure why since the test sketch with the espi library was so perfect.
-
@witchdoc Can you post your sketch here and I will have a look?
The key is that new text is not being erased, it is just building up like a rubber stamp, changing the time and over printing each time. It may not be the library, but your code!
-
@teastain2 I figured it out. With the eSPI library, when you specify text color you have to specify a background color. So by entering the following tft.setTextColor(TFT_GREENYELLOW,TFT_BLACK); the display will display a non blinking text.
-
@witchdoc Perfect! Thanks for getting back to me.