Need pin connection help for 240x320 2.8" ILI9341

I bought this 240x320 2.8" ILI9341 LCD touch screen here but can't get it working. I tried a few different libraries other then getting the screen to light up I can't get it working.

Anyone know how to hook this thing up with an UNO and get it working? I can probably figure out the software side, but I'm not confident I have the pins connected correctly. Should the VCC and LED pins both be connected to 3.3V or 5V on the UNO? Which pins are necessary to use? (excluding the touch or SD card).

Naturally I stubble on a possible answer right after I post. So it seems with this shield I need a 5v-3.3v logic level converter for it to work with the UNO. Here is a link with someone who apparently had the same issue.

If anyone can confirm this will fix my problem, I'd appreciate it.

The display's "LED" pin can be connected to 3V or 5V, but there needs to be a current-limiting resistor (100ohms to 5V).

Have your tried the voltage dividers for the Uno-display signalling? Your link lists that as a possibility (2.2k, 3.3k).

There's a 20-page thread here on the ILI9341 and others' ups and downs. Unfortunately, most of the participants are schematic averse.

The display's Vcc should probably be 3V (there's some variation or misunderstanding/s.)

There are two adafruit libraries required.

I'm at work currently so haven't had a chance, plus I'm waiting on a new breadboard since my other one is currently occupied so testing is a pain at the moment. I will give it a try when my new breadboard arrives.

There are two adafruit libraries required.

I installed them both and the serial monitor ran through all the display stuff like drawing lines and whatnot, but nothing showed up on the screen. I'm sure it's the hardware side that's my problem. I'm still trying to understand why I need a logic level converter if the arduino has a 3.3v pin I can tap into. I need to do more reading. I think this link will explain it better which I will read after work.

Nooffswitch:
I'm still trying to understand why I need a logic level converter if the arduino has a 3.3v pin I can tap into.

Because the display is looking for 3V highs, not 5V highs.
The display is taking 3V for power from the Arduino 3V supply, but the Arduino outputs are still 0/5V.
Don't fight it, just go with it.

You're right, gotta roll with it 8)

I found 2 more links with information about this issue. Basically both advise using 1k or 1k2 resistors to wire this thing. The links are here and here for anyone interested.

Ok, finally got around to cleaning my breadboard and trying to get this thing working. The first thing I tried was using 1k resistors like one of the links I posted suggested, and it works! The Adafruit demo loaded up and went through the demo stuff.

The problem now, I'm trying to get the "breakouttouchpaint" example to work from their touchscreen library, but again I don't know how to wire this thing. In the code they refer to X positive, X negative, Y positive, and Y negative. They link these 4 to Analog pins 2,3, and digital pins 4,5. Does anyone know what the equivalent is on this board to the Adafruit ones?

The touch pins are IRQ, DD, DIN, CS, and CLK, but which pins do I connect them to on the Uno to use with Adafruits touch library?

Is the Touch controller mounted on the pcb?

There have been recent discussions on this board. Search for "ILI9341_due".
Yes, it works with a UNO.

You can connect the Touch controller to the same SPI bus as the SD card and the TFT.
Make sure that all the logic levels are 3.3V. Your "resistors" are a bit fierce! 1k0 and 2k2 would be nearer 3.3V.

AFIK, Adafruit do not do a library for the SPI Touch controller chip.
Avoid anything from UTFT unless you are prepared to waste the GPIO pins.
UTFT has only heard of bit-bashing, and will certainly kill any hardware SPI devices on those pins.

David.

david_prentice:
Is the Touch controller mounted on the pcb?

Not sure what you're asking, can you please clarify? In the first post I linked to the touch screen I bought if that helps.

You can connect the Touch controller to the same SPI bus as the SD card and the TFT.
Make sure that all the logic levels are 3.3V.

I haven't connected the SD card pins yet, so I still don't know how to connect the touch pins to the Arduino, this is where I'm stuck.

Your "resistors" are a bit fierce! 1k0 and 2k2 would be nearer 3.3V.

Ok thanks, I'll play around with different resistors.

AFIK, Adafruit do not do a library for the SPI Touch controller chip.

Is there a better library for this card that works? My goal is to have a menu selection set up on it for a project I'm working on.

My apologies. Your link shows photos of the pcb with an XPT2046 chip mounted.
There are Ebay sites that sell this board with an empty footprint for the XPT2046.

You should find several libraries that control an XPT2046.
Note that almost all Touch controllers use the same basic commands. e.g. ADS7843, ADS7846, …

As I said earlier, I would put TFT, SD, Touch all on the same SPI bus with 3.3V logic.

If you like the UTFT library, the UTouch library will handle this controller. Note that you need separate GPIO pins and 3.3V logic.

Oh, and you can compare performance between ILI9341_due and UTFT.

David.

david_prentice:
As I said earlier, I would put TFT, SD, Touch all on the same SPI bus with 3.3V logic.

This is the part that's confusing me since I'm a newb. Isn't the SPI bus on the UNO consist of pins 10 (ss),11(mosi),12(miso), and 13(sck)? I'm already using those pins for the display to work, so do I share them with the "touch" pins on the touch screen (t_IRQ, t_DD, t_DIN, t_CS, and t_CLK)?

Those pins are digital:

TCLK, TCS, TDIN, TDOUT, IRQ

6,5,4,3,2

For UNO, MEGA o Due you can try this lib to control the TFT and the touch panel: ili9341_due

TFTLCDCyg:
For UNO, MEGA o Due you can try this lib to control the TFT and the touch panel: ili9341_due

It won't work. It needs both the UTouch and UTFT libraries. I tried it and got an error msg. Problem is the UTFT Library needs a lot of flash memory, and I got a msg saying Sketch uses 33,460 bytes (103%) of program storage space. Maximum is 32,256 bytes. Even the website states:

