Connecting Adafruit 2.8" TFT Touch Shield to a Photon

What @peekay123 said :wink:

In the GitHub link I provided above was this

#if defined (SPARK)
  #include "application.h"  // <-- this used to be what's now better called "Particle.h"
  #if defined(ARDUINO) && ARDUINO >= 100
    #include "Arduino.h"
    #include "WProgram.h"
  // here could follow some of the includes only needed on Arduino
  // see bellow

After adding this the other error: expected '=' ' ' ' ' 'asm' or 'attribute' before 'PROGMEM' should be gone too.
Otherwise just add

#ifdef PROGMEM
#  undef PROGMEM
#define PROGMEM

after the Particle.h include.

1 Like

Is the wiring for this different if you want to have your TFT touch shield have touch screen instead of just displaying. Would you have to wire the Photon to the shield differently?

Does that code work with particle dev? Because when they say pgmspace.h: No such file or directory. Your solution only works when you are using Arduino right? Because the software for Arduino already has those files preinstalled. However, in the Particle dev I don’t have the files installed and don’t know where is it.

Have you actually looked at and read the link I even quoted above?

I can repost the same thing

This solution works when it is an Arduino with __AVR__ declared by including that header and #else by exactly not including it.
You won’t need that since the non-AVR processors don’t have the distinction between accessing pgmspace or normal RAM, so no need for any special treatment.
Since you are not including pgmspace.h you definetly won’t get the no such file error for that not needed file.

Or as said in the linked GitHub page

That depends on the exact shield you’re using?
Got a link?

I’m using the TFT touch shield 2.8" version 2. Link:

That link clearly states

and on the board you see a silk note TS CS #8 - that’s the SPI chip select for the touch screen.
So you only need one extra pin to control the CS pin on the display to actually talk to the touch controler.

Here yo can find the wiring info for TFT, resistive TouchScreen & SD

Note that the first three pins are always the same (SPI CLK, MOSI, MISO), only the CS pins need to be seperate (and the TFT also wants a D/C pin).

So, there is only a pin difference between touchscreen and display on the TFT touch shield? What is a silk note? What pin do I have to connect to? I’m really sorry if I’m wasting your time. I just don’t understand much because I am new to everything

The white printing on the bottom of the PCB is called silk screen and the text informs (notes) about pin mapping and other things.

