Cannot Compile TFT_eSPI for ESP32-C6: Persistent "'VSPI' was not declared" Error

Hello everyone,

I’m having a persistent issue trying to get the TFT_eSPI library to compile for a Waveshare ESP32-C6-LCD-1.47 board in PlatformIO. No matter which configuration method I try, I consistently get the same compiler error:

.pio/libdeps/ESP32_C6_env/TFT_eSPI/Processors/TFT_eSPI_ESP32.c:17:31: error: 'VSPI' was not declared in this scope; did you mean 'SPI'?


This error indicates that the library is trying to build for an older ESP32 model and is not recognizing the necessary flags to use the modern driver for RISC-V chips like the ESP32-C6.

What I Have Tried:

  1. User_Setup.h Method: Creating User_Setup.h and User_Setup_Select.h files in the .pio/libdeps/TFT_eSPI folder with the correct C6 definitions.

  2. platformio.ini Build Flags: Forcing all settings via build_flags, including the critical -D ESP32_S3_MODE=1 and -D USER_SETUP_LOADED=1.

  3. Local Library: Copying the entire TFT_eSPI library into my project’s lib folder and placing the configuration files directly inside it.

  4. Changing Platform Versions: I have tried using both the latest official platform = espressif32 and a specific community version (pioarduino).

  5. Full Clean: Between every attempt, I have run the “Clean” command and manually deleted the entire .pio folder to ensure no cached files are being used.

Despite these efforts, the compiler seems to be ignoring the configuration and always falls back to the default, incompatible driver.

Has anyone found a definitive method to force TFT_eSPI to compile correctly for the ESP32-C6 within PlatformIO? It feels like something in the build environment is overriding all configuration attempts.

Here is my most recent platformio.ini:

[env:ESP32_C6_env]
platform = espressif32@^6.5.0
board = esp32-c6-devkitm-1
framework = arduino
monitor_speed = 115200

lib_deps =
    h2zero/NimBLE-Arduino
    bodmer/TFT_eSPI

build_flags =
    ; --- Flags for ESP32-C6 USB ---
    -D ARDUINO_USB_MODE=1
    -D ARDUINO_USB_CDC_ON_BOOT=1


Any help would be greatly appreciated!

The ESP32-C6 requires the newer Espressif Arduino Framework 3.x.
You have to use pioarduino’s espressif32 platform to get 3.x versions:

platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip

The change from 2.x to 3.x comes with a few breaking api changes.
Pease read Migration from 2.x to 3.0 - - — Arduino ESP32 latest documentation

Afaik then the build-flag -DUSE_HSPI_PORT should fix this issue.
Please see ESP32-S3-LCD-1.28 display not working - #15 by maxgerhardt