Introduction: Cheap TFT 2.2 Inch Display on Arduino (ILI9340C or ILI9341)

I ordered a 240 x 320 pixel 2.2 inch TFT LCD display off of ebay for £3.86 which is dirt cheap compared to similar displays from some of the western companies. The only problem was that there wasn't a guide to how to get it working! When I figured it out I thought I'd make an Instructable for anyone with the same issues. It actually turned out to be quite simple. This tutorial doesn't show you how to use the SD card functionality.

The Ethics:
A couple of users have complained that I am using adafruit libraries and I am not supporting adafruit. I'd like to point out that adafruit provide their libraries under The MIT License, which amoungst other things says:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute...

You can look up the entire license if you are interested.

I understand this to mean that adafruit are perfectly happy for their code to be edited to drive cheap chinese displays, and there is no point going to the effort of writing my own code to drive it. If you have an issue with the ethics, I'd like to point out that my behavior is perfectly legal so please keep your rant elsewhere. Thankyou.

Step 1: Parts List

2.2" Serial 240x320 SPI TFT LCD Module Display ILI9340C

An Arduino compatible microcontroler - I use a Breadboard Arduino

Something to convert to 3.3V logic - I power my breadboard Arduino with 3.3V

My setup is a little like this although I ordered my components separately.

Step 2: Install the Correct Libraries

Luckily for us, Adafruit have a very similar display that they have written libraries for. I have the display which is powered by the ILI9340 driver so I installed that library so I assume if you have a display with the ILI9341 driver it works exactly the same with the other library that I linked. I haven't seen any other drivers used but if you do, I recommend searching the Adafruit libraries on github.

You also need to install the Adafruit GFX library regardless of what driver the display uses.

Instructions on how you do this are on the github pages linked.

https://github.com/adafruit/Adafruit-GFX-Library

https://github.com/adafruit/Adafruit_ILI9340

https://github.com/adafruit/Adafruit_ILI9341

EDIT:

My arduino IDE updated and it didn't like having hyphens/underscores in folder names of libraries. If you are getting an error message complaining about these characters try removing them from the folder names (but not the names of the .h and .cpp files).

Step 3: Wire It Up and Upload the Example Sketch

There is an example sketch included with the ILI9340/1 library called graphics test. You have to wire the display up in accordance to the pin definitions there.

Originally When I wrote this Instructable I wrote:

I'd like to emphasize that this display uses 3.3V logic, and will not work if you use 5V. This is information that I found on some forum somewhere and using it I got my display to work

However:
I now have multiple of these displays from different sellers (and perhaps different factories). I have noticed that some of them also behave using 5V logic.

As labeled on my display module, the connections are

SCK - Arduino Pin 13
SDO(MISO) - Arduino Pin 12
SDI(MOSI) - Arduino Pin 11
CS - Arduino Pin 10
D/C - Arduino Pin 9
RESET - Arduino Pin 8
LED - 3.3V / 5V
VCC - 3.3V / 5V
GND - GND

Upload the example sketch and give it a go, the sketch shows you well how to control the display.

You may have to fiddle with the voltages for your particular model. There are various options you have here -potential dividers on each pin, level shifters, or simply powering your arduino with a 3.3v supply (this is perhaps the hackiest and can be slightly temperamental). See the comments for details.

Also, there is information about how to use the library on adafruits website.

A datasheet can be found here

You may do what you like with this Instructable, without having to contact me first.

Comments

author
torykay85 (author)2014-09-25

Hello, I worked with the 2.2 inch SPI LCD again.

I connected the 3,3V LCD with an Arduino Uno R3 5V. I used a resistor divider as a levelshifter.

LCD 3.3V #

|

Arduino Pins 5V #-----|4k7|----#----|10k|-----# GND

DSC_0313.JPG
author
charudatt (author)torykay852016-10-21

I am also planning to try it, not yet tried it, Actually my CC2500 projects use the scheme. I was just wondering why are people not using the same. Thank you for the confidence

author
tomk11 (author)torykay852014-10-28

Thank you for this! I remember trying this origionally and ended up using a 3.3v source instead because for some reason it didn't work. Clearly I made some kind of mistake.

