TFT MCUFRIEND -moving from Arduino MEga to ESP32

I am currently using a TFT ( bellow) and Arduino Mega for my project

ID = 0x6814 (ili9486)
TouchScreen.h GFX Calibration
Testing : (A1, D7) = 34
Testing : (A2, D6) = 24
Diagnosing as:-
YP,YM: (A1, D7) = 34
XM,XP: (A2, D6) = 24
ID = 0x6814
MCUFRIEND_kbv ID=0x6814 320 x 480

My idea is to move to an ESP32. The actual sketch was created for a 320 x 480 display and I would like to keep the resolution.

Is it possible what I want ?
If Yes:
Which options do I have or what display / interface do I have to get to achieve my goal?

Regards,
mesihas

You can buy ESP32 D1 R32 board
And do the hardware mod. Google "Bodmer ESP32 TTGO hardware mod"

Ok. Done it for you: GitHub - Bodmer/TFT_eSPI: Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips

Then your Raydium RM68140 screen will run out of the box with MCUFRIEND_kbv

Bodmer supports some parallel controllers e,g. ILI9481, ILI9486, ILI9488
RM68140 is different to ILI9486 in several ways.

David.

Hi David,

Thanks again for your answer.

ESP32 D1 R32 board sounds really good, but I need to connect some other modules to the ESP like, Tiny RTC I2C, SD Card, and lot of pins for relays, etc. So if I use the display as a shield I wont get access to the pins.

Also I want to connect a MCP23S17 (16 bit SPI expansor) in order to have more IO.
Seems like I have to wire it myself? :o

DO you think is still possible to do it?

and also is this TFT ok for what I want?

SPI tft 320*480

Yes, using an SPI display is the obvious solution. It also has a hardware Touch controller.
And it even works with an ESP8266.
Bodmer’s TFT_eSPI library is impressive.

Any use of a parallel TFT wastes most of your GPIO pins.

My only criticism of that SPI display is the monster SD cage. A microSD would be much neater.

David.

David, thanks again.

"It also has a hardware Touch controller."
Does the hardware touch controller use SPI as well?

"My only criticism of that SPI display is the monster SD cage. A microSD would be much neater."
I agree 100%, I'd rather use a proper microSD module as I will have to wire it anyway.
It is hard to find a TFT that fits, on Ebay sellers don't provide a good description of the items.

Regards

The Touch Controller on the popular Red SPI displays is XPT2046.

Yes, you can run ILI9488, XPT2046, SD all on the same hardware SPI bus.
However it is "safer" to treat ILI9488 as a write-only display. i.e. don't connect the LCD_SDO pin

The ILI9341 is a smaller screen (240x320) but LCD_SDO (MISO) is well behaved.

In practice, you can use SPIFFS on the ESP32 and avoid external SD. It is surprising how many JPEG images you can fit in SPIFFS.

David.

Thanks a lot.

I went through the XPT2046 datasheet and read that the controller has other capabilities such as temperature / pressure measurement?

I'll follow the advice of treating ILI9488 as a write-only display and also will do some research on SPIFFS which I had no idea that existed..!

I am waiting for my hardware to be delivered.

Regards.

I think you will find that most Touch Controller chips can do some extra things.

Quite honestly, all you really want is the Touch function. Most makes, most models, ... all work the same.

e.g. ADS2483, ADS2486, XPT2046, ...

David.

Finally I have the TFT, pls see attached picture, according to the package is a 3.5inch SPI Module ILI9488. I read that the only way to know which controller it really has is through connecting it and running a test.

So now I need to wire it together with ES32, I went through the forum and found some posts like:

But still not sure how to wiring them. I am wondering if I should treat the TFT as any other SPI device?

cheers

It should work fine with Bodmer's TFT_eSPI library.

The XPT2046 Touch controller and SD card can go on the same SPI bus.

Omit the SDO(MISO) pin. The ILI9488 does not play cricket on the SPI bus.
XPT2046 and SD are well behaved on the SPI bus.

You can use SDO(MISO) if there are no other devices on the bus.
Or you can ask the ILI9488 to use SDI(MOSI) as a bidirectional pin if you leave SDO(MISO) n.c.

David.

Davis, thanks for all your help.

