Another TTGO with ESPHOME

LilyGo TTGO module

The first time I did this last week, I was a complete newby to ESPHOME – a popular yet free firmware option for ESP8266 and ESP32-based boards. I also had no idea how to make use of the ESP32-based which Banggood sent me some time ago so I was picking skills up as I went along … well, now (hopefully) I have more of an idea of how to make use of both the TTGO module and ESPHOME itself so let’s see if I can set this up with a minimum of mistakes while discussing the subject on the blog for anyone new to the subject.

First things first… on opening the packing, the LILYGO TTGO module was complete with a pair of unsoldered rows of pins – so here goes with the soldering iron. Again I’ll assume minimal familiarity.

I tend to have a wet sponge next to the iron (which I run at 400c) and use it to keep the tip clean before starting and during the soldering process o remove black rubbish from the tip. On the left you see the TTGO board complete with as-yet unsoldered pin rows – simply positioned and straightened by hand, ready for the iron.

On the right you’ll see as I’m about to attack the board with my nicely cleaned up iron. The whole process including warming up the iron and soldering all the pins took maybe 5 minutes or so.

I tend to put the (0.6mm dia, leaded, 60/40) solder in-between the iron and the pins – soldering maybe half a dozen pins at a time before cleaning the iron with my handy (cheap Chinese) dampened sponge and moving onto the next batch of pins.

And finally, the completed board after soldering all pins and then carefully applying a tiny amount of isopropyl alcohol (96% – generally available for maybe 5 euros a litre here in Spain) on a cloth to clean off any flux (not essential, I just like to clean the somewhat sticky resin from the boards after soldering).

Ok, here we go. Plugged into a USB-C lead an USB supply, the board comes complete with a demo on the colour screen – great to look at and prove the board works but not much use otherwise. Initially I plugged into my PC but at this point only providing power to the board. If you’re familiar with “flashing” or programming ESP8266 and ESP32 boards, you’ll know that some need you to hold down a button while powering up – not this board nor various NodeMCU-branded boards I’m familiar with

As I’ve been recently caught out (unable to FLASH a board even though it has power), I should say at this point, make sure the USB-C lead is fully wired – there are some leads which are good for charging USB boards but no good for sending data – you should be able to tell by whether or not the PC makes a sound when connecting the lead and board. I’ve had more than my share of leads which will ONLY provide power – now that I’m onto it, they’re in the bin.

So all ready to go and having installed ESPHOME on my PC as per my first ESPHOME blog entry (though THIS is where you should go for ESPHOME installation) I decided to call this new board TTGO2.

ESPHOME sits in my C:\users\user folder under ESPHOME folder (and all projects and YAML file sit under that).

Armed, as discussed in my above-mentioned ESPHOME blog entry, with Microsoft TERMINAL (the new one) and the free Visual Studio Code editor (which I’m really warming up to, as a Notepa++ user of many years), I started by going into the terminal, switching to the above-mentioned esphome folder and keying in:

esphome wizard ttgo2.yaml

The result? Almost no work but a shedload of output – during which I was asked for the name of my project (not surprisingly I picked “ttgo2”), whether the project was based on ESP8266 or ESP32, which board I am using (as previously I guessed at “ttgo-t7-v13-mini32”), then for my WiFi SSID and password and finally did I want to use a password for OTA (over the air) updates? No. Here’s how it works… the WIZARD creates the “ttgo2.yaml file” with the above information included. At this point the board didn’t actually need to be plugged in. Here goes – where I keyed something in, I’ve used a different colour.

PS C:\Users\User\esphome> esphome wizard ttgo2.yaml
Hi there!
I'm the wizard of ESPHome :)
And I'm here to help you get started with ESPHome.
In 4 steps I'm going to guide you through creating a basic configuration file for your custom ESP8266/ESP32 firmware. Yay!

============= STEP 1 =============
    _____ ____  _____  ______
   / ____/ __ \|  __ \|  ____|
  | |   | |  | | |__) | |__
  | |   | |  | |  _  /|  __|
  | |___| |__| | | \ \| |____
   \_____\____/|_|  \_\______|