author
FlyboyB1 (author)2017-08-13

It should work with this plug and play shield don't you think?

http://www.ebay.ca/itm/2-4-TFT-LCD-Display-Shield-...

author
FlyboyB1 (author)2017-08-13

It should work with this plug and play shield don't you think?

author
stanleyella (author)2017-07-23

The ILI9341 is supported in Great Cow Basic which compiles for mega328..ie uno

author
oululife (author)2014-09-20

Hi.

I've found a cct. diagram of this unit. Seems the little jumper on the back of the board should be shorted with a blob of solder for 3v3 operation. As it's an LDO regulator, you might just get away with it...
( One of the sellers has a file 2.25.zip. The schematic is in that.)

-Andy

Sch.pdf
author
sector7gp (author)oululife2017-05-29

Great man!! you got the answer! Im powering with 3v3 from arduino and jumpered the J1 ! works excelent!!

author
saabman (author)oululife2015-03-28

Thanks for that one, your post got my attention. Then i did hook up vcc to 5 volt. Voila its working.

author
HengD1 made it! (author)2016-07-29

hello,

I have been working on a tft 2.8 spi display for a while and cant make it working. the display is shown below, just mine is 2.8. I tried to use adafruit ili9341 library but it wont work. the serial monitor seems to be right though. Do you know what could possiblly be wrong. Thank you very much

Capture.JPGCapture2.JPG
author
tomk11 (author)HengD12016-07-29

It has been some time since i've used this display first but here are my thoughts.

Serial monitor working -> those pins which deal with communication are correct - sck and sdi I think (maybe cs too cant remember what that does?)

These are the correct symptoms for a a voltage problem. If i remember correctly some displays need 3.3v and some need 5v. incorrect voltage doesn't necissarily mean nothing works - from my experiance sometimes the backlight lit up but nothing happened sometimes. This is just a guess for where to start digging so I may be wrong. There are plenty of fantastic comments addressing these voltage issues.

author
legokid12 (author)tomk112017-05-09

CS is chip select, or the load pin.

author
MichaelM897 (author)tomk112016-08-10

I've been having this exact same problem (the output is exactly identical as well). I've used both 3.3v power (from an Arduino Mini) and 5v power (from an Arduino Uno), but neither have worked. Any advice on where to go from here?

author
tomk11 (author)MichaelM8972016-08-11

What do you see on the display? A blank white screen? a blank black screen? something else?

author
MichaelM897 (author)tomk112016-08-11

It's a blank white screen (although with a blue tint, certainly from the backlight). I've kept the screen on for long periods of time with both 5v and 3.3v voltages, and have found that it generates a lot of heat when give 5v, therefore it must be meant for 3.3v, as it resists the excess power. The document on it that the seller sent confirms this, and also says that the driver is an ILI9341, so I've had little reason to doubt that. I think that I'll try seeing the output when using an ILI9340 driver next. Besides that, are there any other things I might be doing wrong?

author
tomk11 (author)MichaelM8972016-08-11

Nothing springs to mind, double check that your voltage is okay, and also check that you have enough current to drive the display. I remember getting this blank white screen before I got my power right. It could be something else but other than that I don't know what to suggest. When I have some free time maybe I'll dig mine out and try to set it up again.

author
curtis.newton.104203 (author)2016-12-26

that gfx library is miserable and wont build on windows

author

The Adafruit GFX library has been tested to work on current versions of Windows. You are setting it up incorrectly.

author
curtis.newton.104203 (author)2016-12-26

white screen and there is no reset line so update your tutorial

author

You wired it up incorrectly and there is a reset pin on the model he is referring to.

author
fabianbambam (author)2017-04-28

I still have not get to work the TFT, I have always a white Screen...

My connections are:

All connections are wiring with a voltage divider (less VCC & LED):

arduino pin (5V signals) ----1k----display pin (Approx. 3.3V) ----1k8----GND

TFT----------Arduino UNO:

VCC---------3.3V

GND--------GND

CS----------PIN10

RESET -----PIN8

D/C---------PIN9

SDI(MOSI)-PIN11

