Nothing showing up on display!

Hello, I recently bought an ESP32-3248S035R and I just started to play around with it. I tried displaying the temp that's being read from the M5Stack ENV III. sensor onto the screen but nothing works. The LED just blinks every 2 seconds and that's what it only does for some reason.

Here's my code:

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_SHT31.h>
#include <Adafruit_ILI9341.h>

#define TFT_CLK  13
#define TFT_MISO 19
#define TFT_MOSI 23
#define TFT_CS   15
#define TFT_DC    2
#define TFT_RST   4

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST, TFT_CLK, TFT_MISO, TFT_MOSI);
Adafruit_SHT31 sht31 = Adafruit_SHT31();

void setup() {
    Serial.begin(115200);
    Serial.println("Starting setup...");

    Wire.begin();

  
    if (!sht31.begin(0x44)) { 
        Serial.println("Couldn't find SHT30");
        while (1) delay(1);
    }
    Serial.println("SHT30 sensor initialized");
   
    tft.begin();
    tft.setRotation(1); 
    tft.fillScreen(ILI9341_BLACK); 
    tft.setTextColor(ILI9341_WHITE); 
    Serial.println("ILI9341 display initialized");
}

void loop() {
    float humidity = sht31.readHumidity();
    float temperature = sht31.readTemperature();

    if (!isnan(humidity) && !isnan(temperature)) {

        tft.fillScreen(ILI9341_BLACK);

        tft.setCursor(10, 50);
        tft.setTextSize(2);
        tft.print("Temp: ");
        tft.print(temperature);
        tft.print("C");

        tft.setCursor(10, 80);
        tft.print("Humi: ");
        tft.print(humidity);
        tft.print("%");

        Serial.print("Temperature: ");
        Serial.print(temperature);
        Serial.print("C, Humidity: ");
        Serial.print(humidity);
        Serial.println("%");
    } else {
        Serial.println("Failed to read from SHT30 sensor");
    }

    delay(2000); // wait a little bit before reading again
}

Any help is appreciated! :slightly_smiling_face:

What does the Serial monitor tell you? Did both devices initialize properly? Are you seeing the temperature and humidity on the Serial Monitor every 2 seconds?

I am seeing the temperature and humidity properly in the serial monitor.

Does the display work with one of the display library example programs?

If not, solve that problem first.

1 Like

Seeing that you just received your ESP32 last week. Why not learn to use it first, with ESP32 examples, before trying other devices.

I already fixed it, thank you though!