Esp32 switching multiple MISO / MOSI pins

Hello,

For a project I bought this TFT, touch and esp32 combo board. https://a.aliexpress.com/_vP7LsJ
It was pre programd and works quite nice.


Now I'm trying to interface with it with the library GitHub - Bodmer/TFT_eSPI: Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips bud I can't het it to work properly. After looking at the provided schematic I discovered that the SPI bus of the TFT is connected to different pins than the Touch screen.

TFT:
MOSI 12
MISO 13
SCK 14
CS 15

Touch:
MOSI 32
MISO 39
SCK 25
CS 33

When I change the library to the TFT pins I can use the TFT. And if I change it to the Touch pins I get data from the touchscreen bud no image.

  1. Can anybody help me with switching the SPI bus between these pins in program?

  2. Why would the creaters of the board make it this instead of relying on the CS pin?

Thanks in advance.
Greetings,
Sander

Edit: pictures

SPI should support multiple devices (sharing MOSI, MISO, SCK) - made possible by each having a unique CS.

PE - I've been trying to get a SPI TFT and an I2C-based touchscreen to cooperate in ESP32 situation.
Howbeit, I have the TFT on VSPI and a couple of thermocouples on the HSPI - and that goes OK.

Yes, I know. Norm

Yes exactly. I don't understand why you would not use that capabilitie?

It is a ready made PCB so I can't change that. Somebody who got that library working with 2 sets of SPI pins?

For people who are reading this and have the same problem. I managed to change the library so it switches to the other MISO, MOSI, SCK pins and back when the library is accessing the touchscreen.

Hello,

Here the same issue, can you plz. share your solution in detail?

I just uploaded my solution to github. I hope that will help you.

Thanks for sharing this information, 2 day' s struggeling with this board.
I' m quit a newbie for this technics, but want to learn.
Do you recommend a sketch to start with, to have buttons etc?

But for now this information will help me!

Greetings, Cor

I installed your TFT_eSPI library(renamed to TFT_eSPI befoer import, installed it trough Arduino IDE, install zip file
is this the right or am i missing something?
I adjust the user_setup.h file as mentioned conform my lcm drawing, but no touch at all, other test sketches like the matrix sketch is no longer working.

so any tips or manual for me to get it working?

Does the screen work?

I've compared the schematics and I think it should be this:

#define TFT_MOSI 13

#define TFT_MISO 12

#define TFT_SCLK 14

#define TFT_CS 15

#define TFT_DC 2

#define TFT_RST 12

#define TFT_BL 27 (<< Edit)

#define TOUCH_MOSI 13

#define TOUCH_MISO 12

#define TOUCH_SCLK 14

#define TOUCH_CS 33

By the way, io27 is connected to the becklight. I just make it permanently HIGH in my setup() to turn it on at its highest setting.

Yes, screen with TFT_eSPI works, but no touchscreen.
With the your librarie its not working, i tried with original library the matrix sketch, does work.
With your library not.

I already adjusted the pin assignment, as you suggested.

It's the right way to remove the library and import your zip into the ide?

I now see that you have another pin assignment by the touch parameters that i had, i wil try this and give you feedback.

Next try will be sunday :slight_smile:

Arduino ESP32 TFT test:

With special TFT_eSPI
Proposed ports modified
Then upload from Test_Touch_Controller.ino
Comes with error missing TFT_driver ILI9341 driver
Copied from original TFT_eSPI
Upload again, then missing touch.h file in extensions
Also copied from original
Then upload, no errors
Then serial monitor: x:8191 Y:8191 z:4095
setup_user.h modified to ST7796 driver

Same output

In setup_user.h
#define TFT_RST 12 modified #define TFT_RST -1
Then output x:0 y:0 z:4095

With sketch demo_3D_cube white screen
Tried different drivers, no success
Then command #define USE_SEPERATE_TOUCH_BUS out, then sketch will work with your Library.

Next test:

In the user_setup.h the line //#define TFT_MISO 12 is commanded out
Then upload the following sketch:

#include <TFT_eSPI.h>
#include <TAMC_GT911.h>
#include <DigitalRainAnimation.hpp>

#define TOUCH_SDA  33
#define TOUCH_SCL  32
#define TOUCH_INT 21
#define TOUCH_RST 25
#define TOUCH_WIDTH  320
#define TOUCH_HEIGHT 240

TAMC_GT911 tp = TAMC_GT911(TOUCH_SDA, TOUCH_SCL, TOUCH_INT, TOUCH_RST, TOUCH_WIDTH, TOUCH_HEIGHT);

TFT_eSPI tft = TFT_eSPI();
DigitalRainAnimation<TFT_eSPI> matrix_effect = DigitalRainAnimation<TFT_eSPI>();

void setup() {
  Serial.begin(115200);
  Serial.println("TAMC_GT911 Example: Ready");
  tp.begin();
  tp.setRotation(ROTATION_NORMAL);

 tft.begin();
  tft.setRotation(0);

  matrix_effect.init(&tft);
  matrix_effect.setTextColor(0, 0, 255);
  matrix_effect.setHeadCharColor(0, 255, 255);

  
}

void loop() {

matrix_effect.loop();


  tp.read();
  if (tp.isTouched){
    for (int i=0; i<tp.touches; i++){
      Serial.print("Touch ");Serial.print(i+1);Serial.print(": ");;
      Serial.print("  x: ");Serial.print(tp.points[i].x);
      Serial.print("  y: ");Serial.print(tp.points[i].y);
      Serial.print("  size: ");Serial.println(tp.points[i].size);
      Serial.println(' ');
    }
  }
}

Screen has the matrix affect and i have touchscreen output in monitor

So....
It works?

Well, now trying to find a example how to show a button on the screen and read the touch parameters and gain an action.

Any idea why your solution is not working on my TFT board? , is from the same reseller.

So..., still in a leraning proces :slight_smile:

No, no idea. Hart to tel from behind my computer.

You can always try the touch_calibrate example.

Yes, very difficult without the hardware, i understood.

But for now thanks for the help so far!

I'm struggeling ahead :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.