First up, please choose a name for your node.
It should be a unique name that can be used to identify the device later.
For example, I like calling the node in my living room livingroom.

(name): ttgo2
Great! Your node is now called "ttgo2".

============= STEP 2 =============
      ______  _____ _____
     |  ____|/ ____|  __ \\
     | |__  | (___ | |__) |
     |  __|  \___ \|  ___/
     | |____ ____) | |

Now I'd like to know what microcontroller you're using so that I can compile firmwares for it.
Are you using an ESP32 or ESP8266 platform? (Choose ESP8266 for Sonoff devices)

Please enter either ESP32 or ESP8266.
(ESP32/ESP8266): esp32
Thanks! You've chosen ESP32 as your platform.

Next, I need to know what board you're using.
Please go to and choose a board.
(Type esp01_1m for Sonoff devices)

For example "nodemcu-32s".
Options: alksesp32, az-delivery-devkit-v4, bpi-bit, briki_abc_esp32, briki_mbc-wb_esp32, d-duino-32, esp-wrover-kit, esp32-devkitlipo, esp32-evb, esp32-gateway, esp32-poe, esp32-poe-iso, esp32-pro, esp320, esp32cam, esp32dev, esp32doit-devkit-v1, esp32doit-espduino, esp32thing, esp32thing_plus, esp32vn-iot-uno, espea32, espectro32, espino32, etboard, featheresp32, firebeetle32, fm-devkit, frogboard, healtypi4, heltec_wifi_kit_32, heltec_wifi_kit_32_v2, heltec_wifi_lora_32, heltec_wifi_lora_32_V2, heltec_wireless_stick, heltec_wireless_stick_lite, honeylemon, hornbill32dev, hornbill32minima, imbrios-logsens-v1p1, inex_openkb, intorobot, iotaap_magnolia, iotbusio, iotbusproteus, kits-edu, labplus_mpython, lolin32, lolin32_lite, lolin_d32, lolin_d32_pro, lopy, lopy4, m5stack-atom, m5stack-core-esp32, m5stack-core2, m5stack-coreink, m5stack-fire, m5stack-grey, m5stack-timer-cam, m5stick-c, magicbit, mgbot-iotik32a, mgbot-iotik32b, mhetesp32devkit, mhetesp32minikit, microduino-core-esp32, nano32, nina_w10, node32s, nodemcu-32s, nscreen-32, odroid_esp32, onehorse32dev, oroca_edubot, pico32, piranha_esp32, pocket_32, pycom_gpy, qchip, quantum, s_odi_ultra, sensesiot_weizen, sg-o_airMon, sparkfun_lora_gateway_1-channel, tinypico, ttgo-lora32-v1, ttgo-lora32-v2, ttgo-lora32-v21, ttgo-t-beam, ttgo-t-watch, ttgo-t1, ttgo-t7-v13-mini32, ttgo-t7-v14-mini32, turta_iot_node, vintlabs-devkit-v1, wemos_d1_mini32, wemosbat, wesp32, widora-air, wifiduino32, xinabox_cw02
(board): ttgo-t7-v13-mini32
Way to go! You've chosen ttgo-t7-v13-mini32 as your board.

============= STEP 3 =============
   __          ___ ______ _
   \ \        / (_)  ____(_)
    \ \  /\  / / _| |__   _
     \ \/  \/ / | |  __| | |
      \  /\  /  | | |    | |
       \/  \/   |_|_|    |_|

In this step, I'm going to create the configuration for WiFi.

First, what's the SSID (the name) of the WiFi network ttgo2 should connect to?
For example "Abraham Linksys".
(ssid): xxxxxxxx
Thank you very much! You've just chosen "xxxxxxxx" as your SSID.

Now please state the password of the WiFi network so that I can connect to it (Leave empty for no password)

For example "PASSWORD42"
(PSK): yyyyyyyy
Perfect! WiFi is now set up (you can create static IPs and so on later).

