Go Down

Topic: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields (Read 277713 times) previous topic - next topic


Hi again David,

Huge thanks for putting up the test_8357_99 branch on GitHub - it has solved all my problems with this TFT.

Photos look good, image/colour retention is fixed, all your example scripts work fine (with some minor tweaks), and yes - it's reported as ID 0x99.
You must use the special LCD_ID_readreg sketch to "unlock" the HX8357 registers.   Look at Phaedra's posts.

I will wait to hear from Phaedra about the Gamma settings.   I would prefer to avoid the long sequence if possible.

I am impressed that you managed to install the "branch" ok.




Thanks, with your sketch touch work fine!

When you run graphictest_kbv yse i have smooth green colour band so all works fine, thanks again.


Hi David,

Here's the output from the modified register sketch, looks more sensible to me:

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(0x000A) 00 08tGet Power Mode
reg(0x000B) 00 00tGet Address Mode
reg(0x000C) 00 06tGet Pixel Format
reg(0x000D) 00 00tGet Display Mode
reg(0x000E) 00 00tGet Signal Mode
reg(0x000F) 00 00tGet Diagnostic Result
reg(0x00A1) 00 00 00 00 00 FFtRD_DDB Start
reg(0x00B0) 00 66 00tSETOSC
reg(0x00B1) 00 00 11 1B 1B 83 77 2FtSETPOWER
reg(0x00B2) 00 00 83 3B 00 20tSETDISPLAY
reg(0x00B3) 00 00 00 06 06tSETRGB
reg(0x00B4) 00 02 40 00 2A 2A 0D 96tSETCYC
reg(0x00B5) 00 0B 0B 66tSETBGP
reg(0x00B6) 00 4B 00tSETCOM
reg(0x00B7) 00 00 00 00 00 00tSETOTP
reg(0x00B9) 00 FF 83 57tSETEXTC
reg(0x00C0) 00 73 50 00 3C C4 08tSETSTBA
reg(0x00C1) 00 00 00 08 10 18 20 28 30 38 40tSETDGC
reg(0x00C3) 00 00 80 00 00tSETID
reg(0x00C4) 00 00 00 00 00tSETDDB
reg(0x00C9) 00 0F 82tSETCABC
reg(0x00CC) 00 00tSETPANEL
reg(0x00D0) 00 99 00 00tGETICID
reg(0x00E0) 00 0B 0C 11 1D 25 37 43 4B 4E 47 41 39 35 31 2E 21 1C 1D 1D 26 31 44 4E 56 44 3F 39 33 31 2E 28 1D E0 01tSETGAMMA
reg(0x00E9) 00 00tSETIMAGEI
reg(0x00EA) 00 02tSETMESSI

I don't know why I've got those 't's appearing after the register values. I'm on linux, does that make any difference?

Any questions, just ask...



I suspect that there is a Tab character and not a Space.
On Windoze you see a space.

The Arduino Terminal is not very clever.    But it does let you copy-paste easily.



Just had a play with MCUFRIEND_kbv-test_8357_99 and it looks good on my HX8357D. As a test I commented out the 34 byte gamma setting and to my eye I couldn't tell the difference.


Copy a whole load of photos as 320x480 BMP files to a microSD.   And also to your PC.

Run a showBMP sketch on the TFT.  Compare with the  same BMP photos on the PC.

Some default gammas are horrible.   Most are good enough for photos.    You can always tweak at runtime for a photo frame program.



Comparing the PC to the LCD - without the explicit gamma the images look a bit washed out, not terrible, but not as good as with gamma being explicitly applied.



i am a little bit confused, about the touchscreen when using an arduino due,
does it work or not?

i tried it a bit, but it seems it has problems :/

The alternative solution for my project would be, that i use one of my arduino uno´s, but i need 1 pin for PWM, at least 2 pins for an ESP8266 and i2c.

but the uno, does not suit me, in terms of speed...

also when i use the due, i also can connect an ov7670 an do some stuff with the camera...

so, is there an working solution for touch and display with the due?


An ESP8266 has not got enough pins for running a parallel TFT.
Uno Shields are designed for a Uno.    If you are not using the microSD,  you can use D10..D13.   A5 is available for Analog.    I2C is not available on a Uno because A4 is used for LCD_RST.

My Touchscreen_kbv (as used in TouchScreen_Calibr_native sketch) works with Zero, Due, STM32, Teensy, ESP32.    You probably need to detect a "pressed" with p.z > 200

