I have problems to use my tft screen 2.4 - ILI9342, help me please !


I am sorry for my poor english.

It is with http://www.ivydene1.co.uk/TFT-reg-read.ino
I got ID register of my screen.

TFT LCD test - Read of the ID register
Dummny Byte Read = 0
2nd Parameter Byte Read = 0
3rd Parameter Byte Read = 93
4th Parameter Byte Read = 42
Now I know my screen is an ILI9342.

ILI9341 is for screen 240 x 320 pixels (WxH) datasheet
ILI9342 is for screen 320 x 240 pixels (WxH) datacheet

I do not find one library for ILI9342.

I tryed a lot of libraries for ILI9341, none works, except maybe one.

I say maybe because :

  • colors are inverted, black is 0xFFFF and wite 0X0000 , rgb565.
  • texte is miroired and biggining from right side
  • portrait screen is displayed and splited in lanscape screen or lanscape screen is diplayed and splited in portrait screen

This library "SPFD5408-master.zip" for ILI9341 come from GitHub - JoaoLopesF/SPFD5408: Adafruit Libraries changed to works in TFT 2.4 shields with the SPFD5408 controller for Arduino Uno and Mega (Discontinued library)

Today, datasheet are too technical for me understanding their.

Can you help me :

  • finding library working well
  • understanding datasheet
  • explain me how and where change something in witch files from SPFD5408-master.zip ?

Thank you very much.

[edit] : tft.setRotation(x) just turn picture but not resolve problem display

The sketch implies the pinout wiring of a Red MCUFRIEND shield.

Install MCUFRIEND_kbv with the Library Manager.

Edit the graphictest_kbv.ino sketch:

Force the ID in setup() with tft.begin(0x9341);

Please tell me exactly which colours, directions, scrolls are wrong.

If you give me an accurate report, I will add support for your ILI9342.


Thank you David for your answer.

I clear my libraries folder.

I donwload and install GitHub - prenticedavid/MCUFRIEND_kbv: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields.

I add Adafruit_GFX library.

I edit the graphictest_kbv.ino sketch (Line 97) to force the ID in setup() with tft.begin(0x9341).

In serial table I read
Serial took 0ms to start
ID = 0x9342

I have the same problem than library "SPFD5408-master.zip" , but graphictest_kbv.ino is faster and better graphical.

I made a video (2 minutes) because I think it is better than my poor english.

In blue it is my usb cable and I light it to see screen orientation.

I run also LCD_ID_readreg

Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

reg(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x000A) 00 08 Get Power Mode
reg(0x000C) 00 06 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 RDID2 HX8347-G
reg(0x0063) 00 00 RDID3 HX8347-G
reg(0x0064) 00 00 RDID1 HX8347-A
reg(0x0065) 00 00 RDID2 HX8347-A
reg(0x0066) 00 00 RDID3 HX8347-A
reg(0x0067) 00 00 RDID Himax HX8347-A
reg(0x0070) 00 00 Panel Himax HX8347-A
reg(0x00A1) 00 00 00 00 00 RD_DDB SSD1963
reg(0x00B0) 00 40 RGB Interface Signal Control
reg(0x00B4) 00 02 Inversion Control
reg(0x00B6) 00 0A 02 1D 04 Display Control
reg(0x00B7) 00 06 Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00 ILI9481, HX8357-B
reg(0x00C0) 00 26 09 09 09 09 09 09 09 Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA
reg(0x00CC) 00 3A Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 03 03 NVM Read
reg(0x00D3) 00 00 93 42 ILI9341, ILI9488
reg(0x00D4) 00 00 00 00 Novatek ID
reg(0x00DA) 00 00 RDID1
reg(0x00DB) 00 00 RDID2
reg(0x00DC) 00 00 RDID3
reg(0x00E0) 00 0F 29 1E 06 0F 09 5A 86 3F 06 1C 04 13 0E 00 GAMMA-P
reg(0x00E1) 00 00 20 23 02 10 04 3E 20 43 01 0B 0B 31 33 0F GAMMA-N
reg(0x00EF) 00 00 00 00 00 00 ILI9327
reg(0x00F2) 00 00 00 00 00 00 00 00 00 00 00 00 Adjust Control 2
reg(0x00F6) 00 01 00 00 Interface Control

