ESP32-S3 Display and Arduino MEGA 2560 Data Logging

Specific ESP32 Board: Waveshare ESP32-S3 Touch LCD 7inch Display

I'm trying to make a project wherein the arduino MEGA is the main controller of the components and sends data to the ESP32 display via UART connection. the data will be logged in the SD card installed in the ESP32 display. Can someone help guide me in making the code?

have a read of how-to-get-the-best-out-of-this-forum
in particular

  1. describe the overall project in more detail, e.g. what devices are connected to the Mega and ESP32
  2. how much data do you intended to transfer and how often
  3. what test programs have you implemented so far
  4. upload a wiring diagram?
  5. why not dump the Mega and use the ESP32 as the main controller and display?

have a look at serial-communication-arduino-mega-and-esp32

have a look at esp32-c3-micro-sd-data-logging

the Waveshare ESP32-S3 Touch LCD 7inch Display has a number of interfaces you could use to transfer data from the Mega, e.g. CANbus, RS485 and I2C

probably you could use the I2C GPIOs (8 and 9) for TTL serial which would be the simplest way to transfer data from the Mega - remember the Mega uses 5V logic the ESP32 3.3V logic
I have used the I2C GPIOs on the Freenove_ESP32_Displays for TTL serial

have a look at record-and-replay-can-communication-in-vehicle for an example of logging Canbus data (at 500kbits/second) to a file on SD card