Seeed 2.8 wiring to Arduino Mega 2560 R3

Hey guys,

i bought myself 2 displays from seeed studios:

Now I want to use them via SPI with my arduino mega R3 but i have big troubles wiring them correctly. Right now there is actually no response from none of the displays. As far as i've read, you either need to solder P1, P2 and P3 to use the outer pins on the shield or you have to use the ICSP port from the shield. At the moment I have no chance to solder so i plugged it simply to the ICSP on the shield and the regular pins on the arduino board.

This Thread:
https://forum.arduino.cc/index.php?topic=305945.0
helped me to get the an idea of the correct pins and model to select for using UTFT. Still none of the displays work. Here is how i wired one of them:

5V shield -> Digital 5V
GND Shield -> Digital GND
CLK shield -> D52
MOSI shield -> D53
MISO shield -> D50
TFT_CS shield -> D10
TFT_DC shield -> D09
RST shield -> D08

The init looks like this:

UTFT myGLCD2(ILI9341_S5P, 51, 52, 5, 0, 6);

Hope you guys can figure out where i went wrong.

thanks a lot.

Surely you just plug the Shield into your Mega2560 header sockets.

Then run whatever library Seeed suggests.

But you should be able to use several other libraries. e.g. Adafruit_ILI9341

I do not have this shield. I have not read their documentation.
I would assume that the TFT will use the 3x2 SPI header. You would not need to make any of the solder bridges. i.e. it will run out of the box on Uno, Leo, Mega2560, Zero, Due, ...

David.

Follow the tutorial that Seeed supply for thier shield.

If the displays do not work with the tutorial, then contact Seeed.

Once you have the tutorial working, then you can move on and try your own programs.

david_prentice:
Surely you just plug the Shield into your Mega2560 header sockets.

Then run whatever library Seeed suggests.

But you should be able to use several other libraries. e.g. Adafruit_ILI9341

I do not have this shield. I have not read their documentation.
I would assume that the TFT will use the 3x2 SPI header. You would not need to make any of the solder bridges. i.e. it will run out of the box on Uno, Leo, Mega2560, Zero, Due, ...

David.

Hi David,
If you had read the documentation you would have seen they recommend their own lib at the moment. Which is bullsit. I have to configure several things I don't need and I don't know about. What i know is that the ILI9341 is supportet by the UTFT lib that I already use. Changeing my sketch to the right pins and connecting the display is then way more easy.
The display works when i plug it right onto the mega board but that does not help at all because i need to rung two displays with one mega board and the documentation from seeed studios is sh
t. I haven't seen any tutorial how to connect the displays to the mega board without directly sticking both together. And thats the reason for my question!

The display works when i plug it right onto the mega board but that does not help at all because i need to rung two displays with one mega board and the documentation from seeed studios is sh*t.

I understood that you had bought two items. Not that you wanted to connect two displays to a single Mega2560 at the same time.

I would guess that one shield will plug into the Mega2560 as Nature intended.

The second shield would need to be connected via the 18x2 header.
This contains the hardware SPI pins (50-52) and you can select GPIO pins for CS, DC, RST. The Touch pins of your second screen can have XP, YM on the 18x2 but XM, YP must be Analog. You can access A6-A15 with angle header strip.

This should be fine for libraries like Adafruit_ILI9341. i.e. two separate Adafruit_ILI9341 objects that both use the Hardware SPI.
I am sure that Seeed's TFTv2.h library "works" for a single Shield. It does not expect multiple objects.

I guess that you could create two separate UTFT objects. Note that Mr Karlsen has no concept of hardware SPI. He bit-bangs software SPI. I suspect that you will need to use completely different pins for each constructor with software SPI. Mind you, he has no concept of reading SPI. So multiple SPI devices on the same bus is only important when you use SD card.

David.

Thank you David. That is some Information I was hoping to get!

I tried plugging the shield directly onto the Mega R3 and at least the screen is white and full background lightning. I think this is a sign tha the power supply is okay. So now i have to work out how to set the pins correctly. Do you have any idea what the ALE pins is? I have no idea...

