-->
Page 1 of 3

I Need Help w XPT2046 Touch on 2.4" TFT Display + ESP8266!

PostPosted: Fri Apr 21, 2017 12:29 am
by TechShopJim
I'm having real trouble getting the 2.4" TFT with SPI touchscreen to work with any form of the ESP8266-12E or F. I can get the TFT display working just fine, but even with the display pins disconnected, I get no touch response at all.

There are a lot of posts on the web about people having trouble getting touch to work with the ESP8266, and some posts where people get it working, but provide somewhat cryptic or less-than-complete information on how they did it, including the one on this board at viewtopic.php?f=32&t=5560.

However, I have read these posts over and over, tried and retried the instructions many times, tried every library I can get my hands on, and I really believe that I followed the steps exactly, but I'm not getting any touch response at all.

I have tried a half dozen different of these 2.4" SPI TFT touch display units (all the same 2.4" TFT with SPI touch, same board, etc.), and many different ESP8266-12Es. I am using the Adafruit Huzzah Feather and I've tried all three that I have (I removed the stock ESP8266-12E module and soldered a couple of 1x8 female headers where the ESP used to be and I solder 1x8 2mm make pins on all my ESPs so I can plug them into the Huzzah Feather to program them, then pop them into my project board. I've been doing this for a long time and it works really well. I even wrote an instructable on it at http://www.instructables.com/id/Foolproof-ESP8266-12E-Programming-and-Use/).

Anyway, I have tried to really boil this problem down to the bare essence.

I wrote[/url] a really simple sketch, and put together a super basic test PCB that uses the wiring from spapadim's post in the thread above (viewtopic.php?f=32&t=5560&start=4#p29431).

Here's my circuit (schematic and board):

Image

Here's my single-sided PCB (cut on an OtherMill):

PCB bottom view:
Image

PCB top view:
Image

The PCB has traces only on the bottom, and female headers on the top to plug in the Huzzah Feather, the TFT display, and the voltage regulator which is actually a buck converter mounted on a small PCB to have the same pinout as an LM317). Super simple.

Here's my Arduino sketch for the ESP8266-12E:

Code: Select all/*
 * Super-Simple ESP8266-12E/F + 2.4" TFT SPI Touchscreen Test
 * Why Doesn't This Work?
 * A touch is never received it seems.
 *
 * Using an Adafruit Huzzah Feather with ESP8266-12E
 *
 * Wiring is:
 * TFT/TOUCH      ESP-8266-12E
 * ------------   ------------
 * VCC            +3.3v from external regulator
 * GND            GND
 * CS             GPIO4
 * RESET          GPIO5
 * D/C            GPIO2
 * SDI (MOSI)     GPIO13 (Also to T_DIN)
 * SCK            GPIO14 (Also to T_CLK)
 * LED            +3.3v from external regulator
 * SDO (MISO)     GPIO12 (Also to T_DO)
 * T_CLK          GPIO14 (Also to SCK)
 * T_CS           GPIO16
 * T_DIN          GPIO13 (Also to SDI (MOSI))
 * T_DO           GPIO12 (Also to SDO (MISO))
 * T_IRQ          GPIO0
 */
 
#include <XPT2046.h>

XPT2046 touch(/*cs=*/ 16, /*irq=*/ 0);

void setup() {

  pinMode(2, OUTPUT); // Blue LED on the ESP8266 -- Will flash quickly until touch is detected, then go solid ON

  WDTreset();
  delay(1000);
  WDTreset();
  touch.begin(240, 320);

  while (!touch.isTouching()) {
    WDTreset();
    delay(50);
    digitalWrite(2, LOW); // ESP's blue LED ON
    WDTreset();
    delay(50);
    digitalWrite(2, HIGH); // ESP's blue LED OFF
  }

  // We are out of the loop now, so a touch must have been detected!
  digitalWrite(2, LOW); // ESP's blue LED ON
}

void loop() {
  // Do nothing
}

void WDTreset() {
  ESP.wdtEnable(15000); // Cause the WDT to wait 15 seconds before trying to reset.
                        // Works great, is an alternative to trying to disable the ESP's WDT.
}


When I run the sketch, I would expect that no matter where I touch, the LED should immediately stop flashing.
However, I don't get any response to the touch on the screen. It should break out of the while loop and turn the LED on (or even off). But it just keeps flashing indicating that it is still in the WHILE loop.

Can anyone see what I'm doing wrong here, or why it isn't working?

Thank you so much!

Re: I Need Help w XPT2046 Touch on 2.4" TFT Display + ESP826

PostPosted: Fri Apr 21, 2017 12:52 pm
by NailBuster
Many people have used my webpage info/files successfully....

Let me know if they work for you.

Re: I Need Help w XPT2046 Touch on 2.4" TFT Display + ESP826

PostPosted: Sat Apr 22, 2017 2:38 pm
by TechShopJim
Hi Nailbuster...

First, thank you for all your hard work in testing and documenting this! Your work is fantastic!

I had tried following your instructions before I made my post above, but without success.

Today I followed your instructions meticulously, made a new PCB based exactly on your wiring, re-downloaded the libraries, loaded the example programs successfully, but still NO TOUCH!!!

I even tried the instructions linked off your page called "Pingback: Smart Plug" at http://usemodj.com/2016/03/21/esp8266-d ... ini-board/ , made the indicated mod to "XPT2046.cpp" by commenting out "SPI.begin();", and loaded the sketch "ESP8266_240x320_LCD_Touch_Buttons.ino" from there, but still NO TOUCH!!!

I get graphics fine, but no touch at all.

I have tried different displays, as well as different ESP8266-12E and ESP8266-12F modules.

What am I doing wrong here? Could it be the Adafruit Huzzah Feather? I don't think it is, because my real project board is wired the same way as your wiring diagram, and uses the ESP8266-12E directly without the Huzzah Feather. Is there a pull-up or pull-down that I'm missing that is on the NodeMCU or WeMos but not on the Feather or the raw ESP8266-12E?

Thanks!

Re: I Need Help w XPT2046 Touch on 2.4" TFT Display + ESP826

PostPosted: Tue Apr 25, 2017 11:14 am
by NailBuster
Looks like you've really tried a lot.... is it possible your screens aren't using an XPT2046 controller?

Have you tried it on an actual NodeMCU or WeMos board? Those are the only boards I've worked with.....