Mcufriend 2.8 inch tftlcd for arduino Mega2560(8347i) usage

My first contribution to the Arduino community.

Edit: Removed SdFatSoftSpi from the showBMP_not_Uno.ino example, no need for Software SPI due the fact that this shield uses the hardwired SPI pins from the Mega2560 (MISO = 50, MOSI = 51, SCK = 52) and does not share them.
Link to the Himax 8347-I datasheet:
Himax 8347-I Datasheet: https://drive.google.com/

Still looking for which pin to control BackLight.

I bought this shield cheap on AliExpress:

It has the XPT2046 touchsceen controller chip on it (top-right) but has voltage regulator AMS1117 (down-left) missing, this seemed not to be a problem to get the shield fully working.

Front of the shield

Information about is was difficult to find, but specificaly this thread helped:

This is what I finally found:

Mcufriend 2.8 inch tftlcd for arduino Mega2560(8347i)
TFTLCD controller: Himax 8347i (compatible with 8347D)
non-readdable / write-only (identifier: 0xD3D3)
actual identifier: 0x9595
Touchscreen controller: XPT2046

Pin usage:

Shield Mega2560v3

JP2 (36 pins)
SD card
SD CS 53 SD Chip Select goes to Digital 53
SD MISO 50 SD Master Input Slave Output goes to Digital 50
SD MOSI 51 SD Master Output Slave Input goes to Digital 51
SD SCK 52 SD Serial Clock goes to Digital 52

TFT Himax 8347i
TFT CS 40 TFT Chip Select goes to Digital 40
TFT CD 38 TFT Command/Data goes to Digital 38
TFT WR 39 TFT Write goes to Digital 39
TFT RD 43 TFT Read goes to Digital 43
TFT RESET 41 TFT Reset goes to Digital 41

JP3 (8 pins)
TouchScreen XPT2046
TS DCLK 6 TS Digital Clock goes to Digital 6,
TS CS 5 TS Chip Selectgoes to Digital 5,
TS DIN 4 TS Digital In goes to Digital 4,
TS DOUT 3 TS Digital Out goes to Digital 3,
TS PENIRQ 2 TS PEN Interrupt ReQuest goes to Digital 2

JP4 (6 pins)
used for powering the shield

These libraries I am using

When using the MCUFRIEND_kbv library, you must edit some files in it:
mcufriend_kbv.cpp:
#define SUPPORT_8347D

mcufriend_shield.h:
#define USE_SPECIAL

mcufriend_special.h:
#define USE_MEGA_16BIT_SHIELD

And since this shield is write-only, you MUST force the ID in EVERY sketch:
tft.begin(0x9595); //HX8347-I

When using the arkejan/UTFT library (other UTFT libraries must be (temporarly) removed from the Arduino IDE libraries folder), you invoke the screen with:
UTFT myGLCD(HX8347I, 38, 39, 40, 41);

When using the URTouch library, you invoke the touchscreen with:
URTouch myTouch( 6, 5, 4, 3, 2);
First run the URTouch_Calibration.ino to calibrate the touchscreen and follow the onscreen directions to the letter. This was important to get the other examples working.

SD card works and uses HW pins with the greiman/SdFat library (but you need to edit the SD_CS in the showBMP_not_Uno.ino file (in the example folder of the MCUFRIEND_kbv library) from SD_CS 10 to SD_CS 53)

I have attached the URTouch & MCUFRIEND_kbv libraries they are already edited and in the examples folder are only the ones that worked for me. If you need more examples, DL the libraries from their Github repositories and edit them yourself.

YouTube clips of the working examples:
MCUFRIEND kbv graphictest kbv : https://youtu.be/cmZv8vEwR_8
URTouch ButtonTest : https://youtu.be/By8wzRa0RpY
Arduino_TFT_Tutorial_Example_01 : https://youtu.be/fqIks10n-_s , which comes from here: http://howtomechatronics.com/tutorials/arduino/arduino-tft-lcd-touch-screen-tutorial/

Arduino_TFT_Tutorial_Example_01.zip (6.53 KB)

MCUFRIEND_kbv-edited.zip (72 KB)

URTouch-edited.zip (411 KB)

1 Like

thanks for sharing.

Thanks for an excellent write up. I got the same 2.8 TFT/Touch/SD display from Ali express. Followed your post and was able to get it up running. Thanks