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.





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

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

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.

<p>Hello, I worked with the 2.2 inch SPI LCD again.</p><p>I connected the 3,3V LCD with an Arduino Uno R3 5V. I used a resistor divider as a levelshifter.</p><p>LCD 3.3V #</p><p> |</p><p> Arduino Pins 5V #-----|4k7|----#----|10k|-----# GND</p>
<p>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</p>
<p>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.</p>
<p>hello,</p><p>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</p>
<p>It has been some time since i've used this display first but here are my thoughts.</p><p>Serial monitor working -&gt; those pins which deal with communication are correct - sck and sdi I think (maybe cs too cant remember what that does?)</p><p>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.</p>
<p>CS is chip select, or the load pin.</p>
<p>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?</p>
<p>What do you see on the display? A blank white screen? a blank black screen? something else?</p>
<p>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?</p>
<p>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.</p>
<p>that gfx library is miserable and wont build on windows</p>
<p>The Adafruit GFX library has been tested to work on current versions of Windows. You are setting it up incorrectly.</p>
<p>white screen and there is no reset line so update your tutorial</p>
<p>You wired it up incorrectly and there is a reset pin on the model he is referring to.</p>
<p>I still have not get to work the TFT, I have always a white Screen...</p><p>My connections are:</p><p>All connections are wiring with a voltage divider (less VCC &amp; LED):</p><p>arduino pin (5V signals) ----1k----display pin (Approx. 3.3V) ----1k8----GND</p><p>TFT----------Arduino UNO:</p><p>VCC---------3.3V</p><p>GND--------GND</p><p>CS----------PIN10</p><p>RESET -----PIN8</p><p>D/C---------PIN9</p><p>SDI(MOSI)-PIN11</p><p>SCK---------PIN13</p><p>LED---------47ohms----3.3V</p><p>SDO(MISO)-PIN12</p><p>I'm starting to think is a current issue... Any Suggestions? Or maybe another library?</p>
<p>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 :</p><p>Size: 2.2 inch<br>Module Size: 67x40x4 mm<br>Active Area: 47.5x36.5 mm<br>Resolution: 240 x 320 (RGB)<br>Interface: 4-Wire SPI<br>Color Depth: 262K/65K<br>LED Numbers: 4 LEDs<br>Driver IC: ILI9340C</p><p>Just need 5 IO port (analog SPI), or direct hardware SPI (fast), you can drive the input voltage support 5V/3.3V, ILI9341 drive<br>Suitable for beginners who are new to touch the color screen, LCD lovers who pursuit display effect and the microcontroller enthusiasts learners<br>Support serial SPI mode<br>It has PCB backplane with power IC, SD card socket<br>Need 4 IOs from your MCU only<br>Dot Matrix: QVGA 240*320 Dots<br>Interface 4-Wire SPI</p>
<p>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? </p><p>#include &quot;SPI.h&quot;</p><p>#include &quot;Adafruit_GFX.h&quot;</p><p>#include &quot;Adafruit_ILI9340.h&quot;</p><p>#if defined(__SAM3X8E__)</p><p> #undef __FlashStringHelper::F(string_literal)</p><p> #define F(string_literal) string_literal</p><p>#endif</p><p>// These are the pins used for the UNO</p><p>// for Due/Mega/Leonardo use the hardware SPI pins (which are different)</p><p>#define _sclk 13</p><p>#define _miso 12</p><p>#define _mosi 11</p><p>#define _cs 10</p><p>#define _dc 9</p><p>#define _rst 8</p><p>// Using software SPI is really not suggested, its incredibly slow</p><p>//Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _mosi, _sclk, _rst, _miso);</p><p>// Use hardware SPI</p><p>Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _rst);</p><p>int sensorPin = A0;</p><p>int sensorValue ;</p><p>char sensorPrintout[4]; </p><p>void setup() {</p><p>// put your setup code here, to run once:</p><p> Serial.begin(9600);</p><p> while (!Serial);</p><p> Serial.println(&quot;Adafruit 2.2\&quot; SPI TFT Test!&quot;); </p><p> tft.begin();</p><p> Serial.print(F(&quot;Text &quot;));</p><p> Serial.println(testText());</p><p> delay(3000);</p><p>}</p><p>void loop() {</p><p> // put your main code here, to run repeatedly:</p><p> String sensorValue = String(analogRead(sensorPin));</p><p> sensorValue.toCharArray(sensorPrintout, 4);</p><p>}</p><p>unsigned long testText() {</p><p> tft.fillScreen(ILI9340_WHITE);</p><p> unsigned long start = micros();</p><p> tft.setCursor(1, 2);</p><p> tft.setTextColor(ILI9340_BLACK); tft.setTextSize(3);</p><p> tft.println(&quot;LOVE YOU LANA&quot;);</p><p> tft.setCursor(120, 2);</p><p> tft.setTextColor(ILI9340_RED); tft.setTextSize(2);</p><p> tft.println(sensorPrintout);</p><p> return micros() - start;</p><p>}</p>
<p>Anyone know how to use the SD card on this display? Any help would be appreciated.</p>
<p>I was thinking of purchasing this display. Is it sunlight readable ? Suitable for outdoor use ? I intend to use it for motorsport applications. </p>
<p>Hi my name Arjan from the Netherlands,</p><p>I have to thank so far functioning working demo.</p><p>I have another question.</p><p>Where can I find the right Arduino instructions for creating a circle, square, pixel, etc. ??</p><p>has anyone examples or a web address</p>
<p>Ok, it works!!!!!</p><p>Many tanks to the author <a href="https://www.instructables.com/member/tomk11" rel="nofollow">tomk11</a> and to <a href="https://www.instructables.com/member/torykay85" rel="nofollow">torykay85</a> for a Fix in his comment.</p><p>Good Job Guys!!!!</p>
<p>Got it easy to run with you receipt - thank's a lot!</p>
<p>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.</p><p>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.</p><p>Longer description of my setup:</p><p> The pictures displayed did not match what I see everywhere else, resetting the image was clearly not working correctly.</p><p>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: </p><p>gnd -- 5.5k -- &lt;display pin&gt; -- 2.7k -- &lt;arduino pin&gt; </p><p>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.</p><p>This setup now works for me, so I hope this helps!</p>
<p>Yep +1 on this - I bought these displays from two separate aliexpress sellers, both of which were clearly described as </p><p>1PCS NEW ILI9341 2.2 inch 2.2&quot; SPI Serial Port TFT LCD Display Screen 240*320 Dots 5V/3.3V</p><p>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 </p><p>(I used 390 and 200 ohm, since that's what I had in the box :)</p>
<p>After much trying and trying different configurations, I finally made it work and to read files on the SD card. I share my solution:</p><br> <br> PIN #<br> TFT<br> ARDUINO ONE<br> SD<br> ARDUINO ONE<br> <br> <br> 1<br> VCC<br> 5 +<br> SD_CS<br> 7<br> <br> <br> 2<br> GND<br> GND<br> SD_MOSI<br> 11<br> <br> <br> 3<br> CS<br> 10<br> SD_MISO<br> 12<br> <br> <br> 4<br> RESET<br> RESET<br> SD_SCK<br> 13<br> <br> <br> 5<br> DC/RS<br> 9<br> <br> <br> <br> <br> 6<br> SDI/MOSI<br> 11<br> <br> <br> <br> <br> 7<br> SCK<br> 13<br> <br> <br> <br> <br> 8<br> LED<br> 220k resistor ==&gt; 5<br> +<br> <br> <br> <br> <br> 9<br> SDO/MISO<br> 12<br> <br> <br> <p>I used the library to recommend the following link:</p><p><a href="https://www.instructables.com/id/Arduino-TFT-display-of-bitmap-images-from-an-SD-Ca/?ALLSTEPS" rel="nofollow">https://www.instructables.com/id/Arduino-TFT-displa...</a></p><p>I hope they help you</p>
<p>hi there,</p><p>Does anyone figure out the power consuption of this device(sleep/active)? I am unable to find the values on the datasheet. regards,</p>
<p>Thanks, it worked finally! screen is quite screwed as it got damaged....but it worked enough for test.</p>
<p>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!<br></p>
<p>thanks a lot. I have used arduino pro mini 3.3 V.</p>
<p>Hi,</p><p>with the help of that blog and the post of torykay85 the TFT works! Thanks for that!!<br>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 ..?</p>
<p>Is it mandatorily i should use 3.3V or 3V also enough for proper operation of the module?..... please someone give me the answer</p>
<p>It depends on the specific components used on your display. Quite often 3v is sufficient for 3.3v modules.</p>
<p>Hi,</p><p>My TFT works, but now I want to load a bmp from the SD. How can I do this? What is the wiring?</p>
<p>I am using Adafruit ILI9340 library.</p>
<p>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.</p>
<p>Didn't work first time. Reset pin on the LCD must be high and it will work. Just add </p><p>pinMode(8, OUTPUT);</p><p> digitalWrite(8, LOW);</p><p> digitalWrite(8, HIGH);</p><p>to your Arduino sketch or connect reset pin to 3.3V by wire</p>
<p>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.</p>
<p>On step 3, you write &quot;LCD - 3.3V&quot;. I think this should be &quot;LED - 3.3V&quot;.</p>
<p>j'ai r&eacute;alis&eacute; le montage avec une carte compatible Arduino <br>nano. J&rsquo;ai utiliser le pont de r&eacute;sistance pour adapter la tension .</p><p>l'&eacute;cran TFT utilis&eacute; est exactement le m&ecirc;me qu'ici.</p><p>r&eacute;sultat :</p><p>- il as fallut que je trouve les drivers de la carte <br>compatible arduino nano</p><p>- le programme <br>graphicstest ne d&eacute;marre pas toujours au moment ou je branche <br>l'alimentation de la carte</p><p>actuellement j&rsquo;essais de comprendre pourquoi le d&eacute;marrage n&rsquo;es <br>pas syst&eacute;matique</p>
<p>Hi.</p><p>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...<br>( One of the sellers has a file 2.25.zip. The schematic is in that.)</p><p>-Andy</p>
<p>Thanks for that one, your post got my attention. Then i did hook up vcc to 5 volt. Voila its working. </p>
<p>I tried installing this for an Arduino, but it doesn't even compile. The first problem is that the include statement:</p><p>#include &lt;Adafruit_GFX.h&gt;</p><p>in the file Adafruit_ILI9340.h is incorrect. I think it should be </p><p>#include &quot;Adafruit_GFX.h&quot;</p><p>The next problem, that I have not solved yet, is the error</p><p>'initG' was not declared in this scope</p><p>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.</p><p>How did people get this to work when it's such junk? Or am I missing some setting?</p>
<p>Whenever you wish to use a library in Arduino you always type</p><p>#include &lt;libraryname&gt;</p><p>not</p><p>#include &quot;libraryname&quot;</p><p>It sounds like the most likely problem is that you haven't installed the libraries correctly.</p><p>If you post the entire error messages I might be able to help you further.</p><p>Also you can be politer than &quot;How did people get this to work when it's such junk?&quot;. The fact that other people have got it to work suggests that its your mistake...</p>
<p>I installed the Adafruit library where all of the other libraries outside of the core are located, in this folder:</p><p>C:\Program Files (x86)\arduino-1.5.7\libraries</p><p>I also tried putting it in </p><p>C:\Users\...\Documents\Arduino\libraries</p><p>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.</p><p>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:</p><p>// Rather than a bazillion writecommand() and writedata() calls, screen</p><p>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:</p><p>writecommand(0xCB);</p><p>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.)</p><p>The initG was in the TFT class that is part of the original Adafruit library. </p>
<p>Can I install those Libraries on raspberry pi? If yes, how do I suppose to do that? I'll be waiting for the answer?</p>
Short answer - not easily.<br><br>Unless you want to be messing around with the source code I don't think you will be able to have rasp-pi --&gt; LCD. Your options basically are:<br><br>1 - Look around the web to see if someone has done a tutorial on using this LCD with the rasp-pi<br>2 - consider making whatever project you are thinking of on arduino<br>3 - use some sort of intermediary hardware to link them. You might find something relevant by googling something like &quot;use arduino shield with raspberry pi&quot;<br><br>I do have a raspberry pi so I might look into getting one of these solutions to work after my uni exams are over :)
<p>Hi, I have some problems to get my TFT 2.2 (see picture) run. I wired the TFT to my MEGA: 3,3V</p><p>#define _sclk 52<br>#define _miso 50<br>#define _mosi 51<br>#define _cs 53<br>#define _dc 9<br>#define _rst 8</p><p>an I use the library ILI9340 and the sketch graphicstest.</p><p>#include &quot;SPI.h&quot;<br>#include &quot;Adafruit_GFX.h&quot;<br>#include &quot;Adafruit_ILI9340.h&quot;</p><p>But it do not work (see picture 2). Only white screen.</p><p>What is wrong? Do I make a mistake? I have two TFT tested but the same result.</p><p>Regards Ulli. </p>
<p>I can't actually see what's going on there but I suspect that you have wired the 3.3v to the vcc on the display (which is fine). However your other pins are still running at 5v which the display won't play ball with. Please see <a href="https://www.instructables.com/member/torykay85/" rel="nofollow">torykay85</a>'s comment which I have pinned for a fix. I will update the instuctable with some more detail soon as this has confused a few people.</p>
<p>MattM5's comments are correct. Although it is open source, they can only afford to do that if people support their business in some way.</p><p>Am I missing something in this Instructable, or is there no schematic showing how you wired this? I see pictures, but no details on how you did the level translation, etc. Posting a couple of pictures with links to someone else's code isn't really much of an Instructable. It would be helpful to maybe have a schematic on the wiring, and maybe some close-ups of the wiring and display. What are you clocking this at? Doesn't the ATMega require 5v to operate at full 16MHz rate? Are you clocking at 8 to make this work at 3.3V? If so, what board did you pick in the Arduino dev env?</p>
<p>My atmega chip runs quite happily at 3.3v at 16 mhz. <a href="https://www.instructables.com/member/torykay85/" rel="nofollow">torykay85</a> provided an example of how you would do level shifting in the comment above if you want to do it that way though.</p><p><br>SCK - Arduino Pin 13</p><p>SDO(MISO) - Arduino Pin 12</p><p>SDI(MOSI) - Arduino Pin 11<br>CS - Arduino Pin 10 <br>D/C - Arduino Pin 9 <br>RESET - Arduino Pin 8 <br>LCD - 3.3V <br>VCC - 3.3V </p><p>GND - GND <br><br>I didn't post this originally because it tells you to do this in the library. The point of the instructable was because it the time there were absolutely no pointers on how to get the thing to run.</p>

About This Instructable



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