Most TouchScreen.h libraries only work with AVR.

If the Uno Shield does not suit you,   you can always buy a different display and different library.



i know that the esp is not able to control an parallel display, i mean i need at least 2 pins to communicate with him

hm i think i know how i get sd card support and i2c

software i2c on d10 and d11, communication with esp on d12 and d13 and then connecting the sd card to the esp, as all values my sensors harvest will be transmitted to the esp

shouldn´t the adafruit touchscreen.h work for the due?

yeah i could, but the uno shield was bought a long time ago, so it would be nice, if it gets a final usage :D


Hi David,

I'd just like to confirm Phaedra's most recent comment above about display quality without the 34 byte gamma. Most people would probably be happy enough with it removed but when I compare it to my colour calibrated PC screen it looks decidedly dull and washed-out.

Conversely, with the full 34 byte gamma, it is very similar to the colour calibrated screen.

As a photographer, I know which version I'll be using!

Cheers and thanks again for the help,

Edit #1: corrected an ambiguity.
Edit #2: the LCD display on my example of this has amazingly good viewing angles! It's best 'straight-on' but it holds up extremely well in every direction and only really fails when you're about 15 degrees away from 'side-on'.


Hi community,

I have several mcufriend LCD shields and cannot get one of them working. I've done the diagnostics included in the mcufriend library (most current version on github). It says that it is unsupported and suggests that I modify the .cpp and other _shield and/or _special.h files.

Here's the thing ... it appears to be supported but untested in the .cpp file. I've uncommented related #define statements and have searched through all of the other suggested library files. No luck yet. I'm guessing I need to define registers and pin assignments but could not locate anywhere to edit them.

My diagnostics data for this shield is below and any help would be greatly appreciated!!!  This shield looks to be a ILI9341, ILI9488 variant ... and it seems that #define SUPPORT_8347A along with #define USE_SPECIAL should do the trick but did not.


Diagnose whether this controller is supported
There are FAQs in extras/mcufriend_how_to.txt

tft.readID() finds: ID = 0x8347

MCUFRIEND_kbv version: 2.9.8

This ID is not supported
look up ID in extras/mcufriend_how_to.txt
you may need to edit MCUFRIEND_kbv.cpp
to enable support for this ID
e.g. #define SUPPORT_8347D

New controllers appear on Ebay often
If your ID is not supported
run LCD_ID_readreg.ino from examples/
Copy-Paste the output from the Serial Terminal
to a message in Displays topic on Arduino Forum
or to Issues on GitHub

Note that OPEN-SMART boards have diff pinout
Edit the pin defines in LCD_ID_readreg to match
Edit mcufiend_shield.h for USE_SPECIAL
Edit mcufiend_special.h for USE_OPENSMART_SHIELD_PINOUT

Register Data:

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) 3F 3F 3F 3F 3F   Status Register
reg(0x000A) 00 00   Get Power Mode
reg(0x000C) 01 01   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) 80 80   RDID2 HX8347-A
reg(0x0066) 00 00   RDID3 HX8347-A
reg(0x0067) 47 47   RDID Himax HX8347-A
reg(0x0070) 06 06   Panel Himax HX8347-A
reg(0x00A1) 00 00 00 00 00   RD_DDB SSD1963
reg(0x00B0) 00 00   RGB Interface Signal Control
reg(0x00B4) 00 00   Inversion Control
reg(0x00B6) 00 00 00 00 00   Display Control
reg(0x00B7) 00 00   Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00   ILI9481, HX8357-B
reg(0x00C0) 00 00 00 00 00 00 00 00 00   Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 00 00   Power Control
reg(0x00D2) 00 00 00 00 00   NVM Read
reg(0x00D3) 00 00 00 00   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 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   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 00 00 00   Interface Control


Thanks for the report.   Yes,  it looks like you need USE_SPECIAL and SUPPORT_8347A

Please edit your MCUFRIEND_kbv.cpp:
Code: [Select]

#ifdef SUPPORT_8347A
    case 0x8347:
        _lcd_capable = REV_SCREEN | MIPI_DCS_REV1 | MV_AXIS;
        is8347 = 1;

Then run the diagnostic again.   It should say "supported".
Run the graphictest_kbv sketch and make notes.   It should have correct colours, directions, scrolling, ...

I have never seen an HX8347-A.   I rely on your feedback.


Go Up