Library for mcufriend 3.5" TFT with 16 bit interface

I bought a 3.5" TFT a while ago that was advertised as having an ILI9481 driver and touch screen. As is typical of Chinese vendors the display that arrived did not exactly match the advert photos and the PCB is marked as having an ILI9488 driver.

As I could not quickly get it going it ended up being put aside for many weeks until I could spare some time to investigate.

By trying various setups I found that it had an ILI9486 driver (so advert and PCB marking is wrong!) and needed quite slow write strobes so that the logic signals get through the 10K logic level protection series resistors on the back of the display. If the write strobe is too fast the display remains white even when the correct driver is used.

This is the display I have, the vendor advert has gone now.

To get a good performance with a Mega I have updated my library here so that it can be used with the ILI9486 driver. The library originally only supported HX8357B and HX8357C drivers hence the naming oddity. It also supports the ILI9481 driver.

The display now works fine :slight_smile:

I haven't tried the touch screen yet but the display is fitted with an XPT2046 so this should be straightforward.

Thanks bodmer. Works with my mega2560 and ILI8486 3.5"' shield. Only Issue so far is my BMP's are upside down.

Ah! I did not test that... I will have to find a spare microSD card to try and then fix that problem.

In the meantime, if you use Windows then it is possible to load the image into Paint and save it upside down. Then at least it should get rendered correctly!

Hello bodmer

First thank you for sharing your library.

I bought a TFT LCD similar to yours (3,6 Zoll TFT LCD-Touchscreen-Modul für Arduino Mega2560 3651857 2022 – €27.59). It works with ILI9481, ILI9486 and R61581 (following Henning Karlsen's UTFT). The PCB has an XPT2046 on it.
I tried your library but the image is mirrored. In Henning's library I could fix it changing the Memory Access Control (0x36) from 0x0A to 0x4A and the image was OK. So I changed the value in your library but it didn't help - it is still mirrored.
I also tried to get access to the touch screen with your library TFT_touch. I used your modified TFT_HX8357 for ILI9486 and run the example TFT_Touch_Calibrate_v2.
The message on the display still is mirrored and touching the display on the cross has no effect. Without touching anything, after a few seconds, I get the following message on the serial monitor

TFT_Touch Calibration, follow TFT screen prompts..
First point : Raw x,y = 289,2628

The first lines of your code I changed are:

// TFT Screen pixel resolution in landscape orientation, change these to suit your display
// Defined in landscape orientation !
#define HRES 480
#define VRES 320

// Call up the TFT driver library
#include <TFT_HX8357.h> // Hardware-specific TFT library
#include <SPI.h>

// Call up touch screen library
#include <TFT_Touch.h>

// Invoke custom TFT driver library
TFT_HX8357 tft = TFT_HX8357(); // Invoke custom library

// These are the pins I used to interface between the 2046 touch controller and Arduino Mega
// they can be changed to other digital pins

#define DOUT A0 /* Data out pin (T_DO) of touch screen /
#define DIN A2 /
Data in pin (T_DIN) of touch screen /
#define DCS 9 /
Chip select pin (T_CS) of touch screen /
#define DCLK 8 /
Clock pin (T_CLK) of touch screen */

Running the example TFT_Touch_Raw and pressing the touch in its middle give the following (strange) results:

Raw x,y = 1,2464
Raw x,y = 2,2437
Raw x,y = 7,2502
Raw x,y = 3,2333
Raw x,y = 5,2330
Raw x,y = 5,2328
Raw x,y = 1,2320
Raw x,y = 2,2328
Raw x,y = 7,2470
Raw x,y = 3,2335
Raw x,y = 6,2317
Raw x,y = 4,2246
Raw x,y = 3,2437
Raw x,y = 4,2330
Raw x,y = 3,2432
Raw x,y = 367,2587
Raw x,y = 359,2526

So now I'm doubting if the touch (not the screen) is broken or I'm to stupid to make the touch work.

Hope you can help me

Sorry, I forgot to mention that I'm using the TFT on an Arduino mega 2560.


I checked the resistances on the XPT2046 between XP/XN and YP/YN and found that only YP/YN gives a value on the multimeter. So I disassebled the whole screen and soldered the flat cable of the touch again to the PCB. After reassembling everything worked fine (display was still mirrored). I had to disassemble it again because I had to put gluepads for fixing the Screen on the PCB. And again the touch didn't work. So I assume there must be a tiny crack on the flat cable that opens and closes depending on its position.

I'll buy a new TFT touch and check all again.


Well done for finding the root cause, this stacks up with the raw touch coordinate results where x is stuck at a low value.

It is possible to fix the mirroring by changing some control register bits. When you get the new screen post back and we will see if it behaves the same with the mirroring, sometimes a replacement screen is fitted with a different driver!