Looking for basic setup EPS32-S3-Touch-LCD-1.85

Hi,

I am trying to figure out how I should start. I was looking into Demo which is availabe but this has so much information which I am strugling to understand.

The device I am using is this:

Using Arduino IDE 2.3.4, how I should write a very simple program which will allow me to display a simply text in the middle of the screen?

Do I need to define something such as pins for display? I guess yes, but I have troubles to find any reference which will be simple enough to let me get familiar how to use it.

Any help will be very appriciated.

I am planning to write a tool which will have:

  • circular progress bar at the edge of the screen.
  • buttons
  • support touch screen
  • have a gyroscope/accelometer reading
  • play sound

I guess for all of these above I need to set pins but no idea how to start and which libraries I might need to make it work. Currently I have lvgl. I also read that I might need TFT_eSPI by Bodmer, but not sure in 100%.

I did deep dive search and most of the suggestions are very complex or dont work.

Ideally would be to see a very basic example of how to sets this up and make something display on the screen.

Thanks,
Bart

Your topic does not indicate a problem with IDE 2.x and hence has been moved to a more suitable location on the forum.

That is not an easy project even for somebody with experience. Go to the basics and get the blink and other example programs to compile and run first. There is a book called the Arduino Cookbook, It has lots of projects with explanations. That is what I used to learn the Arduino.

Yes, I understand this is not an easy thing to create but using demo with given files should work out of the box. From the provided files I could learn myself to strip the most interesting elements and bit by bit learn from experience.

Currently I cannot even make Demo to work. Constantly some weird issues. I learnt how to read schematics and what IO Extensions does for EXIO pins which cannot be called directly from ESP32-S3 as GPIO. So I learn every day something new but the most annoying part is that I am unable to have any working example which could provide more vaulable information which are correct. Most of the time I do something wrong but this is not described in Demo instruction. I tried two:

But yeah, I am very beginner. I used to play with Raspberry Pi, but never did anything with LCD/Display which seems to another level of knowledge.

Start with something simple. Build them and understand how they work then progress. It will take some time. Some of the demo programs are actually far from simple.

I know of nobody who is writing demo programs that is clairvoyant. Not everybody makes the same mistooks or in the same way.

I did some, such as connecting to WiFI etc. I think the problem is with IO Extension, one pin is used in LCD, I also tried today to read files on my FAT32 SD Micro Card but this card also has EXIO pin which needs to be initialized. I found the module to get it but because my card returns that it cannot be initialized / no card I do not know if somehting is wrong with how I read that EXIO pin or something is corrupted on my board. Currently I think corruption might be around TCA9554PWR IO Extension.

But when I install demo *.bin it works, so it comes that something else must be wrong.

Just would like to understand what is the correct way of reading IO Extension.

For example I have SD (TF-110) and the pin layout for it is as follow:

SD Card ESP32S3
SD_D0 / MISO GPIO16
SD_CMD / MOSI GPIO17
SD_SCK / SCLK GPIO14
SD_D3 / CS EXIO3
SD_D1 NC
SD_D2 NC

EXIO3 is on my IO Extension and it is physical pin 6 with name P2
I tried to call it as 2 from IO Extension but no luck, not sure if this is correct approach.

I used this as follow:

#include <Wire.h>
#include <SPI.h>
#include <SD.h>

#define IO_EXPANDER_ADDR  0x20  // IO Expander I2C Address (default: 0x20)
#define SD_CS_PIN         2     // SD_CS controlled by P2 (bit 2 of the IO Expander)

// SPI Pins for SD Card
#define SD_MOSI 17
#define SD_MISO 16
#define SD_SCK  14

// Function to set the IO Expander pin (CS pin for SD card)
void setIOExpanderPin(uint8_t bit, bool state) {
    Wire.beginTransmission(IO_EXPANDER_ADDR);
    
    // Read the current output state of the IO Expander
    Wire.write(0x01);  // Command to read Output Port Register
    Wire.endTransmission();
    Wire.requestFrom(IO_EXPANDER_ADDR, 1);
    uint8_t currentState = Wire.read();

    // Modify the relevant bit based on the state
    if (state) {
        currentState |= (1 << bit);  // Set the bit HIGH
    } else {
        currentState &= ~(1 << bit); // Set the bit LOW
    }

    // Write the updated state back to the IO Expander
    Wire.beginTransmission(IO_EXPANDER_ADDR);
    Wire.write(0x01);  // Command to write Output Port Register
    Wire.write(currentState);
    Wire.endTransmission();
}

// Function to list the files on the SD card
void listFiles(File dir, int numTabs = 0) {
    while (true) {
        File entry = dir.openNextFile();
        if (!entry) break;

        for (int i = 0; i < numTabs; i++) Serial.print("\t");
        Serial.print(entry.name());

        if (entry.isDirectory()) {
            Serial.println("/");
            listFiles(entry, numTabs + 1);
        } else {
            Serial.print("\tSize: ");
            Serial.println(entry.size());
        }
        entry.close();
    }
}

void setup() {
    Serial.begin(115200);
    Wire.begin();  // Initialize I2C for IO Expander
    SPI.begin(SD_SCK, SD_MISO, SD_MOSI, -1);  // Initialize SPI with custom pins for SD

    Serial.println("Enabling SD card...");

    // Set the SD_CS pin (P2) on the IO Expander to LOW (active)
    setIOExpanderPin(SD_CS_PIN, LOW);
    delay(10);  // Allow time for the pin to be set

    // Initialize the SD card using the correct CS pin
    if (!SD.begin(SD_CS_PIN)) {  // Use the SD_CS_PIN from the IO Expander
        Serial.println("SD Card initialization failed!");
        return;
    }
    Serial.println("SD Card initialized successfully.");
    
    // List files on the SD card
    File root = SD.open("/");
    if (!root || !root.isDirectory()) {
        Serial.println("Failed to open SD card directory.");
        return;
    }

    Serial.println("Listing files...");
    listFiles(root);
}

void loop() {
    // Nothing to do in loop
}

And the result is:
SD Card initialization failed!

No idea what is wrong, but I bet the problem comes from IO Extension in my case, probably I do something wrong here.

Not sure what happened but when I tried with SD card read with Demo files few hours ago it did not work. I retured to this now and plugged everything the result I received as follow:

SD card initialization successful!
SD Card Type: SDHC
Total space: 31906594816
Used space: 4521984
Free space: 31902072832

What is good, so for this I used my personal sketch ino file where I #include SD_Card.h from demo. I also added I2C_Drive.cpp, I2C_Drive.h, SD_Card.cpp, SD_Card.h, TCA9554PWR.cpp and TCA9554PWR.h. I skipped all other cpp and header files to make less complex.

I will probably focus on extracting and learning based on working code now. Maybe next I will try to figure out to do something with the screen like changing color or something what does not require extra libraries if possible just to see if I can properly comunicate with

1 Like

Thanks for letting us know!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.