SCK---------PIN13

LED---------47ohms----3.3V

SDO(MISO)-PIN12

I'm starting to think is a current issue... Any Suggestions? Or maybe another library?

author
AndrewM512 (author)2017-04-01

my pinout is starting at pin1 vcc,gnd,gnd,nc,nc,led,clk,sdi,rs,rst.cs, i have no clue as to what clk rs would get connected to ?here are the specks on the ldc :

Size: 2.2 inch
Module Size: 67x40x4 mm
Active Area: 47.5x36.5 mm
Resolution: 240 x 320 (RGB)
Interface: 4-Wire SPI
Color Depth: 262K/65K
LED Numbers: 4 LEDs
Driver IC: ILI9340C

Just need 5 IO port (analog SPI), or direct hardware SPI (fast), you can drive the input voltage support 5V/3.3V, ILI9341 drive
Suitable for beginners who are new to touch the color screen, LCD lovers who pursuit display effect and the microcontroller enthusiasts learners
Support serial SPI mode
It has PCB backplane with power IC, SD card socket
Need 4 IOs from your MCU only
Dot Matrix: QVGA 240*320 Dots
Interface 4-Wire SPI

author
delreer (author)2017-01-19

I am using the 2.2 TFT w/ILI 9340C. I got it to work just fine but I can only do text character. How can I display a variable, like a sensor value?

#include "SPI.h"

#include "Adafruit_GFX.h"

#include "Adafruit_ILI9340.h"

#if defined(__SAM3X8E__)

#undef __FlashStringHelper::F(string_literal)

#define F(string_literal) string_literal

#endif

// These are the pins used for the UNO

// for Due/Mega/Leonardo use the hardware SPI pins (which are different)

#define _sclk 13

#define _miso 12

#define _mosi 11

#define _cs 10

#define _dc 9

#define _rst 8

// Using software SPI is really not suggested, its incredibly slow

//Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _mosi, _sclk, _rst, _miso);

// Use hardware SPI

Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _rst);

int sensorPin = A0;

int sensorValue ;

char sensorPrintout[4];

void setup() {

// put your setup code here, to run once:

Serial.begin(9600);

while (!Serial);

Serial.println("Adafruit 2.2\" SPI TFT Test!");

tft.begin();

Serial.print(F("Text "));

Serial.println(testText());

delay(3000);

}

void loop() {

// put your main code here, to run repeatedly:

String sensorValue = String(analogRead(sensorPin));

sensorValue.toCharArray(sensorPrintout, 4);

}

unsigned long testText() {

tft.fillScreen(ILI9340_WHITE);

unsigned long start = micros();

tft.setCursor(1, 2);

tft.setTextColor(ILI9340_BLACK); tft.setTextSize(3);

tft.println("LOVE YOU LANA");

tft.setCursor(120, 2);

tft.setTextColor(ILI9340_RED); tft.setTextSize(2);

tft.println(sensorPrintout);

return micros() - start;

}

author
NeilM82 (author)2016-10-20

Anyone know how to use the SD card on this display? Any help would be appreciated.

author
DeepenS (author)2016-10-01

I was thinking of purchasing this display. Is it sunlight readable ? Suitable for outdoor use ? I intend to use it for motorsport applications.

author
arjan1974 (author)2016-09-29

Hi my name Arjan from the Netherlands,

I have to thank so far functioning working demo.

I have another question.

Where can I find the right Arduino instructions for creating a circle, square, pixel, etc. ??

has anyone examples or a web address

author
LotharK1 (author)2016-05-04

Ok, it works!!!!!

Many tanks to the author tomk11 and to torykay85 for a Fix in his comment.

Good Job Guys!!!!

author
cyzen made it! (author)2016-04-14

Got it easy to run with you receipt - thank's a lot!

20160414_215303.jpg
author
JayEffW (author)2015-08-06

Hi! Thanks to this post and the comments, I got my display to work. I initially had some issues and was going to ask for help, but I figured it out myself now and will instead post my solution here. If you're experiencing the symptoms shown below in the pictures, this post might just help you.