In this thread: Using the UTFT libraries with the Seeedstudio 2.8'' TFT Touch Shield V2.0 - Displays - Arduino Forum
in the first post the user seems to get it working with UTFT lib but I am very confused by the init line:
"UTFT myGLCD(ILI9341_S5P,51,52,5,0,6);".
51 and 52 should be RS and WR, 5 is the CS i guess, 0 the RS. But what is the 6?

Copied from the Instructions pdf from Mr Karlssen is the attachment. Though its not connected via SPI, i think it must be the upper text.

Thanks for your help.

You use the second constructor for the first shield

//UTFT(byte model, int SDA, int SCL, int CS, int RST, int RS);
UTFT(ILI9341_S5P, 51, 52, 5, 255, 6);

You could use any other GPIO pins for the hand-wired second display.

Quite honestly, I would use Adafruit_ILI9341 or any other library than UTFT.
Mind you, UTFT is very useful for SLOW speed hardware testing.

But I would always start with the the recommended Seeed library. Even though it has a horrible set of class methods.

David.

Okay i took a look into the Adafruit_ILI9341 and it's going to be a hell of lot work. But first it would be nice to know if it's possible so simply use MOSI as SDA and MISO as SDL or how is this connected?

Go on. You plug the first Shield into the Arduino.

#include <Adafruit_ILI9341>
Adafruit_ILI9341 tft(7, 6, -1);

If you have two displays:

#include <Adafruit_ILI9341>
Adafruit_ILI9341 tft1(7, 6, -1);  //mounted shield.  (picks up MOSI, SCK from 3x2 SPI header)
Adafruit_ILI9341 tft2(23, 22, -1);  //hand-wired shield connected to 18x2 header

Note that tft1 is the same for Uno, Leo, Mega2560, Zero, Due, ...
tft2 is easy on Mega2560. Other Arduinos require access to SPI header which is covered by shield #1.

In my opinion GFX functions are more intuitive than UTFT. Anything is better than the Seeed TFTv2 functions.

Your decision depends on your personal preferences. There is far more GFX code that is publicly available. But if your existing projects are all UTFT, I would stick with UTFT.

David.

Awesome thanks a lot David. I will test it and then give feedback.

Pins should be the same for UTFT lib I guess? Then I would like to stick to UTFT. Thats the lib I know best cause my older project was completely written on that. It's not necessary that its fast cause the refresh rate is 500ms or 1000ms. The displays are just used for coolant & oil temperature, and fuel level e.g. So those are quite slowly changeing numbers.

Still I will take a deeper look to the adafruit lib. Maybe it's worth the work. So far a huge thanks! 8)

So i tried several examples from the ADAFRUIT_ILI9341 lib but none of the works for me. Here is one sketch for example:

/***************************************************
This is our touchscreen painting example for the Adafruit ILI9341 Shield
----> 2.8 TFT Touch Shield for Arduino with Resistive Touch Screen v2 [STEMMA QT / Qwiic] : ID 1651 : $24.95 : Adafruit Industries, Unique & fun DIY electronics and kits

Check out the links above for our tutorials and wiring diagrams
These displays use SPI to communicate, 4 or 5 pins are required to
interface (RST is optional)
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution
****************************************************/

#include <Adafruit_GFX.h> // Core graphics library
#include <SPI.h>
#include <Wire.h> // this is needed even tho we aren't using it
#include <Adafruit_ILI9341.h>
#include <Adafruit_STMPE610.h>

// This is calibration data for the raw touch data to the screen coordinates
#define TS_MINX 150
#define TS_MINY 130
#define TS_MAXX 3800
#define TS_MAXY 4000

// The STMPE610 uses hardware SPI on the shield, and #8
#define STMPE_CS 8
Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS);

// The display also uses hardware SPI, plus #9 & #10
#define TFT_CS 10
#define TFT_DC 9
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

// Size of the color selection boxes and the paintbrush size
#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;

void setup(void) {
// while (!Serial); // used for leonardo debugging

Serial.begin(9600);
Serial.println(F("Touch Paint!"));

tft.begin();

if (!ts.begin()) {
Serial.println("Couldn't start touchscreen controller");
while (1);
}
Serial.println("Touchscreen started");

tft.fillScreen(ILI9341_BLACK);

// make the color selection boxes
tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED);
tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW);
tft.fillRect(BOXSIZE2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN);
tft.fillRect(BOXSIZE
3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN);
tft.fillRect(BOXSIZE4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE);
tft.fillRect(BOXSIZE
5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA);

