TFT Display works in Arduino IDE, doesnt in PlatformIO

I am using a TFT Display with driver GC9A01 and TFT_eSPI library.

I run my code in the Arduino IDE and it works perfectly. When I use PlatformIO and import the exact same project there is nothing on the display. My wiring remains the same and I am using a the esp-prog to flash the code for both Arduino and PlatformIO.

The code uploads fine and there are no compile errors.

Am I missing something very basic here? This is the Platformio.ini file

[env:esp32dev]
platform = espressif32

board = esp32dev
framework = arduino

lib_deps = bodmer/TFT_eSPI@^2.5.0
upload_protocol = esp-prog
debug_tool = esp-prog
debug_init_break = tbreak setup

Any guidance much appreciated.

How did you configure the TFT_eSPI library for your specific display? By uncommenting header files in .pio/libdeps/esp32dev/TFT_eSPI? I don’t see configuration macros being present in your platformio.ini.

Hello Max,

I commented out the correct display in the User_Setup.h file in the TFT_eSPI library

#define GC9A01_DRIVER
#define TFT_HEIGHT 240 // GC9A01 240 x 240

#define TFT_MOSI 23 // In some display driver board, it might be written as "SDA" and so on.
#define TFT_SCLK 18
#define TFT_CS   22  // Chip select control pin
#define TFT_DC   16  // Data Command control pin
#define TFT_RST  4  // Reset pin (could connect to Arduino RESET pin)
//#define TFT_BL   22  // LED back-light

I thought editing the User_Setup.h file was the only thing required to indicate which display is being used?

Do I need to add something else to the platformio.ini file?

Thanks for your reply.

Hi, leemanio. I think maybe you are missing the PSRAM configuration size and type!

Try reading this:

Hello Max,

I just tested this with some simple code, same result. The display is working fine in Arduino IDE, not working in PlatformIO. The example code I am using shows as expected in the below code, as soon as I flash using Platformio the screen goes black.

#include <Arduino.h>
#include <TFT_eSPI.h>

TFT_eSPI tft = TFT_eSPI();

void setup() {
  // put your setup code here, to run once:
  tft.init();
  tft.setRotation(0);
  tft.fillScreen(TFT_GREEN);
     delay(1000);
}

void loop() {

    tft.fillScreen(TFT_BLUE);
      delay(1000);
    tft.fillScreen(TFT_RED);
      delay(1000);
  // put your main code here, to run repeatedly:
}

This is my platformio.ini file.


[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps = bodmer/TFT_eSPI@^2.5.23

This is the compiling messages in the terminal output.

 *  Executing task in folder DISPLAY_TEST: C:\Users\DESKTOP-PC\.platformio\penv\Scripts\platformio.exe run 

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.1.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.20007.0 (2.0.7) 
 - tool-esptoolpy @ 1.40500.0 (4.5.0) 
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 34 compatible libraries
Scanning dependencies...
Dependency Graph
|-- TFT_eSPI @ 2.5.23
|   |-- SPI @ 2.0.0
|   |-- SPIFFS @ 2.0.0
|   |   |-- FS @ 2.0.0
|   |-- FS @ 2.0.0
|   |-- LittleFS @ 2.0.0
|   |   |-- FS @ 2.0.0
Building in release mode
Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   7.0% (used 22820 bytes from 327680 bytes)
Flash: [==        ]  22.7% (used 296961 bytes from 1310720 bytes)
=============================================================== [SUCCESS] Took 3.84 seconds ===============================================================
 *  Terminal will be reused by tasks, press any key to close it.

I cant for the life of me understand why it is not working. I have reinstalled platformio extension.

ok, thank you @tiagomagalhaessillva for your advice, I will take a look and report back…

1 Like

I don’t have my computer here now, because I’m not working! But tomorrow I can send my .ino to you, to show you how I did the configurations!
I had the same issues that you! Maybe it can help you.

ok, that would be great.

I did use the CLI and everything is up to date.

Microsoft Windows [Version 10.0.22621.1555]
(c) Microsoft Corporation. All rights reserved.

C:\Users\DESKTOP-PC\Documents\PlatformIO\Projects\DISPLAY_TEST>pio pkg update -g -p espressif32
Platform Manager: espressif32@6.1.0 is already up-to-date
Tool Manager: framework-arduinoespressif32@3.20007.0 is already up-to-date
Tool Manager: tool-esptoolpy@1.40500.0 is already up-to-date
Tool Manager: tool-mkfatfs@2.0.1 is already up-to-date
Tool Manager: tool-mklittlefs@1.203.210628 is already up-to-date
Tool Manager: tool-mkspiffs@2.230.0 is already up-to-date
Tool Manager: tool-openocd-esp32@2.1100.20220706 is already up-to-date
Tool Manager: toolchain-esp32ulp@1.23500.220830 is already up-to-date
Tool Manager: toolchain-xtensa-esp32@8.4.0+2021r2-patch5 is already up-to-date

C:\Users\DESKTOP-PC\Documents\PlatformIO\Projects\DISPLAY_TEST>

With

#include <Arduino.h>
#include <TFT_eSPI.h>

TFT_eSPI tft = TFT_eSPI();

void setup() {
  Serial.begin(115200);
  Serial.println("setup");
  tft.init();
  tft.setRotation(0);
  tft.fillScreen(TFT_GREEN);
  delay(1000);
}

void loop() {
   Serial.println("loop");
   tft.fillScreen(TFT_BLUE);
   delay(1000);
   tft.fillScreen(TFT_RED);
   delay(1000);
}

does it output anything on the serial monitor?

yes, this is the output on the serial monitor

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13192
load:0x40080400,len:3028
entry 0x400805e4
setup
loop
loop
loop
loop
loop
loop

I just found my .ino file on git lab!!

[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
build_flags =
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
board_build.arduino.memory_type = qio_opi
board_build.f_flash = 80000000L
board_build.flash_mode = qio
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
upload_protocol = esptool
lib_deps =
miq19/eModbus@^1.7.0
monitor_speed = 115200
upload_port = COM[6]

There are some configs that I didn’t saw on your .ino… Those are the memory type, flash size and mode!

Unfortunately this hasn’t worked.

I tried with and without, with it gave me lots of compiling errors about sdk, so commented it out and it compiled without error, but still no display.

board_build.arduino.memory_type = qio_opi

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps = bodmer/TFT_eSPI@^2.5.23
;board_build.arduino.memory_type = qio_opi
board_build.f_flash = 80000000L
board_build.flash_mode = qio
board_upload.flash_size = 4MB
upload_port = COM4

Is it something to do with the way it is being compiled? Or something in these files?

I already uninstalled both vscode and platform io and still no joy. The strange thing is I have had this display working with platformio a couple weeks ago

ok, I got the display working (fillscreen test) using platformio.

The code is still not displaying as it should though, i think it is a compiling issue or some configuration in PlatformIO. I will make a new thread with new errors I am facing.

Thanks for your help.