arduinospirp2040

SB Components Micro RP2040 and ST7789 2.4 TFT LCD SPI display not working together using any library


I have a board from SB components called the Micro RP2040 (Link to this product - here).

With this I also have a 2.4 inch SPI TFT LCD screen with an ST7789 controller (Link to the screen - here, it's on that page just scroll down)

Before using the RP2040 Micro board to run this display, I decided to start by using an ESP32 Dev Module to try out the display and see how it works. This display was advertised as having an ILI9341 controller but using the Adafruit ILI9341 library I was not able to fill the full screen with the content being printed. I diagnosed and fixed this error from this thread on the Arduino Forum.

From @david_prentice's answer in that thread I was able to figure out that my display has a ST7789 controller instead of the ILI9341 that it was advertised to have. This was a great relief as it proved that the display does work properly when used with the Adafruit ST77XX library.

I used this same library and changed the code for the pinout of the RP2040 Micro, when I connected it all up (through 10k resistors because the RP2040 board is 5V), all I get is a white screen.

Before with the ESP32 it was working perfectly and here's an image of that -

display with esp32

another sketch

display with esp32 2

With the RP2040 connected and turned on all I get is

white screen with rp2040

My connections to the RP2040 Micro board

TFT Display Pin RP2040 Pin
TFT_CS GPIO 17
TFT_RST GPIO 16
TFT_DC GPIO 15
TFT_SDA (MOSI) GPIO 19
TFT_SCK GPIO 18
TFT_VCC 3.3V
LED 3.3V
TFT_GND GND

I'm doing this pinout with all the pins except VCC and GND (cause VCC has a 3.3v that I can connect to) going through a 10k resistor to the board.

I tried with TFT_eSPI library and I wasn't even able to get it running with the ESP32... neither the RP2040 Micro board worked.

Although TFT_eSPI is the right library for RP2040 based board, it did not work..

Code I'm using for drawing the spiderweb using the ESP32 -

#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
#include <SPI.h>

#define TFT_DC 2
#define TFT_CS 15
#define TFT_MOSI 23
#define TFT_CLK 18
#define TFT_RST 4
#define TFT_MISO 19

Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST);

void setup() {
  Serial.begin(9600);
  tft.init(240, 320);
  tft.fillScreen(ST77XX_BLACK);
  drawPattern();
}

void loop() {
}

void drawPattern() {
  int centerX = tft.width() / 2;
  int centerY = tft.height() / 2;

  for (int radius = 10; radius <= 120; radius += 10) {
    uint16_t color = (radius / 10) % 2 == 0 ? ST77XX_BLUE : ST77XX_CYAN;
    tft.drawCircle(centerX, centerY, radius, color);
  }

  for (int angle = 0; angle < 360; angle += 15) {
    float radians = angle * 3.14159 / 180;
    int x1 = centerX;
    int y1 = centerY;
    int x2 = centerX + 120 * cos(radians);
    int y2 = centerY + 120 * sin(radians);
    uint16_t color = (angle / 15) % 2 == 0 ? ST77XX_RED : ST77XX_YELLOW;
    tft.drawLine(x1, y1, x2, y2, color);
  }

  tft.fillCircle(centerX, centerY, 10, ST77XX_GREEN);
}

This worked with the ESP32 but when I changed the pin numbers so that I could connect it to the RP2040 Micro board it did not work with the RP2040.

Also with the ESP32, all the colors are inverted, but that's another issue I can fix myself.

Please help, thank you.


Solution

  • I've managed to fix this problem effectively and have concluded that the problem was with the board.

    I had to find the Github repo for the board.

    There I was able to find the pinout for the board and one thing immediately caught my eye and that was the reversal of pin 16 and 18 on the pinout.

    GPIO16 was marked as GP18 on the silk screen and GPIO18 was marked as GP16 on the board.

    This was the root cause of all the problems because both of these pins were actively being used by the SPI interface.

    Below I've attached the correct pinout for this board.

    pinout for Micro RP2040

    There is this note on the Github repo too which I think should be printed on the packaging too, this is a pretty serious fault.

    Note on the github repo

    Below you can see my board, it shows on the left side

    Where it should've been,

    My board

    This was the issue and as soon as I connected the pins following the correct pin scheme on the board, the display worked perfectly.

    working display yayy :)