============= STEP 4 =============
       ____ _______
      / __ \__   __|/\\
     | |  | | | |  /  \\
     | |  | | | | / /\ \\
     | |__| | | |/ ____ \\
      \____/  |_/_/    \_\\

Almost there! ESPHome can automatically upload custom firmwares over WiFi (over the air) and integrates into Home Assistant with a native API.
This can be insecure if you do not trust the WiFi network. Do you want to set a password for connecting to this ESP?

Press ENTER for no password

DONE! I've now written a new configuration file to ttgo2.yaml

Next steps:
  > Check your Home Assistant "integrations" screen. If all goes well, you should see your ESP being discovered automatically.
  > Then follow the rest of the getting started guide:
PS C:\Users\User\esphome>

So, now I had a “ttgo2.yaml” file sitting in my c:\users\user\esphome folder. Ok, so NOW I needed to to have ESPHOME create the project and get the code onto the board. With the board still plugged into my PC USB, again using Microsoft TERMINAL, this time I punched in “esphome run ttgo2.yaml”.

This time only one interaction at the end but a REAL shedload of output as compilation and linking took placed. Quite frightening when you are new – including various compiler and linker warnings which I guess you should just utterly ignore.

At the end of that (50 seconds of me doing nothing) – I was asked if I’d like to choose [1] COM13 serial or [2] Over-the-Air (ttgo2.local). Well, a couple of things here – the FIRST time around, you CAN’T use OTA as there’s nothing on the ESP32 chip but it’s normal bootloader that came with the board… and secondly, ttgo2.local is a BIG assumption. My router adds .lan to local addresses, not .local and back in the UK my router adds .broadband. There will be other variations and knowledgeable users can change that suffix (I changed mine to .lan because that minimises typing. I suppose I could have be extreme and use .l but you get the point.

PS C:\Users\User\esphome> esphome run ttgo2.yaml
INFO Reading configuration ttgo2.yaml...
INFO Generating C++ source...
INFO Core config or version changed, cleaning build files...
INFO Compiling app...
INFO Running:  platformio run -d ttgo2
Processing ttgo2 (board: ttgo-t7-v13-mini32; framework: arduino; platform: platformio/espressif32@3.2.0)
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Espressif 32 (3.2.0) > TTGO T7 V1.3 Mini32
HARDWARE: ESP32 240MHz, 1.25MB RAM, 4MB Flash


Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   3.2% (used 41332 bytes from 1310720 bytes)
Flash: [=====     ]  48.7% (used 893118 bytes from 1835008 bytes)
Building .pioenvs\ttgo2\firmware.bin v3.0
============================================= [SUCCESS] Took 50.09 seconds =============================================
INFO Successfully compiled program.
Found multiple options, please choose one:
  [1] COM13 (Silicon Labs CP210x USB to UART Bridge (COM13))
  [2] Over The Air (ttgo2.local)

As this point up to now involved no interaction other than starting things going at the top so I’ve shown you a stripped down version.. to beginners the compilation and linking process will mean nothing anyway. I chose option [1] – i.e. flash the chip using the serial port. Again below I’ll miss out bits in the middle that likely won’t make sense but were there just for information – I will include the flashing process (that means the chip is being programmed)…

Uou may notice in the code below “Use manually specified: COM13. No I didn’t – it was picked automatically.

(number): 1
INFO Running:  platformio run -d ttgo2 -t upload --upload-port COM13
Processing ttgo2 (board: ttgo-t7-v13-mini32; framework: arduino; platform: platformio/espressif32@3.2.0)
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Espressif 32 (3.2.0) > TTGO T7 V1.3 Mini32
HARDWARE: ESP32 240MHz, 1.25MB RAM, 4MB Flash


Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   3.2% (used 41332 bytes from 1310720 bytes)
Flash: [=====     ]  48.7% (used 893118 bytes from 1835008 bytes)
Configuring upload protocol...
AVAILABLE: esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Use manually specified: COM13
Uploading .pioenvs\ttgo2\firmware.bin v3.0
Serial port COM13
Chip is ESP32-D0WDQ6-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None


Auto-detected Flash size: 4MB
Compressed 17104 bytes to 11191...
Writing at 0x00001000... (100 %)
Wrote 17104 bytes (11191 compressed) at 0x00001000 in 1.0 seconds (effective 138.0 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 144...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (144 compressed) at 0x00008000 in 0.0 seconds (effective 1154.2 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 5277.5 kbit/s)...
Hash of data verified.
Compressed 893232 bytes to 511992...
Writing at 0x00010000... (3 %)
Writing at 0x00014000... (6 %)


Writing at 0x0008c000... (100 %)
Wrote 893232 bytes (511992 compressed) at 0x00010000 in 45.2 seconds (effective 158.0 kbit/s)...
Hash of data verified.

Hard resetting via RTS pin...
============================================= [SUCCESS] Took 56.08 seconds =============================================
INFO Successfully uploaded program.


[14:19:39][C][wifi:037]: Setting up WiFi...
[14:19:40][D][wifi:382]: Starting scan...
[14:19:41][D][wifi:397]: Found networks:


[14:19:46][I][wifi:515]: WiFi Connected!
[14:19:46][C][wifi:361]:   SSID: 'xxxxxxxx'
[14:19:46][C][wifi:362]:   IP Address:
[14:19:46][C][wifi:364]:   BSSID: 94:83:C4:01:84:6E
[14:19:46][C][wifi:365]:   Hostname: 'ttgo2'
[14:19:46][C][wifi:369]:   Signal strength: -58 dB ▂▄▆█
[14:19:46][C][wifi:373]:   Channel: 1
[14:19:46][C][wifi:374]:   Subnet:
[14:19:46][C][wifi:375]:   Gateway:
[14:19:46][C][wifi:376]:   DNS1:
[14:19:46][C][wifi:377]:   DNS2:
[14:19:46][D][wifi:524]: Disabling AP...
[14:19:46][C][ota:029]: Over-The-Air Updates:
[14:19:46][C][ota:030]:   Address: ttgo2.local:3232
[14:19:46][C][api:023]: Setting up Home Assistant API server...
[14:19:46][I][app:060]: setup() finished successfully!
[14:19:46][I][app:102]: ESPHome version 2021.9.1 compiled on Oct  2 2021, 14:09:55

I stopped the serial (terminal) log at this point – all’s well. The chip is programmed. For my own purposes the very next thing I do now is set up the web page – clearly the code at this point contains nothing about the display so that’s blank – connected to serial I know the board is working but I really don’t want to do that after the first time around, I prefer to connect over WiFi. See above where I’m given the choice of serial or WiFi. If I now, having initially programmed the board, connect it to an independent USB hub I’ll not see the options for the RUN command – and of course, a HUB will have more power available than a PC USB output. For subsequent updates – serial is not needed.

Here I (bravely) switch to a USB charger – NOT connected to the PC. As the TTGO2.YAML file is actually on the PC, I can edit the code (Using in this case, Microsoft Visual Studio Code editor) for this board without a serial connection. Remember the file is sitting in the ESPHOME folder. Right now, that file is MINIMAL.

  name: ttgo2
  platform: ESP32
  board: ttgo-t7-v13-mini32

# Enable logging

# Enable Home Assistant API
  password: ""

  password: ""

  ssid: "xxxxxxxx"
  password: "yyyyyyyy"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
    ssid: "Ttgo2 Fallback Hotspot"
    password: "1bAl7GwWSRwl"


I add to the end, the code for the web server…. that is, two lines – and note – YAML is case sensitive and VERY sensitive about indenting – you must get that absolutely right.

    port: 80

Having saved that addition, I run a slight variation of the ESPHOME RUN command as I don’t want logging to get in the way – others might advise leaving it on. So, back to the terminal program.., I note that the board is plugged into my charger – and a blue light is on (on the board).

esphome run ttgo2.yaml --no-log

THIS time I see compiling info as before but no options as to how to program the board. I see SUCCESS and a one-line version of the FLASHING INFORMATION – again I’ll show you the output (no interaction) minus the compiling info about which you can do nothing…

Building .pioenvs\ttgo2\firmware.bin v3.0
============================================= [SUCCESS] Took 46.76 seconds =============================================
INFO Successfully compiled program.
INFO Resolving IP address of ttgo2.local
INFO  ->
INFO Uploading ttgo2\.pioenvs\ttgo2\firmware.bin (904288 bytes)
Uploading: [============================================================] 100% Done...

INFO Waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
PS C:\Users\User\esphome>

And now, on my PC, if I go in my CHROME BROWSER (for example) to address http://ttgo2.lan

TTGO WEeb Server using ESPHOME

LOVELY – all ready to go – this entire process would have takenless than minutes had I not been blogging it as I went along.

The next step is to start adding display and other blocks just as I added that web server block – but you can pick that up from the original ESPHOME blog entry. The YAML file is, after all just a plain text file – just be careful about indenting.

I hope that this attempt (together with my original ESPHOME entry) at covering basic setup from scratch, makes life easier for anyone either trying to find a use for certain boards or embarking on ESPHOME. If you want to use HOME ASSISTANT as well, there’s plenyu of information on that in the ESPHOME website.

If not, look in from time to time as I’m likely to come back into this blog, make changes/improvements and fix any mistakes as well as actually doing something USEFUL with the board – right now I’m treating it as a test board as I increase my knowledge.

Something I HAVE noticed – as I have no plans to use this with Home ASSISTANT – looking an hour later at that web page is this:

The debug output is because by default – that YAML file contains a block for HOME ASSISTANT – I’ll now take that out an insert a block for my local MQTT broker instead, as at some point I’ll want to talk to this board by MQTT (from Node-Red). Note in the code below – all I have done is commented out (using hashes) the API section and below that added in a section for my MQTT broker (which is MOSQUITO, sitting on a Raspberry Pi) – and rather than block our my WiFi credential as I did originally, I’m using a simple YAML file called secrets.yaml (in the ESPHOME folder) as described in my ESPHOME blog entry and on the ESPHOME website – so that here I don’t need to actually block out sensitive information. I hope this makes sense… note – that is ALL I need to include for MQTT initually. ESPHOME will automatically support MQTT and compile in the relevant code. I’ve now also the same secrtes file on my WIFI credentials. I’m just pulling in this stuff from my original project.

  name: ttgo2
  platform: ESP32
  board: ttgo-t7-v13-mini32

# Enable logging

# Enable Home Assistant API
#  password: ""

  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
    ssid: "Ttgo2 Fallback Hotspot"
    password: "1bAl7GwWSRwl"

  broker: !secret mqtt_broker
  username: !secret mqtt_user
  password: !secret mqtt_password
  id: mqtt_client
  password: ""


    port: 80

So here, we have a fully functional basic setup – doesn’t do anything but it is functional and can handle OTA and has a web server. In the process of doing that update and using the RUN command again – the TTGO2 web page is keeping track automatically – see the OTA log on the right.

I need more PC screens – I have three already – one is where I’m editing the YAML file (multi-window as I’ll copy-paste blocks from my other YAML projects as I go along to minimise mistakes) – and doing this blog entry – another is where I do the compiling and the third is showing that ttgo2 web server. OK I know my RUN command line has a –no-log flag on the end but that applies to the terminal.

For now, that’s it – setting up a board from scratch without a single mistake – first time ever. A week ago I could not use one line of YAML without making a mistake somewhere.

In the process I’ve hopefully improved the colour highlighting in the blog entry thanks to feedback from one of you.

I think the next block to add will be for the display used in the TTGO and initially a quick “Hello world” before getting fancy with fonts (which you can do in ESPHOME more readily than in Tasmota. However as I’ve covered that in the original ESPHOME blog – I’ll point you to this ESPHOME page. They show simple setup of fonts and colours and everything from a “Hello World” to a nice clock. I’ve taken things a lot further but shown all in one go would put beginners right off – I recommend opening all the pages on the ESPHOME site you think you might need and bookmarking the lot. I have the free SESSION BUDDY extension for Chrome which lets me save and restore dozens of tabs at once.