You could use any free IO pin on the Photon (connected to pin #8 on the shield) for that, you’d just inform the library that does the talking to the touch controler which pin to use.

(image source: 2.8 TFT Touch Shield for Arduino with Resistive Touch Screen : ID 1651 : $34.95 : Adafruit Industries, Unique & fun DIY electronics and kits )

What is a IO pin? So I can wire any female female jumper wire on the Photon to pin #8 on the TFT shield and there will be Touchscreen? If I inform my library?

Hmm, that’s very basic tho’
IO stands for Input/Output and in connectino with the Photon it refers to the pins marked with D0~D7, A0~A5 & DAC, WKP, RX, TX.
These are pins that can be used in code by use off commands like pinMode(), digitalRead(), digitalWrite(), analogRead(), analogWrite() and via specialized interface libraries like SPI, Serial1, Wire - just to name a few.

Generally yes, but with not any background in programming micro controllers that might be a big chunk to chew without a tutor.

Hey ScruffR, do you mind if you rephrase what you said? I don’t understand what you mean. So your saying I shouldn’t have a error? All I know is that my code was made by Arduino Yun but I decided to use a Photon instead to connect with the TFT touch screen. This is the link I use to follow: How would you change the code to make it photon possible?

Oh, I see. Thanks for the tip.

Is there a example code for a TFT touch shield to a Photon Touch screen example code anywhere? All I found was Arduino examples of touchscreen in the TFT touch shield and I don’t know how to change it. I just want to test the code how to see if my wiring is correct from my Photon to my TFT touch shield.

For this the silk print offers some help.
It states that the touch controler is an STMPE610 and searching this very forum for that term brings up these threads.
I guess one of them should contain some useful information

1 Like

Hey everyone,
Just wanted to put a note on here for anyone trying to connect the Adafruit 2.8" TFT Resistive Touch Shield to a Photon, through a Particle Shield Shield. I couldn’t get it to work, then figured this out and thought I’d share the knowledge…

The TFT shield is hardwired to use the default hardware SPI pins for Arduino, but on the Shield Shield, these pins actually map to Particle’s SPI1, not SPI (there are two SPI ports on the Particle…I’ve read there is perhaps a third?).

To make it work, you need to change any instance of “SPI.xxxxx” to “SPI1.xxxxx” in the following library:


For example, change:

SPI.beginTransaction(SPISettings(16000000, MSBFIRST, SPI_MODE0));


SPI1.beginTransaction(SPISettings(16000000, MSBFIRST, SPI_MODE0));

These occur in 6 places in the Adafruit_ILI9341.cpp file (Line numbers approximate):

Line 38:  SPI1.transfer(c);
Line 107: SPI1.begin();
Line 108: SPI1.setClockDivider(SPI_CLOCK_DIV2);	//Full speed @18MHz
Line 109: SPI1.setBitOrder(MSBFIRST);
Line 110: SPI1.setDataMode(SPI_MODE0);
Line 405: r = SPI1.transfer(0x00);

This will have your Particle talking to the correct pins of the TFT shield, through the Shield Shield. And of course, if coming from Arduino, you will need to do the other typical porting changes covered in this and other threads.

Hope this helps someone! :wink:


I am trying to use a tft screen similar to the one talked in this thread but I am not able to use the library in particle web ide. I got a bunch of errors (I thought about copying them here but it is a huge list).

Is the library updated somewhere? Maybe I am getting the wrong version. The one included in web ide says “not ported”. I tried about SPI to SPI1 as the previous message says but I still get errors.

Checking errors, most of them seem to come from BRR and BSRR members which not exists in GPIO_TypeDef

Maybe its useful, my tft screen has these pins: PIN_NO_TEXT, LCD_RST, LCD_CS, LCD_RS, LCD_WR, LCD_RD where PIN_NO_TEXT is the A5 in an arduino UNO board. Which PIN_NO_TEXT I mean a pin without silk name.

This is very similar to mine

I don’t know that display, but I’d try to use the SD_DI, SD_DO, SD_SCK, LCD_CS, since on the LCD side there is no clock pin so I’d deduct (without looking at the datasheet tho’) that LCD_RD, LCD_WR are note actually meant as SPI pins and since most SPI displays with SD card share the SPI pins (apart from CS) that would fit.

So, if I have this line to initialize the library:

A2 seems to be CS, A1 -> DC and A0 ->RST

Cs and RST are in the LCD side: LCD_RST, LCD_CS. But DC is not in the LCD side neither it is on te SD side.

Also, I don’t know which pins I should connect on SD_D1, SD_D0 and SD_SCK.

I found this on the documentation a friend gave me:

LCD_RST — A4 — LCD bus reset signal
LCD_CS — A3 — LCD bus chip select signals
LCD_RS — A2 — LCD bus command /data selection signal
LCD_WR — A1 — LCD bus write signal
LCD_RD — A0 — LCD bus read signal

About SD pins,
SD_SS ---- 10 ---- SD card SPI bus chip select signals
SD_DI ---- 11 ---- SD card SPI bus MOSI signal
SD_DO ---- 12 ---- SD card SPI bus MISO signal
SD_SCK ---- 13 ---- SD card SPI bus clock signal

Those numbers correspond to UNO/Mega2560 identification

That’s not D1/D0 but DI/DO corresepinding to MOSI/MISO

Also looking at the datasheet on the page you linked above this is not an ILI9341 display, so the lib won’t work IMHO and the pinout you got of your friend doesn’t seem to use SPI for communicating with the display either.
Have a look at the datasheet :wink:

I am not sure but I think it is an ILI9341 controller. watching this screen on ebay: it has that controller and it is quite similar to the one I have.

I am not sure, the documentation is so simple. Just what I wrote here and a list of examples contained in ?? no cd or anything similar.

I will keep looking for a way to make it working. I will ask for an arduino uno to see if it works there with adafruit libraries.