// select the current color 'red'
tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
currentcolor = ILI9341_RED;
}

void loop()
{
// See if there's any touch data for us
if (ts.bufferEmpty()) {
return;
}
/*
// You can also wait for a touch
if (! ts.touched()) {
return;
}
*/

// Retrieve a point
TS_Point p = ts.getPoint();

/*
Serial.print("X = "); Serial.print(p.x);
Serial.print("\tY = "); Serial.print(p.y);
Serial.print("\tPressure = "); Serial.println(p.z);
*/

// Scale from ~0->4000 to tft.width using the calibration #'s
p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());

/*
Serial.print("("); Serial.print(p.x);
Serial.print(", "); Serial.print(p.y);
Serial.println(")");
*/

if (p.y < BOXSIZE) {
oldcolor = currentcolor;

if (p.x < BOXSIZE) {
currentcolor = ILI9341_RED;
tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
} else if (p.x < BOXSIZE2) {
currentcolor = ILI9341_YELLOW;
tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
} else if (p.x < BOXSIZE
3) {
currentcolor = ILI9341_GREEN;
tft.drawRect(BOXSIZE2, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
} else if (p.x < BOXSIZE
4) {
currentcolor = ILI9341_CYAN;
tft.drawRect(BOXSIZE3, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
} else if (p.x < BOXSIZE
5) {
currentcolor = ILI9341_BLUE;
tft.drawRect(BOXSIZE4, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
} else if (p.x < BOXSIZE
6) {
currentcolor = ILI9341_MAGENTA;
tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
}

if (oldcolor != currentcolor) {
if (oldcolor == ILI9341_RED)
tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED);
if (oldcolor == ILI9341_YELLOW)
tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW);
if (oldcolor == ILI9341_GREEN)
tft.fillRect(BOXSIZE2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN);
if (oldcolor == ILI9341_CYAN)
tft.fillRect(BOXSIZE
3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN);
if (oldcolor == ILI9341_BLUE)
tft.fillRect(BOXSIZE4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE);
if (oldcolor == ILI9341_MAGENTA)
tft.fillRect(BOXSIZE
5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA);
}
}
if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) {
tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor);
}
}

If i upload it to the Arduino and restart it, the screen turns on and then turns black. Nothing more happens.

Go on. Of course the pasted code will not work with your Seeed Shield. The Seeed Shield has different DC, CS pins. And does not contain a STMP610 chip.

I suggest that you try the regular Adafruit_ILI9341 examples and edit the constructor e.g.

#define TFT_RST  -1
#define TFT_DC    6
#define TFT_CS    5
#define TFT_MOSI 51
#define TFT_MISO 50
#define TFT_CLK  52

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
// If using the breakout, change pins as desired
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

Please do not post arbitrary sketches. Please quote library example by name. And paste any edited lines (in a Code window).

Your Shield should work just fine. But you must give accurate information.
i.e. describe each step and success e.g. Yes / No
i.e. describe problem with which (No) step

David.

Alright David I really have no idea how you did that but you literally are a magician. The shield plugged directly to the Mega Board is now doing the graphics test :o

Please help me understand. You defined MOSI, MISO and CLK on Pins that are not even connected. So how does that work?

How do I have to connect the display with cables to the mega board? I'm just curious because as you know there are two displays that need to be connected to one mega board.

I suggest that you get one shield working with Seeed, Adafruit, UTFT.
Run all the examples that come with each library.

Gain experience and familiarity with the Shield.

When you are happy, read my earlier messages about a second screen.

Oh, MOSI, MISO and CLK on Pins that are not even connected download and print the Mega2560 pinout diagram.
Seriously, it is much more useful on paper. And you see which digital pin number is assigned to each of 3x2 SPI pins, I2C pins, UART pins, PWM pins, ...

David.

So it took quite a long time to get both Displays running but now they do. And they run on UTFT which is very satisfying for me.

Thanks a lot David!!! 8)

This topic was automatically closed after 70 days. New replies are no longer allowed.