LILYGO ESP32 T-Display Development Board
$19.95 – $21.95
32-bit processor, WiFi / Bluetooth capability and 135×240 color display.
Description
The LILYGO ESP32 T-Display Development Board is a powerful 32-bit 240MHz processor with a large 16MB Flash program memory. It incorporates a full color LCD, 2 user buttons and has WiFi and Bluetooth capability. It packs a lot of power and functionality in a very small package.
LILYGO was previously called TTGO which is why you see that name branded on some of the products or if it comes up in search results.
PACKAGE INCLUDES:
- LILYGO ESP32 T-Display, 16MB Flash, CH9102 USB
- Qty 2 – 1×12 male header pins (Optionally soldered on)
- JST 1.25mm 2-pin battery cable
KEY FEATURES OF LILYGO ESP32 T-DISPLAY DEVELOPMENT BOARD:
- Microcontroller: Xtensa single/dual-core LX6 32-bit
- Clock Speed: 240MHz
- USB Converter: CH9102
- USB Connector: USB-C
- Flash Memory: 16 MB
- RAM: 520Kb
- Display: 135 x 240 full color 1.14″ ST7789V IPS LCD. 4-wire SPI interface
- Digital I/O: 13 (4 are inputs only)
- PWM: 9 channels
- Analog Outputs: 2 channels, 8-bit
- Analog Inputs: 11 channels, 12-bit
- Communications: 1 Serial, 1 SPI, 1 I2C
- Integrated Sensors: IR remote, Hall sensor, temperature sensor, touch sensors, pulse counter, LNA
- Bluetooth: 4.2 and BLE (Bluetooth Low Energy)
- WiFi: Built-in 802.11 b/g/n 2.4GHz
- Buttons: 2 user programmable buttons GPIO0 and GPIO35 + Reset
- Programming: Compatible with Arduino IDE or Micropython
- Pin Spacing: 0.1″ pin to pin x 0.9″ row to row. Breadboard compatible with pins installed.
- Operating Voltage: 3.3V internal power and I/O.
- Power Source: 5V USB, 5V VIN pin, 3.7V lithium battery
The ESP32 based T-Display is a very flexible IOT board with significant processing power. It provides 16 MB of Flash memory for program space and runs at clock speeds of 240 MHz so has a fast processing speed. Because it incorporates an LCD for user feedback and has 2 buttons for user input, it can function as a complete little standalone system right out of the box simply by connecting it to a USB cable. Because of its WiFi and Bluetooth capabilities, it can also be used as a peripheral device in conjunction with another MCU just to provide WiFi, Bluetooth or other unique capabilities that it has.
With the pins installed, the 24-pin board is breadboard compatible and will leave one row of open contacts on each side of the board for making jumper connections. Be sure when using with a solderless breadboard to insert the T-Display into the breadboard by pressing on the pins and ends of the module and do not press directly on the LCD or damage could result.
An enclosure shell is available for packaging the T-Display to help ruggedize it a bit. The enclosure provides access to the user buttons, reset button and battery connections.
If you already have your T-Display module in hand and are in a hurry to checkout it out , you can just plug it into a USB-C cable and it should come up and run the factory test application which shows some graphics, cycles through a couple color screens and then lets you scan for WiFi using the left button or monitor the USB voltage or put the module into or out of sleep mode with the right button.
LEARNING ABOUT THE LILYGO T-DISPLAY MODULE
These are great little displays but information can be a little hard to come by. We’ll cover some of the basics next to make it easier to get started.
Display Characteristics
The display is a 1.14″ IPS TFT LCD with a resolution of 135 x 240.
It uses a 4-wire SPI bus plus Reset and Backlight control. The pins used to drive the LCD are dedicated and are not brought out to the edge of the module.
The display uses the ST7789V driver and is supported by the TFT-eSPI library and is also compatible with the LVGL library.
Pin Map for the T-Display
One of the main limitations of the module is the relatively small number of I/O pins, but the ESP32 chip allows most of the I/O such as the serial ports, SPI and I2C to be multiplexed to any of the other GPIO pins for flexibility.
This diagram shows how the pins are used on the T-Display module. Note that some pins are used internally for driving the SPI LCD display and as inputs for two user buttons. Those pins are not brought out to the main header pins leaving 16 pins available for the user.
Digital I/O
There are 13 GPIO on the board that are brought out to the header pins. The pins are labeled GPIOx. When using with Arduino IDE, the digital pin number is the same as the GPIO pin number, so GPIO2 is referenced as just ‘2’.
There are 3 additional pins not in the count of 13 GPIOs. Pins 21 & 22 are typically reserved for I2C and they have 10K ohm resistor pullups to 3.3V on the T-Display PCB, but can be repurposed as GPIO if needed. Pin 17 is unclear why it isn’t listed as a standard GPIO or if it has some dedicated use. If we figure it out or a customer clues us in, we will update this information for others.
It is important to note that GPIO 36, 37, 38 and 39 are input only pins and cannot be used for outputs. There are also 270pF capacitors connected between pins 36 & 37 as well as pins 38 & 39 as shown below. Depending on the signals being used, sometimes using either 36 or 37 will work OK, but not both. Same with pins 38 and 39. These capacitors have no practical purpose, so if you need to use these input pins without worrying about the capacitors being in the circuit, they can be removed by unsoldering them. They are small enough that a larger soldering iron tip can melt both sides at the same time to make removal easy.
All of the digital I/O support interrupts. In addition they can be configured to have pull-up or pull-down resistors. 9 of the pins support hardware PWM.
There are 3 pushbuttons included on the board. The two on top of the module are user programmable buttons on GPIO0 and GPIO35 which do not come out to the pins on the edge of the board. A third button on the side is a standard reset button that resets the ESP32 microprocessor.
Unlike some other development boards, the T-Display does not have a user controllable LED on any of its pins. The blue LED is a power LED when connected to USB power.
The digital I/O is limited to 3.3V. If using with 5V logic, logic level translators must be used to prevent possible damage.
Analog I/O
Analog to Digital Converters
There are two 12-bit analog-to-digital converters (ADC1 / ADC2) on the ESP32. One or both of the A/D converters can be multiplexed across up to 11 input pins on this module. As with all the I/O pins, the analog inputs are limited to a voltage range of 0-3.3V. Higher voltages can damage the module
12-bit resolution provides readings in the range of 0-4095. The resolution of the A/D converters can be changed to a lower bit depth of 9-12 bits if desired. As with many high performance microcontrollers that have built in A/D converters on the same substrate, some amount of digital noise tends to get into the analog readings. Using a lower bit depth can help to reduce the impact of digital noise since the individual reading steps are larger.
Keep in mind that the A/D converters don’t have a completely linear behavior at the extreme ends of their range. If measuring a 0 to 3.3V voltage range, it may not be possible to differentiate between 0.0V and 0.1V or 3.2V and 3.3V so keep that in mind when interpreting the readings.
The ADC2 converter cannot be used when WiFi is also being used, in that case ADC1 should be used.
Digital to Analog Converters
There are two 8-bit digital-to-analog converters DAC1 (GPIO 25) and DAC2 (GPIO26).
These can provide voltages or waveforms of 0-255 steps on their output.
Communication Buses
The module has the standard built-in buses and in many cases arbitrary GPIO pins can be assigned to those buses.
I2C
I2C is a common 2-wire bi-directional bus with a data line (SDA) and a clock line (SCL).
The default I2C is on GPIO 21 (SDA) and GPIO 22 (SCL) and these are available on the module and not counted in the GPIO pin total. I2C requires pullup resistors to work properly and the T-Display module incorporates 10K pullup resistors on the default GPIO 21 and 22 pins.
You can define other pins to use for I2C if needed by using the command Wire.begin(SDA, SCL); where SDA and SCL are the new pin numbers to use.
If you use other pins and the module you are connecting to does not include pullup resistors, then you will need to add 2.2K to 10K pullup resistors from the SDA and SCL pins you have selected to 3.3V to ensure correct operation.
SPI
SPI is a common 4-wire unidirectional bus which can support higher speeds than the I2C bus and often used for displays, SD cards or other modules that can benefit from a high data transfer rate.
There are 2 SPI buses on the ESP32. The VSPI bus and the HSPI bus. The display occupies the VSPI bus default pins on GPIO pins 5, 18, 19, 23
To assign other pin as an SPI bus, the following code snippet can be used for guidance. In this example, the SPI bus is subsequently used to interface with an SD card and we are using GPIO pins 15, 25, 26 and 27.
#include "SD.h" #include <SPI.h> SPIClass SPI1(HSPI); #define MY_CS 15 #define MY_SCLK 25 #define MY_MISO 26 #define MY_MOSI 27 void setup() { SPI1.begin(MY_SCLK, MY_MISO, MY_MOSI, MY_CS); //Assuming use of SPI SD card if (!SD.begin(MY_CS, SPI1)) { Serial.println("Card Mount Failed"); } else { Serial.println("Mounted SD CARD"); } }
UART Serial
The standard default ESP32 serial pins are not brought out on the T-Display.
Other pins can be assigned to serve serial duty by using a command such as the following to assign a RX and TX pin to use for a serial port. Serial.begin(9600, SERIAL_8N1, RX_PIN, TX_PIN);
Powering the Board
Internally, the board operates on 3.3V.
There are four ways to provide power to the board as outline here. Note that there are some interdependencies as detailed down below.
- 5V applied to the USB-C port through the USB cable
- 5V applied to the 5V VIN pin
- 3.3V applied to the 3.3V pin
- 3.7V Lithium battery applied to the 2-pin JST connector
5V USB Power
Applying power through the USB cable is the first and most common way to power this board. With USB 5V connected via a USB-C cable the following is true:
5V (VIN) pin has 5V (4.8V nominal) on it and can be used to power other 5V circuits.
3.3V pin has 3.3V output power on it supplied by an AP2112K-3.3V regulator and could be used to power other 3.3V circuits. This 3.3V is also powering the on-board circuitry, so you should not pull too much power off this pin. Perhaps 250mA max, but it depends on how the T-Display is being used. Something like WiFi transmit for example takes more power than just running the LCD.
The 5V USB power is also fed to a TP4054 battery charger circuit that outputs 4.2V to the 2-pin JST connector. This can be used to charge any Lithium battery that may be connected. Having both 5V USB and battery power connected at the same time is fine. When USB cable is connected, the battery is charging and when the USB cable is disconnected, the module will continue to run on the battery power.
5V (VIN) Pin Power
With power applied to the 5V (VIN) pin of the module, the following is true:
The 3.3V pin has a 3.3V output on it.
The JST battery connector has 4.8V on it. Basically the 5V pin is connected directly to the battery, so using 5V VIN power is NOT compatible with also using a battery.
There is a blocking diode from the 5V VIN power pin to the 5V USB power on the module. If a USB cable is connected, this will help to provide partial protection for the USB power coming from the computer. If it is planned to use both the 5V VIN pin to power the module and also connect the 5V USB power at the same time, such as to reprogram the module, a diode should be inserted between the 5V VIN pin and its 5V power source with the cathode of the diode facing towards the 5V VIN pin as shown on the left below. This ensures that neither power source can back feed current to the other power source. Whichever power source has the higher voltage will power the T-Display module. The diode can be a Schottky diode or a regular silicon rectifier type diode.
3.3V Pin Power
If 5V power or battery power is not being used on the module, the 3.3V pin can be used to power the module by applying a 3.3V source as an input.
This will put 3V on the 5V pin and the battery connector, so is not compatible with also using those connections. Using this method of powering the module is not recommended unless it is being embedded into a system where only 3.3V power is available.
3.7V Lithium Battery Power
While 3.7V is the nominal battery voltage, the actual battery voltage may range from 4.2V when fully charged down to about 3V. Most batteries will have a over-discharge cutoff circuit built-in. In our test example, the module ran OK down to 2.95V at which point the battery over-discharge circuit cut the battery output off.
The Battery connector is a 1.25mm 2-pin JST style which is very small. A pigtail cable is included with your module so if you have a battery with a larger connector, you can cut and splice on the smaller connector. Higher capacity batteries will tend to have larger connectors. Smaller batteries in the 100mAh range can be found with the small 1.25mm connector if you don’t want to mess with cutting and splicing. Be sure to observe proper polarity as shown here as the polarity of the battery connector may not necessarily match the LILYGO wiring.
If you have a battery with the large 2.54mm JST style connector, for experimenting to make it easy to connect/disconnect, a standard 2-pin header pin can be soldered to the 1.25mm pigtail cable to create a plug-in connection as shown here.
When working with battery power in your own program, be sure to enable battery power, GPIO14 (ADC_EN) by setting it HIGH in your program as shown here.
#define ADC_EN 14 // ADC detection enable port
/* ADC_EN is the ADC detection enable port If the USB port is used for power supply, it is turned on by default. If it is powered by battery, it needs to be set to high level */ pinMode(ADC_EN, OUTPUT); digitalWrite(ADC_EN, HIGH);
If 3.7V battery power is applied to the JST battery connector, the 3.3V pin will have 3.3v output power and the 5V pin will have the 3.7V battery power on it. As the battery voltage droops, so will the 5V pin and eventually the 3.3V output will also start to droop.
If 5V USB power is then connected, the JST battery connector has 4.2V applied to it through a TP4065 battery charging IC and the battery goes into a charging state. If the USB power is then removed, the battery will continue to power the module.
The small blue LED flashing quickly (looks dim) with USB connected indicates that the battery is not connected. If a battery is connected along with USB power, the LED will turn steady on (brighter blue) indicating that the battery is charging. If the USB power is then removed, the blue LED will go out as the module starts running on battery power.
Operating current is about 30-60mA under normal operation and the maximum current draw is approximately 300mA when transmitting WiFi.
To conserve battery power and maximize battery life, the ESP32 can be placed into various low power sleep modes. The operating frequency of the CPU can also be lowered from the default 240MHz to something lower such as 80MHz if the full processing power of the module is not required for the application.
Important Note: Using a battery with the T-Display module is only compatible with also using the 5V USB power. A battery cannot be used when powering the module using the 5V VIN pin or 3.3V pin.
Another Important Note: The battery charging current is set to a maximum of 580mA. When selecting a battery, be sure that it is compatible with at least that amount of charging current or it has its own built-in current limiting circuit.
Selecting a Battery
The key points to keep in mind when selecting a battery are these:
Battery Connection: Select a battery with the 1.25mm JST connector unless you are OK with cutting and splicing a smaller connector on.
Battery Capacity: The larger the capacity (mAh rating), the longer the battery will be able to supply power to the T-Display-S3. With a larger capacity also comes a larger physical size and a larger JST connector, so there are tradeoffs to be made in that regard. Smaller batteries of around 100mAh can be found with the 1.25 connector already installed. Higher capacity batteries will usually have 2.0 or 2.54mm JST connectors.
Battery Charge Rate: Since the T-Display-S3 is configured to provide up to 580mA of charging current, ensure that the battery can either handle that maximum charge rate or has its own built-in current limiting circuit to prevent overcharging the battery.
Battery Physical Size: This largely depends on whether you want to fit the battery into the optional enclosure. A battery of 50mm x 20mm x 7mm will fit snug and is what we are using here. It happens to have a capacity of 800mAh and a large 2.54mm JST connector. This size will also fit in the enclosure if the module has the pins installed.
Adding Pins to the T-Display
The T-Display is a little different than most microcontroller development boards. Whether you want pins installed or not will depend on how you plan to use the board. Since it already includes a display and a couple of pushbuttons, many things can be done with it without hooking up anything to the pins and if installed into the enclosure, it makes for a nice tidy little assembly. If pins are installed, the T-Display can be installed into a solderless breadboard to make various I/O connections.
To install pins yourself, it is easiest to first insert them into a solderless breadboard to hold them in alignment. Insert the pins at the end of the breadboard so that the JST connector on the bottom side of the T-Display can hang over the edge to let the T-Display to seat fully down on the header pins. The space is sometimes tight between the 3-pin regulator next to the 5V pin and the header plastic, preventing it from seating fully. In that case, you can trim a little of the plastic away from the header strip in that area.
To solder the pins, it is recommended to use no-clean solder. Attempting to clean the flux using something like IPA (isopropyl alcohol) will allow the liquid to wick under the LCD and cause visible artifacts in the display. These may or may not go away after some period of time.
If it is installed into the enclosure, the enclosure has slots in the back for the pins to extend through as shown below. When in the enclosure, the pins do not extend out far enough to then plug into a solderless breadboard, though female jumper wires can be used to attach to the pins to make connections. It can of course also be removed from the enclosure to work with it on a breadboard.
Programming the T-Display
Important Note: This module uses the USB Type-C style connector like is used on cell phones. Make sure you have a standard USB to USB-C cable that includes the data lines. Cables supplied with cell phones are usually charge only cables and do not have the required data lines. The correct data cable can be ordered at the bottom of this page if needed. To communicate over USB, the board uses the CH9102 USB to UART bridge chip. On Win11 no special driver was required to be installed. If you experience any issues with connecting to the board and you have a good USB cable, you may need to download a driver for this chip. Drivers can be downloaded at this link for both MAC and PC: https://github.com/Xinyuan-LilyGO/TTGO-T-Display This is how the board will look in the Windows Device Manager window with the CH9102 driver installed and the board recognized by the system. The ‘COM26’ will vary. The board can be programmed in C using the Arduino IDE and is how the modules are most often used. The steps below show how to setup the Arduino IDE for the LILYGO displays. It assumes you already have the Arduino IDE installed. If the IDE is not installed, it can be downloaded from here: https://www.arduino.cc/en/software There are many instructions for installing and using ESP32 based boards with the Arduino IDE, but here is a short version. In this case we are using IDE 2.x but IDE 1.8 works similarly. 1. Open the IDE File/Preferences window and in the Additional Board Manager URLs field enter the following: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json. If you already have links for other additional boards loaded, just open the window and add it as a new line to the existing list as shown here. Click OK to close the window and close and restart the IDE. 2. Under Tools/Boards/Boards Manager, you can now find and install “ESP32 by Espressif Systems” as shown below. The current version as this is written is 3.03, but it does not work correctly with the T-Display. Instead, install the 2.0.17 version. If you already have a newer version loaded, just hit REMOVE and then select an older version like 2.0.17 and hit INSTALL. Important note: If you don’t run a version under 3.x, you will get a GPIO compiler error.
3. Under Tools/Boards/ESP32 you can now select “LilyGo T-Display“. 4. While you are messing around with the IDE, you will want to go ahead and install 2 main libraries for working with the T-Display and for compiling and running the example software. TFT_eSPI by Bodmer which is used to handle the built-in display and Button2 by Lennart Hennigs which is used to handle the two user buttons. TFT_eSPI – Use the Library Manager to download the TFT_eSPI library to the Arduino default library location. Install the latest version. Once the TFT_eSPI library is downloaded, locate the the User_Setup_Select.h file in the TFT_eSPI library folder and open it in a text editor like Notepad. You are going to modify this file to so the software knows knows that we are working with the T-Display module. Comment out #include <User_Setup.h> on line 27 as shown here: //#include <User_Setup.h> // Default setup is root library folder Uncomment //#include <User_Setups/Setup25_TTGO_T_Display.h> on line 58 as shown here: #include <User_Setups/Setup25_TTGO_T_Display.h> // Setup file for ESP32 and TTGO T-Display ST7789V SPI bus TFT Then save the file. 5. Make sure the T-Display is plugged into the USB and select the port that the board is attached to. In my case it happened to be COM26 Here is what the Tools menu looks like on my setup. Note that when the LilyGo T-Display board type is selected in the IDE, there are many more items added to the Tools drop down menu. Make sure the Flash Size is set to 16MB and not 4MB. PSRAM should default to “Disabled”. To test whether the board is basically working, plug the board into the USB and it should power up and display a logo screen, then cycle through red, blue and green screens. It will next try to detect if an SD card is connected and give a red warning message because it can’t find one and then it will give some menu options on the screen. Pressing the left user button causes it to do a WiFi scan and report the results. A quick press of the right user button causes it to show the voltage, in this case the USB voltage. A longer press causes it to go into a sleep mode and turn the display off. Pressing the right button again causes it to wake back up.
Downloading Software to the T-Display
When the T-Display is selected in the IDE, many example programs are available. To play around with some quick graphic examples, use the TFT_eSPI examples since they will utilize the display. Most should run correctly. Examples that use a different LCD resolution other than the 135 x 240 on this module should still run though the image may be chopped off or otherwise be incorrect. Important Note: If the software compiles OK, but the upload to the T-Display fails with an Upload Flags error, you will need to edit the boards.txt file to add the missing flags. First locate the boards.txt file. In my case it is located at: C:\Users\myname\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.17. The last number is the revision of the ESP32 software that you are using. Open the boards.txt file with a text editor like Notepad. Find the section for the Lilygo T-Display and paste these two lines into that section at the end of the lilygo_t_display.upload section and the save the file. And yes, there is nothing required after the “=” sign. lilygo_t_display.upload.flags= lilygo_t_display.upload.extra_flags= The program below is the factory test program that ships with the T-Display. It is provided here so you can see what is going on behind the scenes or if you want to try to modify it. To compile the program, copy the program and paste it into the IDE and then save to your Arduino directory under T_Display_Factory_Test or something similar. Next click the bmp.h link below which will download the file in zip format. Open the download and copy and paste the file into the same Arduino directory. This provides the TTGO graphics logo used by the program in the command line: tft.pushImage(0, 0, 240, 135, ttgo); BMP.H
T-Display Factory Test Program
#include <TFT_eSPI.h> #include <SPI.h> #include "WiFi.h" #include <Wire.h> #include "Button2.h" #include <esp_adc_cal.h> #include "bmp.h" #include "driver/rtc_io.h" // TFT Pins has been set in the TFT_eSPI library in the User Setup file TTGO_T_Display.h // #define TFT_MOSI 19 // #define TFT_SCLK 18 // #define TFT_CS 5 // #define TFT_DC 16 // #define TFT_RST 23 // #define TFT_BL 4 // Display backlight control pin #define ADC_EN 14 //ADC_EN is the ADC detection enable port #define ADC_PIN 34 #define BUTTON_1 35 #define BUTTON_2 0 TFT_eSPI tft = TFT_eSPI(135, 240); // Invoke custom library Button2 btn1(BUTTON_1); Button2 btn2(BUTTON_2); char buff[512]; int vref = 1100; int btnCick = false; #define ENABLE_SPI_SDCARD //Uncomment will use SDCard, this is just a demonstration, //how to use the second SPI #ifdef ENABLE_SPI_SDCARD #include "FS.h" #include "SD.h" SPIClass SDSPI(HSPI); #define MY_CS 33 #define MY_SCLK 25 #define MY_MISO 27 #define MY_MOSI 26 void setupSDCard() { SDSPI.begin(MY_SCLK, MY_MISO, MY_MOSI, MY_CS); //Assuming use of SPI SD card if (!SD.begin(MY_CS, SDSPI)) { Serial.println("Card Mount Failed"); tft.setTextColor(TFT_RED); tft.drawString("SDCard Mount FAIL", tft.width() / 2, tft.height() / 2 - 32); tft.setTextColor(TFT_GREEN); } else { tft.setTextColor(TFT_GREEN); Serial.println("SDCard Mount PASS"); tft.drawString("SDCard Mount PASS", tft.width() / 2, tft.height() / 2 - 48); String size = String((uint32_t)(SD.cardSize() / 1024 / 1024)) + "MB"; tft.drawString(size, tft.width() / 2, tft.height() / 2 - 32); } } #else #define setupSDCard() #endif void wifi_scan(); //! Long time delay, it is recommended to use shallow sleep, which can effectively reduce the current consumption void espDelay(int ms) { esp_sleep_enable_timer_wakeup(ms * 1000); esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); esp_light_sleep_start(); } void showVoltage() { static uint64_t timeStamp = 0; if (millis() - timeStamp > 1000) { timeStamp = millis(); uint16_t v = analogRead(ADC_PIN); float battery_voltage = ((float)v / 4095.0) * 2.0 * 3.3 * (vref / 1000.0); String voltage = "Voltage :" + String(battery_voltage) + "V"; Serial.println(voltage); tft.fillScreen(TFT_BLACK); tft.setTextDatum(MC_DATUM); tft.drawString(voltage, tft.width() / 2, tft.height() / 2 ); } } void button_init() { btn1.setLongClickHandler([](Button2 & b) { btnCick = false; int r = digitalRead(TFT_BL); tft.fillScreen(TFT_BLACK); tft.setTextColor(TFT_GREEN, TFT_BLACK); tft.setTextDatum(MC_DATUM); tft.drawString("Press again to wake up", tft.width() / 2, tft.height() / 2 ); espDelay(6000); digitalWrite(TFT_BL, !r); tft.writecommand(TFT_DISPOFF); tft.writecommand(TFT_SLPIN); //After using light sleep, you need to disable timer wake, because here use external IO port to wake up esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER); // esp_sleep_enable_ext1_wakeup(GPIO_SEL_35, ESP_EXT1_WAKEUP_ALL_LOW); rtc_gpio_init(GPIO_NUM_14); rtc_gpio_set_direction(GPIO_NUM_14, RTC_GPIO_MODE_OUTPUT_ONLY); rtc_gpio_set_level(GPIO_NUM_14, 1); delay(500); esp_sleep_enable_ext0_wakeup(GPIO_NUM_35, 0); delay(200); esp_deep_sleep_start(); }); btn1.setPressedHandler([](Button2 & b) { Serial.println("Detect Voltage.."); btnCick = true; }); btn2.setPressedHandler([](Button2 & b) { btnCick = false; Serial.println("btn press wifi scan"); wifi_scan(); }); } void button_loop() { btn1.loop(); btn2.loop(); } void wifi_scan() { tft.setTextColor(TFT_GREEN, TFT_BLACK); tft.fillScreen(TFT_BLACK); tft.setTextDatum(MC_DATUM); tft.setTextSize(1); tft.drawString("Scan Network", tft.width() / 2, tft.height() / 2); WiFi.mode(WIFI_STA); WiFi.disconnect(); delay(100); int16_t n = WiFi.scanNetworks(); tft.fillScreen(TFT_BLACK); if (n == 0) { tft.drawString("no networks found", tft.width() / 2, tft.height() / 2); } else { tft.setTextDatum(TL_DATUM); tft.setCursor(0, 0); Serial.printf("Found %d net\n", n); for (int i = 0; i < n; ++i) { sprintf(buff, "[%d]:%s(%d)", i + 1, WiFi.SSID(i).c_str(), WiFi.RSSI(i)); tft.println(buff); } } // WiFi.mode(WIFI_OFF); } void setup() { Serial.begin(115200); Serial.println("Start"); /* ADC_EN is the ADC detection enable port If the USB port is used for power supply, it is turned on by default. If it is powered by battery, it needs to be set to high level */ pinMode(ADC_EN, OUTPUT); digitalWrite(ADC_EN, HIGH); tft.init(); tft.setRotation(1); tft.fillScreen(TFT_BLACK); tft.setTextSize(2); tft.setTextColor(TFT_GREEN); tft.setCursor(0, 0); tft.setTextDatum(MC_DATUM); tft.setTextSize(1); /* if (TFT_BL > 0) { // TFT_BL has been set in the TFT_eSPI library in the User Setup file TTGO_T_Display.h pinMode(TFT_BL, OUTPUT); // Set backlight pin to output mode digitalWrite(TFT_BL, TFT_BACKLIGHT_ON); // Turn backlight on. TFT_BACKLIGHT_ON has been set in the TFT_eSPI library in the User Setup file TTGO_T_Display.h } */ tft.setSwapBytes(true); tft.pushImage(0, 0, 240, 135, ttgo); espDelay(5000); tft.setRotation(0); tft.fillScreen(TFT_RED); espDelay(1000); tft.fillScreen(TFT_BLUE); espDelay(1000); tft.fillScreen(TFT_GREEN); espDelay(1000); button_init(); esp_adc_cal_characteristics_t adc_chars; esp_adc_cal_value_t val_type = esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_12, 1100, &adc_chars); //Check type of calibration value used to characterize ADC if (val_type == ESP_ADC_CAL_VAL_EFUSE_VREF) { Serial.printf("eFuse Vref:%u mV", adc_chars.vref); vref = adc_chars.vref; } else if (val_type == ESP_ADC_CAL_VAL_EFUSE_TP) { Serial.printf("Two Point --> coeff_a:%umV coeff_b:%umV\n", adc_chars.coeff_a, adc_chars.coeff_b); } else { Serial.println("Default Vref: 1100mV"); } tft.fillScreen(TFT_BLACK); tft.setTextDatum(MC_DATUM); setupSDCard(); tft.drawString("LeftButton:", tft.width() / 2, tft.height() / 2 - 16); tft.drawString("[WiFi Scan]", tft.width() / 2, tft.height() / 2 ); tft.drawString("RightButton:", tft.width() / 2, tft.height() / 2 + 16); tft.drawString("[Voltage Monitor]", tft.width() / 2, tft.height() / 2 + 32 ); tft.drawString("RightButtonLongPress:", tft.width() / 2, tft.height() / 2 + 48); tft.drawString("[Deep Sleep]", tft.width() / 2, tft.height() / 2 + 64 ); tft.setTextDatum(TL_DATUM); } void loop() { if (btnCick) { showVoltage(); } button_loop(); }
Before they are shipped, these modules are:
- Power-up tested to verify factory software runs OK and display works correctly
Notes:
- None
Technical Specifications
Microcontroller | Xtensa LX6 32-bit |
Serial to USB Converter | CH9102 |
Operating Voltage | 3.3V |
Input Power | 5V or 3.7V Lithium Battery |
Digital I/O Pins | 13 (4 input only) |
PWM I/O Pins (Shared with Digital I/O) | 9 |
Analog Input Pins | 11 (12-bit) |
Analog Output Pins | 2 (8-bit) |
DC Current per I/O Pin | 10-40mA depending on total chip loading |
Hardware Serial Ports (UARTS) | 1 or more |
I2C Ports | 1 |
SPI Ports | 1 |
Touch Sensor Inputs | 7 |
Flash Memory | 16 MBytes |
ROM | 448 KBytes |
SRAM | 520 KBytes |
Clock Speed | 240MHz (default) |
Network | IEEE 802.11 b/g/n WiFi 2.4GHz |
Bluetooth | V4.2 BR/EDR and BLE |
USB Connector Style | USB Type-C Female |
Board Dimensions (L x W) | 51.49 x 25.09mm (2.03 x 0.99″) |
Pin Spacing (row-to-row) | 22.86mm (0.9″) |
Country of Origin | China |
Schematics (Down rev, shows CP2014 USB) | T-Display Schematic |
ESP32 Datasheet T-Display uses ESP32-DOWDQ6 chip | ESP32-DOWDQ6 |
FURTHER READING
VOLOS Projects – Youtuber with very useful information and projects using the LILYGO products.
Randomnerdtutorials – Very good generic ESP32 reference information with lots of examples that can be adapted to the T-Display
LILYGO T-Display Github – Alternate source for TFT-eSPI library if you have issues with Bodmer’s version. Also has some useful troubleshooting information under the ‘Issues’ list