You can use SDO(MISO) if there are no other devices on the bus.
Or you can ask the ILI9488 to use SDI(MOSI) as a bidirectional pin if you leave SDO(MISO) n.c.

Not sure If I am getting this.

I have connected the display and touch to the same ISP bus (VSPI). Both working but touch a bit funny according to the test. Both display and touch share MOSI and SCLK and display is not connected to MISO as per suggestion and the touch is connected to MISO. This is my setup.

TFT_MOSI 23
TFT_SCLK 18
TFT_CS 17
TFT_DC 2
TFT_RST 4

TOUCH_MOSI 23
TOUCH_SCLK 18
TOUCH_MISO 19
TOUCH_CS 16

If I want to connect another device to the same bus, let's say the SD_card then should I do the same as I did with the touch (share MOSI, SCLK and MISO but Different CS) ?

Regards

Yes. You can connect as many SPI devices as you like. Separate CS per device.
Omit TFT_MISO from the bus.

Bodmer supports TFT, Touch and SD.

David.

Regards David.
I would like to take the opportunity to clarify a question:
I have a display like that of friend ‘mesihas’ in post # 8 and I have a sketch (attached) that uses its MCUFRIEND_kbv library but for a shield card I would like to know what I should change in the sketch to use the display mentioned in the post above, which pins should I use, if I can use your library for the intended display;
My sincere thanks,
Daniel

PS Sorry for my english (not my native language)

Graphing_Thermometer_V3_10.ino (118 KB)

It looks as if your project has:
320x480 screen
4 membrane switch buttons
DHT21 temperature and humidity sensor chip
DS3231 RTC chip

If it works with a MEGA2560 why change?

It is fairly simple to port the TFT code from MCUFRIEND_kbv to TFT_eSPI on an ESP8266 / ESP32.
But I have no idea what "droid_mono_40pt7b" font is.
You have to choose suitable GPIO pins for your external hardware.

Provide "droid_mono_40pt7b" font
Provide a valid reason for not using MEGA2560
I will show you how to port to TFT_eSPI

David.

Yes, it works with the MEGA2560 but here are two issues:

  1. To stay on the MEGA2560, I need to know which pins to plug in because it is a Display Breakout SPI, unlike the one used in the code, which is a Shield.
  2. The reason for porting to an ESP8266, for example, is that you will not need to use Level Converter on the logic pins of the display. Therefore, I prefer ESP.
    Thank you for your help,
    Daniel

It appears to be a project from https://www.nutsvolts.com/magazine/article/build-the-graphing-thermometer

It all fits together quite nicely on the MEGA2560. The Shield plugs straight in. The I2C, DHT, push buttons all fit nicely on the MEGA2560.

I had a swift look at the code earlier. It is fairly simple to use the TFT_eSPI methods except for the
tft.getTextBounds()

If the author had put the "text drawing" code in one helper function, you just use the TFT_eSPI() font drawing code instead of messing about with the GFX methods to draw text with background.

David.

Yes, this is the site you mentioned.
Ok but, as I told you, it sure works with MEGA2560 but my Display is not Shield but Breakout SPI as in the photo from post #8 (3.5inch SPI Module ILI9488.jpg) and so the pins are different so I plan to use it with same MEGA2560 but with Breakout SPI pins or use it with ESP8266 but I am not knowledgeable enough to adapt the sketch and use the TFT_eSPI library.

Daniel

I suggest that you buy the shield. It plugs into the MEGA2560.

Yes, I can simply change the include and constructor for my ST7789_kbv library. It uses exactly the same methods as MCUFRIEND_kbv

However this would require you to wire up the ESP32 or ESP8266 correctly.

It is "harder" to use TFT_eSPI because the methods are slightly different. Not only do you have to wire correctly, you also have to adapt the sketch code.

Much simpler to follow the Nuts and Volts project. Use their recommended components. After all, this is a "one-off" project. Build once and use forever.

David.

Oh, if you make yourself available and do it for me, I would definitely be using ESP32 or ESP8266.

Would you have the kindness to adapt directly to the sketch I sent you?

Otherwise, I would buy the Shield and plug in the Mega2560;

Once again, thank you very much,

Daniel

Hi David
I want to remind you that the board I have is the Arduino Mega Pro Mini (small board), so I can't fit the shield display.