My apologies. I had an ILI9342 datasheet on my PC but had never actually read it !

The 9342 is 320x240 as opposed to most 240x320 (Portrait) like 9341.

Please add this case block to the begin() method. And use the regular virgin graphictest_kbv sketch.

    case 0x9342:
        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | READ_24BITS;
        static const uint8_t ILI9342_regValues[] PROGMEM = {     //CPT 2.4"
            (0xB9), 3, 0xFF, 0x93, 0x42, //[00 00 00]
            (0xC0), 2, 0x1D, 0x0A,    //[26 09]
            (0xC1), 1, 0x02,          //[10]
            (0xC5), 2, 0x2F, 0x2F,    //[31 3C]
            (0xC7), 1, 0xC3,          //[C0]
            (0xB8), 1, 0x0B,          //[07]
            (0xE0), 15, 0x0F, 0x33, 0x30, 0x0C, 0x0F, 0x08, 0x5D, 0x66, 0x4A, 0x07, 0x13, 0x05, 0x1B, 0x0E, 0x08,
            (0xE1), 15, 0x08, 0x0E, 0x11, 0x02, 0x0E, 0x02, 0x24, 0x33, 0x37, 0x03, 0x0A, 0x09, 0x26, 0x33, 0x0F,
        table8_ads = ILI9342_regValues, table_size = sizeof(ILI9342_regValues);   //
        p16 = (int16_t *) & HEIGHT;
        *p16 = 240;
        p16 = (int16_t *) & WIDTH;
        *p16 = 320;

Untested. I do not have your Display.

I always call the vertical Scroll aspect "Portrait".
The BLUE Band screen will be short and Wide. And scroll up and down.

Please post a new video. The colours may be inverted and directions wrong.
I will probably need to change attributes e.g. REV_SCREEN.


Thank you David for your answer.

I am sorry but I do not understand where you want I add the case block to the begin() method, in witch file ?

Sorry. Edit the MCUFRIEND_kbv.cpp file with a regular editor. Save it back to disk.

With this added "case block", the library should recognise your ILI9342 and behave 100%.


Thank you David for your answer.

I put in MCUFRIEND_kbv.cpp your block case 0x9342 just after block case 0x9341: (line 2121)
I am surprise block case 0x9342 is shortest than block case 0x9341.

About result, I see it is better about size and oriention. That is all !
Color are reversed and texte mirored.

If I write tft.invertDisplay(true); at top of block loop in graphictest_kbv, colors are good !

Now new video is uploading to vimeo ... please wait ...
one hour later : VID_20170430_170508 on Vimeo

Please replace your previous block with:

    case 0x9342:
        static const uint8_t ILI9342_regValues_CPT24[] PROGMEM = {     //CPT 2.4"
            (0xB9), 3, 0xFF, 0x93, 0x42, //[00 00 00]
            (0xC0), 2, 0x1D, 0x0A,    //[26 09]
            (0xC1), 1, 0x02,          //[10]
            (0xC5), 2, 0x2F, 0x2F,    //[31 3C]
            (0xC7), 1, 0xC3,          //[C0]
            (0xB8), 1, 0x0B,          //[07]
            (0xE0), 15, 0x0F, 0x33, 0x30, 0x0C, 0x0F, 0x08, 0x5D, 0x66, 0x4A, 0x07, 0x13, 0x05, 0x1B, 0x0E, 0x08,
            (0xE1), 15, 0x08, 0x0E, 0x11, 0x02, 0x0E, 0x02, 0x24, 0x33, 0x37, 0x03, 0x0A, 0x09, 0x26, 0x33, 0x0F,
        static const uint8_t ILI9342_regValues_Tianma23[] PROGMEM = {     //Tianma 2.3"
            (0xB9), 3, 0xFF, 0x93, 0x42,
            (0xC0), 2, 0x1D, 0x0A,
            (0xC1), 1, 0x01,
            (0xC5), 2, 0x2C, 0x2C,
            (0xC7), 1, 0xC6,
            (0xB8), 1, 0x09,
            (0xE0), 15, 0x0F, 0x26, 0x21, 0x07, 0x0A, 0x03, 0x4E, 0x62, 0x3E, 0x0B, 0x11, 0x00, 0x08, 0x02, 0x00,
            (0xE1), 15, 0x00, 0x19, 0x1E, 0x03, 0x0E, 0x03, 0x30, 0x23, 0x41, 0x03, 0x0B, 0x07, 0x2F, 0x36, 0x0F,
        static const uint8_t ILI9342_regValues_HSD23[] PROGMEM = {     //HSD 2.3"
            (0xB9), 3, 0xFF, 0x93, 0x42,
            (0xC0), 2, 0x1D, 0x0A,
            (0xC1), 1, 0x02,
            (0xC5), 2, 0x2F, 0x27,
            (0xC7), 1, 0xA4,
            (0xB8), 1, 0x0B,
            (0xE0), 15, 0x0F, 0x24, 0x21, 0x0C, 0x0F, 0x06, 0x50, 0x75, 0x3F, 0x07, 0x12, 0x05, 0x11, 0x0B, 0x08,
            (0xE1), 15, 0x08, 0x1D, 0x20, 0x02, 0x0E, 0x04, 0x31, 0x24, 0x42, 0x03, 0x0B, 0x09, 0x30, 0x36, 0x0F,
        table8_ads = ILI9342_regValues_CPT24, table_size = sizeof(ILI9342_regValues_CPT24);   //
        //        table8_ads = ILI9342_regValues_Tianma23, table_size = sizeof(ILI9342_regValues_Tianma23);   //
        //        table8_ads = ILI9342_regValues_HSD23, table_size = sizeof(ILI9342_regValues_HSD23);   //
        p16 = (int16_t *) & HEIGHT;
        *p16 = 240;
        p16 = (int16_t *) & WIDTH;
        *p16 = 320;

This should give you the correct functionality. i.e. colours and directions.

When you are happy with the functionality, uncomment/comment the table8_ads statements. Report back with "which one looks most stable".


Thank you David for your answer.

Wahow ! It is great !

Before testing uncomment/comment the table8_ads statements can you make a video of 0x9341 working fine for you ?

It is for compare with mine, because somewhere I not sure about result.
I think some lines of pixels are wrong, but it is my first screen, I am not sure.

I am so happy !

I will try your others examples from your library.

I test screen tactile ...

UTouch_Calibr_kbv sreen have good colours and texts directions (title white on background red).

But I cannot press the cross top/left

I change
and screen is in PORTRAIT mode

But I cannot press the cross top/left

By moving finger on screen, target change place, but never when I am on cross.

TouchScreen_Calibr_kbv screen have good colours and texts directions (title white on background red).
no reaction with stilus.

Touch_shield_kbv screen have good colours and texts directions (EXIT in red on background black).

Found unknown LCD
Screen is 320x240
Callibration is:
LEFT = 920 RT = 150
TOP = 940 BOT = 120

Wiring is: PORTRAIT
YP=15 XM=16
YM=7 XP=6

Please see this video about problem painting

testcard_kbv is very nice, but in PORTRAIT and I am in LANSCAPE
serial table show
TFT ID = 0x9342

Use diagnose_touchpins sketch to find the pins. I call the long dimension Y because most people have Portrait controllers.

Since your controller is 320x240 you will need to select rotation #0 for examples written for Landscape (#1). Most examples adjust for the geometry but Testcard is written specifically for 320x240.

Yes, you will need to edit programs to match your rotation and touch geometry.

No, I have never taken a video. Many users have posted videos.
I would expect all the table8 settings to work. But some will look better than others.

Regarding Gamma. Photos of a known female face are best for determining accurate colours. Avoid orange people from Essex. They always look wierd.


OK !

Beacause I want use tactile menu in my project, can you explain me how can synchronizeI stilius and x,y values ??

First off. Diagnose the Touch pins.
Draw a pencil sketch of your screen and Touch directions.

Read the Touch_shield_kbv example.
Map the Touch return values to the X,Y coordinates on your screen.

Read the (many) replies about Touch.

If you report back with your Touch diagnosis and the program you want to run, someone might show you how to do it.

I would appreciate some feedback for the Power setting of your screen. i.e. best "table8"

Sorting out your Touch directions will give you brain-ache if you try to do it in your head.
Invest in a pencil and a cup of tea. Solved in seconds.


As soon as I say you with table8 I prefer but before I need transform picture 8Mo to 620x240 pixel RGB565 and understand how read picture from sdcard and view it on sceen.

I am newbie in arduino, 30 years ago I learn C (not C++) and COBOL during 2 month. POO does not exist ...

I have pencil and rubber, I will buy tea, cup for tea and lexomyl...

I would have thought that a mature person would own a mug or cup of some description.
lexomyl seems to be either a pop group or an anti-depressant pharmaceutical.

You can use IrfanView or Paint to convert between GIF, JPEG, PNG, BMP, ... of any size to a 320x240 BMP file.

If it is on SD card, size is no problem. There are many programs to render a 24-bit BMP on a TFT.

Use SD.h with a Uno. Disable the 8-bit support in my example if you are on a Uno. The Palette uses too much stack.

When you want to render a 320x240 or a 240x320, change the rotation to match.


I am a single man and I do not drink coffee or tea (no cup or mug).
Fruit juice each morning and water, no alchool.
Lexomyl it is a joke !
I leave in montain.

For my project, I want an tactile menu for choice to diplay just one or one after one :

inclinometer : something like this

  • in one picture false 3D or car in perspective see from back
  • or if it is too difficult

GPS position , altitude and compass
Record my path on SDcard

date time and temperature in/out

IMAX 3D and THX sound

When I bought all that I need, I thank uno was enought, execpt for 4) , of course ...
Size 240x320 is perfect for my car.

I received furniture 3 weeks ago and I cannot begin my project because stopped before begining by problems with screen.
I do not know if finally I can use/adapt other skecht for helping me or if I need to create each all because of the screen ...

2 weeks 1/2 later my question I receive today an answer from vendor :
Hi dear,
Thanks for you contact with us. the main chip of this display shield is ili9342 or ili9341, it will working ok, just some difference with the touch. we not supply the driver for it.

You can probably fit two inclinometer graphics in one screen. You need to design the appearance of every screen and how you want to select them. e.g. how much information. how easy to read the onformation.
Graphics are easier to view than numbers.

The difficulty is with extra Sensors. Your Shield uses almost all of the GPIO pins on your Uno.

I could never consider life without tea.


2 weeks 1/2 later my question I receive today an answer from vendor :
Hi dear,
Thanks for you contact with us. the main chip of this display shield is ili9342 or ili9341, it will working ok, just some difference with the touch. we not supply the driver for it.

You are right !
Your life and mine are out off topic. It will not interest readers with the same problem, receive ILI9342 instead of ILI9341

In the beginning I thought you would take advantage of my misfortune to associate my inexperience with your knowledge to improve your excellent work and complete MCUFRIEND_kbv

Now I am trying to understand how work uno, how are writted *.h and *.cpp to transform your help to an "universel translater ILI9341 to ILI9342 driver" for other sketch adafruit work fine...

Arduino is a friendly community, when I will have finished my project, I write an "howto" and it is better if my program work on ILI9342 and ILI9341. If it is specific, nobody benefit.
Before, if I need help about graphic, it is more easyer if my sketch are "universel" and not specific to my screen.

About my project, screen, uno and sensors are not in same place, many wire connect then (in shielded multi-core cable), like on bread board (not received today)

about 1) of my project I should want some thing like this on my ILI9342

with a car (mine dranwed ?) and not a plane ...

It makes no difference whether you have ILI9341 or ILI9342 except for the Vertical Scroll feature. Very few apps use this feature. In fact, I think that only my libraries cater for it.

So you can take any regular TFT sketch. It will be the same for any TFT controller.

Just exchange Landscape and Portrait i.e. the setRotation() method is normally called just once in setup().

It is only Demo programs that change rotations more than once.

Yes, you can render the gyroscope image on your TFT just like the video.