The overview, with examples running, is on the board page.

The LilyGO TTGO T-Display

A classic ESP32 with a 1.14 inch 135x240 ST7789 color screen on its own SPI lines, and two buttons, on GPIO 0 and GPIO 35.

What it is

The same classic ESP32 as the ESP32 DevKit V1, on a black board 51.5 by 25 mm with the screen filling the middle. Two twelve-pin rows run down the long edges, 0.9 inch apart, so it straddles a breadboard with one row free on each side. A USB-C socket goes to UART0, which is the serial monitor, and a small JST socket takes a LiPo cell.

The screen and both buttons are wired inside the board, as on the real one, so a first sketch needs no other parts. The board has no user LED.

The pins

The silkscreen numbers are the GPIO numbers. Top to bottom as the drawing has them, with the screen facing you and the USB-C socket at the bottom:

Left Right
GND 3V3
GND 36
21 37
22 38
17 39
2 32
15 33
13 25
12 26
GND 27
GND GND
3V3 5V

36, 37, 38 and 39 are inputs only, with no pull-up or pull-down of their own. Wire uses 21 for SDA and 22 for SCL. There are no TX or RX pins: GPIO 1 and 3 go only to the USB chip. There is no EN pin either. 5V is the USB rail.

2, 12 and 15 are strapping pins on the chip. Mokxi does not model strapping, so the board starts whatever is wired there; on a desk, a pull-up on 12 stops it booting.

The GPIOs inside the board

These are wired to the parts on the board and no wire can reach them.

GPIO What it is wired to
19 Screen MOSI
18 Screen SCLK
5 Screen CS
16 Screen DC
23 Screen reset
4 Screen backlight
35 BUTTON1, with a pull-up on the board
0 BUTTON2, which is BOOT
34 The battery divider (not modeled)
14 Switches the battery divider (not modeled)

SPI.begin() with no pins uses 18, 19, 23 and 5, which on this board are the screen's lines. For a second SPI device, name free pins: SPI.begin(sck, miso, mosi, ss).

The screen

The screen is the ST7789 part at its 135x240 size. The ST7789 has 240 by 320 pixels of memory, and this glass is a window into it from column 52 and row 40, so a driver has to add those offsets or it draws where nobody can see. The glass is IPS and shows the controller's colors inverted until the driver sends INVON. TFT_eSPI does both, as every ST7789 driver does. A hand-written driver that leaves INVON out gets a photographic negative, here as on the board.

A sketch for this board needs no User_Setup.h here. LilyGO ships a TFT_eSPI setup for the board, Setup25_TTGO_T_Display.h, and Mokxi has it built in. If the sketch names no TFT pins, TFT_eSPI gets the board's:

#define ST7789_DRIVER
#define TFT_WIDTH 135
#define TFT_HEIGHT 240
#define CGRAM_OFFSET
#define TFT_MOSI 19
#define TFT_SCLK 18
#define TFT_CS 5
#define TFT_DC 16
#define TFT_RST 23
#define TFT_BL 4
#define TFT_BACKLIGHT_ON HIGH

On a real board you install that setup in the TFT_eSPI library folder: in User_Setup_Select.h, comment out the default and use Setup25_TTGO_T_Display.h. A sketch that names its own pins keeps them.

#include <TFT_eSPI.h>

TFT_eSPI tft = TFT_eSPI();

void setup() {
  tft.init();
  tft.setRotation(1); // landscape, 240 wide
  tft.fillScreen(TFT_BLACK);
  tft.drawString("T-Display", 20, 20, 4);
}

The backlight is on GPIO 4, and TFT_eSPI's init() turns it on, as upstream does. Pull it LOW and the picture goes out. The panel is not read back: readPixel() on the screen gives black.

The buttons

Both buttons pull their pin LOW while pressed. Press either one on the drawing while the circuit runs to hold it down.

  • BUTTON1, the right one, is GPIO 35. GPIO 35 is input only and has no pull of its own, so the board carries a pull-up, modeled as 100 k. pinMode(35, INPUT) is enough.
  • BUTTON2, the left one, is GPIO 0, which is also BOOT. Use pinMode(0, INPUT_PULLUP).

The runtime names them as arduino-esp32's lilygo_t_display variant does: LEFT_BUTTON is 0 and RIGHT_BUTTON is 35. There is no LED_BUILTIN, as in that variant.

WiFi

It joins Mokxi's simulated network, with the network name and password as properties of the board. There is no radio, no 802.11 and no real internet: Simulated WiFi says what is faithful and what is not.

What is modeled

The DevKit V1 model's chip, whole: one Xtensa LX6 core, GPIO, UART0, the timers, ADC1 and LEDC PWM. The screen is the ST7789 part at 135x240, with its window offsets and its inverting glass, on the GPIOs the board wires it to. BUTTON1 is a pushbutton with a 100 k pull-up, and BUTTON2 is the board's BOOT. The board carries its own program string, so it is offered its own examples, and TFT_eSPI gets LilyGO's setup. Sketches compile in the tab.

What is not modeled

  • The battery connector and its charger.
  • The battery divider on GPIO 34, switched by GPIO 14.
  • Reading the panel back: it gives black.
  • The second core, ADC2, the DAC, touch sensing, Bluetooth and a real radio.

Starter project

T-Display hello writes on the screen with TFT_eSPI and counts presses of the two buttons.

Elsewhere