TL;DR: The ebay listing listed the wrong display driver chip. It listed the ILI9341 and I used the corresponding library, producing the symptoms below. I then, on a hunch, tried the ILI9340 library, which fixed the issues. This makes me believe that it was merely the listing that was wrong.

Longer description of my setup:

The pictures displayed did not match what I see everywhere else, resetting the image was clearly not working correctly.

I used a board with a couple of voltage dividers to shift my 5v logic down to 3.3v. It's more like 3.0v but from what I gathered, that shouldn't be a big deal. I'm using 2.7k and 5.6k resistors as such:

gnd -- 5.5k -- <display pin> -- 2.7k -- <arduino pin>

with all gnd being connected to the one arduino gnd pin. VCC and LED I connected directly to the arduino's 3.3v output as the LED wouldn't work on the 3.0v provided by my divider.

This setup now works for me, so I hope this helps!

2015-08-06 19.29.47.jpg2015-08-06 19.23.17.jpg2015-08-06 19.23.37.jpg2015-08-06 19.23.48.jpg
author
GavinH24 (author)JayEffW2016-04-08

Yep +1 on this - I bought these displays from two separate aliexpress sellers, both of which were clearly described as

1PCS NEW ILI9341 2.2 inch 2.2" SPI Serial Port TFT LCD Display Screen 240*320 Dots 5V/3.3V

Both panels used ILI9340, and neither supported 5V GPIO logic - I had to make a bank of resistors to divide the +5V voltage down to approx 3.3V

