Navigation

    LILYGO

    • Register
    • Login
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    corrupted text

    Common problems
    2
    13
    899
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • teastain2
      teastain2 @Witchdoc last edited by teastain2

      @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!

      W 1 Reply Last reply Reply Quote 0
      • W
        Witchdoc @teastain2 last edited by

        @teastain2 Thanks for that information. How about the DS18B20? Would it work better? Looking now for the datasheet on the DS.

        teastain2 1 Reply Last reply Reply Quote 0
        • teastain2
          teastain2 @Witchdoc last edited by teastain2

          @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.

          W 1 Reply Last reply Reply Quote 0
          • W
            Witchdoc @teastain2 last edited by

            @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.

            teastain2 1 Reply Last reply Reply Quote 0
            • teastain2
              teastain2 @Witchdoc last edited by

              @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);
              }
              
              W 1 Reply Last reply Reply Quote 0
              • W
                Witchdoc @teastain2 last edited by

                @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());
                }

                W 1 Reply Last reply Reply Quote 1
                • W
                  Witchdoc @Witchdoc last edited by

                  @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.

                  teastain2 1 Reply Last reply Reply Quote 0
                  • teastain2
                    teastain2 @Witchdoc last edited by

                    @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!

                    W 1 Reply Last reply Reply Quote 0
                    • W
                      Witchdoc @teastain2 last edited by

                      @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.

                      teastain2 1 Reply Last reply Reply Quote 0
                      • teastain2
                        teastain2 @Witchdoc last edited by

                        @witchdoc Perfect! Thanks for getting back to me.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Powered by NodeBB | Contributors