Due to the size of the library I do not recommend using it on ATmega328 (Arduino 2009/Uno) and ATmega32U4 (Arduino Leonardo) as they only have 32KB of flash memory.

So I'm once again trying to figure out how to get the touch working. On the bright side I changed my resistors to 1K0 and 2K2 as David suggested, and now get 3.05V reading on the pins.

TFTLCDCyg:
Those pins are digital:

TCLK, TCS, TDIN, TDOUT, IRQ

6,5,4,3,2




For UNO, MEGA o Due you can try this lib to control the TFT and the touch panel: [ili9341_due](http://forum.arduino.cc/index.php?topic=265806.0)

Wait! It kind of works. Not sure why I thought UTFT was needed, must have loaded a different example. I'm trying the "uTouchButtonTest" example and it's letting me click on the numbers, but something is off with the alignment. Hitting "clear" gives me 9, "enter" gives me 7, and whatnot. At least its progress :smiley:

Ok, got it working! I did the calibration example and updated the UTouchCD.h file with the results. Now everything works great. Thanks guys! Now that I know it works I can try figuring out how to make my own menu system on it.

I have been playing around with the touch screen a bit, and there’s an issue I can’t figure out. Basically when I’m using the ILI9341_due library, the colors often get messed up, or the screen sometimes stays white (even though I believe the sketch is loading underneath).

When it messes up I run the adafruit “graphictest” example and it plays fine, and in the process seems to reset everything. I’m convinced it’s some kind of conflict with the reset button, either from the library side or my connection from the Reset pin directly to the 3.3V pin on the Arduino Uno.

Below is some simple code, the only change in the code is the library I’m using, and all it’s supposed to do is display a sequence of different colors on the screen (Black, Red, Green, Blue, and Yellow) repeatedly.

#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"

// For the Adafruit shield, these are the default.
#define TFT_DC 9
#define TFT_CS 10

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);


void setup() {
  Serial.begin(9600);
  Serial.println("COLOR TEST"); 
 
  tft.begin();
}

void loop(void) {
  testFillScreen();
  delay(1000);  
}

unsigned long testFillScreen() {
  unsigned long start = micros();
  tft.fillScreen(ILI9341_BLACK);
  tft.fillScreen(ILI9341_RED);
  tft.fillScreen(ILI9341_GREEN);
  tft.fillScreen(ILI9341_BLUE);
  tft.fillScreen(ILI9341_YELLOW);
  return micros() - start;
}
#include <SPI.h>
#include <ILI9341_due_config.h>
#include <ILI9341_due.h>

#define TFT_RST 8
#define TFT_DC 9
#define TFT_CS 10

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
ILI9341_due tft = ILI9341_due(TFT_CS, TFT_DC, TFT_RST);


void setup() {
  Serial.begin(9600);
  Serial.println("COLOR TEST"); 
 
  tft.begin();
}

void loop(void) {
  testFillScreen();
  delay(1000);  
}

unsigned long testFillScreen() {
  unsigned long start = micros();
  tft.fillScreen(ILI9341_BLACK);
  tft.fillScreen(ILI9341_RED);
  tft.fillScreen(ILI9341_GREEN);
  tft.fillScreen(ILI9341_BLUE);
  tft.fillScreen(ILI9341_YELLOW);
  return micros() - start;
}

The ILI9341_due code includes “#define TFT_RST 8”, which I have removed since I have nothing on pin 8, but it doesn’t seem to make a difference, and from what I read it’s optional.

When I run the first set of code (Adafruit_ILI9341) everything works fine, but when I run the second set of code (ILI9341_due) from Marekburiak library, the colors aren’t right. It’s like they’re reversed or something, I get white, cyan, magenta, yellow, blue.

Can anyone help with this?

Ok, I figured it out. Not sure why, but my colors are being inverted, so adding "tft.invertDisplay(true);" fixed the color issue.

It still doesn't explain why when I load a ILI9341_due sketch after powering up the Arduino, the screen stays white, where's when I run the Adafruit one it always loads. There's still something off about the way it resets/refresh's. Funny part is when I load a ILI9341_due sketch, then the adafruit one, for a split second I can see the ILI9341_due sketch appear on the screen before the adafruit one starts.

There is nothing unusual. The GRAM is not altered during reset.

I am sure that both Marek and Adafruit perform a “Software Reset” command.
I am sure that they both shake the hardware Reset line.

OTOH, we have no idea whether you have wired the Reset line OR whether you have put the Reset pin in the constructor().

I am guessing that you are using an AVR. Have you got proper 3.3V logic?

David.

david_prentice:
OTOH, we have no idea whether you have wired the Reset line OR whether you have put the Reset pin in the constructor().

As I said before, the reset pin on the touch screen is connected to the 3.3V on the Arduino. My setup is just like this, except I changed 4 of my resistors to to 2K2 as someone suggested. Do I need a logic level converter for the Reset pin also?

I am guessing that you are using an AVR. Have you got proper 3.3V logic?

Yeah I think I do. If the code works on one library and not the other one, what are the chances it's a hardware issue anyways?

I have tried playing with some of the other ILI9341_due library commands such as:
tft.display(true);
tft.idle(false);
tft.sleep(false);
tft.setSPIClockDivider(SPI_CLOCK_DIV2);

None of these commands seem to help.

Well, for a start, it is unwise to hardwire the Reset pin.

My apologies. I have just looked at Adafruit and Marek's init commands. Neither seem to issue a "Soft Reset".

Both cater for a "Hard Reset". Which you have disabled !!!

Either do a Soft Reset or wire your Reset pin properly. e.g. with a pull-up to 3.3V and a proper 3.3V control signal.

David.