(I used 390 and 200 ohm, since that's what I had in the box :)

author
esterlynquesada (author)2016-02-03

After much trying and trying different configurations, I finally made it work and to read files on the SD card. I share my solution:



PIN #
TFT
ARDUINO ONE
SD
ARDUINO ONE


1
VCC
5 +
SD_CS
7


2
GND
GND
SD_MOSI
11


3
CS
10
SD_MISO
12


4
RESET
RESET
SD_SCK
13


5
DC/RS
9




6
SDI/MOSI
11




7
SCK
13




8
LED
220k resistor ==> 5
+




9
SDO/MISO
12


I used the library to recommend the following link:

https://www.instructables.com/id/Arduino-TFT-displa...

I hope they help you

author
mvcorrea (author)2016-01-12

hi there,

Does anyone figure out the power consuption of this device(sleep/active)? I am unable to find the values on the datasheet. regards,

author
Fezder made it! (author)2016-01-11

Thanks, it worked finally! screen is quite screwed as it got damaged....but it worked enough for test.

IMG_1145.JPG
author
AlyssonR2 (author)2016-01-02

I use a simple, transistor-based level shifter that takes its supplies from both the host (system) and slave (remote) devices - allowing it to automatically compensate for supplied voltage. It also handles a few extra load units!

I²C Level Shifter Schematic.png
author
Jatin Gandhi made it! (author)2015-12-24

thanks a lot. I have used arduino pro mini 3.3 V.

_20151225_053855.JPG
author
soundmanu (author)2015-11-26

Hi,

with the help of that blog and the post of torykay85 the TFT works! Thanks for that!!
But my TFT on UNO is very, very slow .... When I want to set the TFT on Hardware ID it won't work, but when I define all Pin's (13,12,11,etc...) then it work but very slow!! Anybody would help me ..?

author
dj4you (author)2015-11-10

Is it mandatorily i should use 3.3V or 3V also enough for proper operation of the module?..... please someone give me the answer

author
RuneP3 (author)dj4you2015-11-19

It depends on the specific components used on your display. Quite often 3v is sufficient for 3.3v modules.

author
CelticHarp (author)2015-11-11

Hi,

My TFT works, but now I want to load a bmp from the SD. How can I do this? What is the wiring?

author
CelticHarp (author)CelticHarp2015-11-12

I am using Adafruit ILI9340 library.

author
gbushta made it! (author)2015-11-08

I just wanted to say thank you. I played with this cheap TFT for a little while, actually quite a while. I was just about to give up when all of a sudden it started working. The ones I bought work on 5v. I fought with my bareduino (on a breadboard) and with an Uno. BTW, I saw your reset button on your breadboard and just had to add one to mine. It sure works nicely. Thanks for that, too.

IMG_6262.PNG
author
encodersofia (author)2015-05-06

Didn't work first time. Reset pin on the LCD must be high and it will work. Just add

pinMode(8, OUTPUT);

digitalWrite(8, LOW);

digitalWrite(8, HIGH);

to your Arduino sketch or connect reset pin to 3.3V by wire

author
bratan (author)encodersofia2015-06-13

Thank you for the Reset tip! I couldn't get mine to work until I connected it to 3.3V! Author should definately include this in the instructable.

author
NeilK3 (author)2015-05-12

On step 3, you write "LCD - 3.3V". I think this should be "LED - 3.3V".

author
messina.david.7 (author)2015-04-28

j'ai réalisé le montage avec une carte compatible Arduino
nano. J’ai utiliser le pont de résistance pour adapter la tension .

l'écran TFT utilisé est exactement le même qu'ici.

résultat :

- il as fallut que je trouve les drivers de la carte
compatible arduino nano

- le programme
graphicstest ne démarre pas toujours au moment ou je branche
l'alimentation de la carte

actuellement j’essais de comprendre pourquoi le démarrage n’es
pas systématique

author
Surferdude (author)2015-03-26

I tried installing this for an Arduino, but it doesn't even compile. The first problem is that the include statement:

#include <Adafruit_GFX.h>

in the file Adafruit_ILI9340.h is incorrect. I think it should be

#include "Adafruit_GFX.h"

The next problem, that I have not solved yet, is the error

'initG' was not declared in this scope

The ILI9340 library seems to be incomplete (i.e., not finished). There's a function called commandList, but the only reference to it that I find is commented. out.

How did people get this to work when it's such junk? Or am I missing some setting?

author
tomk11 (author)Surferdude2015-03-26

Whenever you wish to use a library in Arduino you always type

#include <libraryname>

not

#include "libraryname"

It sounds like the most likely problem is that you haven't installed the libraries correctly.

If you post the entire error messages I might be able to help you further.

Also you can be politer than "How did people get this to work when it's such junk?". The fact that other people have got it to work suggests that its your mistake...

author
Surferdude (author)tomk112015-03-27

I installed the Adafruit library where all of the other libraries outside of the core are located, in this folder:

C:\Program Files (x86)\arduino-1.5.7\libraries

I also tried putting it in

C:\Users\...\Documents\Arduino\libraries

I was finally able to get it to compile by putting the files with my code and using the quoted version of the #include directive.

If you look in the code, you'll see what I mean by my comment that it's junk. It looks like they started by trying to adapt the code for the ST7735. There is a section, for example, starting with this comment:

// Rather than a bazillion writecommand() and writedata() calls, screen

that wasn't even completed, as it is for the 7735. It's just poorly documented and written code. Is the commandList function even used for the 9340? Plus there's no documentation in the spec sheet on the initialization commands that they use in the code. For example, what does:

writecommand(0xCB);

do? The command list I see in the spec goes from 0x39 to 0x3A to 0x3C to 0x3E on page 84. No command 0x3B. (This is the ILITEK spec sheet for the ILI9340.)

The initG was in the TFT class that is part of the original Adafruit library.

author
maula-rama (author)2015-03-26

Can I install those Libraries on raspberry pi? If yes, how do I suppose to do that? I'll be waiting for the answer?

author
tomk11 (author)maula-rama2015-03-26

Short answer - not easily.

Unless you want to be messing around with the source code I don't think you will be able to have rasp-pi --> LCD. Your options basically are:

1 - Look around the web to see if someone has done a tutorial on using this LCD with the rasp-pi
2 - consider making whatever project you are thinking of on arduino
3 - use some sort of intermediary hardware to link them. You might find something relevant by googling something like "use arduino shield with raspberry pi"

I do have a raspberry pi so I might look into getting one of these solutions to work after my uni exams are over :)

About This Instructable

189,490views

90favorites

More by tomk11:TFT Environment Monitor using BMP180 & DHT11Cheap TFT 2.2 inch Display on Arduino (ILI9340C or ILI9341)
Add instructable to: