Not sure what format this code is in so how to use it?

Hi,

First post here and apologies if it’s in the wrong place.

I came across this CO2 monitor project:

I ordered the sensor, tacked it onto an ESP32 and used the basic code offered on the link above (I’m an old hardware / electronics tech, not a coder) to integrate the sensor into my Home Assistant setup using ESPHome and everything is working fine. :wink:

However, I would also like to build another using the LilyGO TTGO T-Display ESP32 (built in display) as shown in the link and using the stock code that comes with the kit version but understand the code is setup for PlatformIO and I have no experience of that IDE.

Or didn’t till this morning as I now have it all installed and have managed to install some simple code (Arduino Blink) to an ESP32 and that is also working fine.

So my question is how should / would / could I correctly make use of the code seen here please?:

I’ve tried opening the local folder (assuming it’s already in PlatformIO format) and that seems to work but I get errors when I try to compile so I’m probably doing it wrong?

Any pointers very welcome please. :wink:

Cheers, T i m

Ok, I think I might have got a bit further as I read elsewhere to try ‘Import Arduino’ rather than open and it seems to have worked to some degree (the code then uploaded to a generic ESP32 etc). I can’t tell if it worked fully as I don’t have the screen but I am confused why if it was in Arduino IDE format why the Arduino IDE didn’t work in the first place and why the mention of PlatformIO IDE?

Now I just need to wait for the parts to arrive and see how / where I configure the WiFi settings etc.

Cheers, T i m

No, the build system is PlatformIO. The code is written against the Arduino API (Arduino.h) and the used libraries (most importantly TFT_eSPI.h). That’s what matters most here when you port it to a different board target as you have to understand how to interact with these libraries different (or give them different setup information) for your differing board.

The project uses the TFT_eSPI library with a specific configuration in terms of where the display is connected (and the featureset of the library).

The pins (SPI bus, MISO/MOSI/SCLK,CS)and display driver (ST7789 in the reference) and geometry (width + heigh) differ from display to display / board to board depending on how it’s internally or externally connected.

A first sensible step is to set up a minimal TFT_eSPI project for your LilyGO TTGO T-Display in PlatformIO with correct pin information. See

for reference.

Notice also that TFT_eSPI already has a premade header file for your board: TFT_eSPI/User_Setups/Setup25_TTGO_T_Display.h at master · Bodmer/TFT_eSPI · GitHub.

That said, you could also try a “shot in the dark” by either copying the macro information from that file into the build_flags of the platformio.ini, or relpace them by using the documented

build_flags =
  -D USER_SETUP_LOADED=1
  -include $PROJECT_LIBDEPS_DIR/$PIOENV/TFT_eSPI_ID1559/User_Setups/Setup1_ILI9341.h

(amke sure to adapt path, TFT_eSPI_ID1559 may be TFT_eSPI now).