ESP32

Most ESP32 boards are now supported by the Arduino IDE. Some of the LilyGO TTGO boards I have used require a little setup.

T-Eth-POE

The LilyGO-T-Eth-POE board is not shown in the boards list in the Arduino IDE. It uses an ESP32 WROOM Module, so you select the ESP32 Wrover from the boards list.

While testing the POE the example code didn't work. Specifically, the ethernet never connected. After some digging it turned out that the #defines in the example code use "SYSTEM_EVENT_ETH_CONNECTED" etc. The include from WiFi.h uses "ARDUINO_EVENT_ETH_CONNECTED". A quick global search and replace of SYSTEM with ARDUINO got everything working just fine.

The latest version of the library checks versions and selects the correct #define for you.

T-Display

The LilyGO T-Display board is not shown in the boards list. It is an ESP32 Dev Module.

The T-Display has i2c on pins 21 and 22, so in the Arduino IDE you need to initialize the Wire library with "Wire.begin(21,22);".

To use the TFT_eSPI library needs a little config for the T-Display. The User_Setup.h need to be edited as below.

#define ST7789_DRIVER

// IPS 1.14 in T-Display
#define TFT_WIDTH 135
#define TFT_HEIGHT 240


#define TFT_MOSI 19
#define TFT_SCLK 18
#define TFT_CS 5
#define TFT_DC 16
#define TFT_RST 23
#define TFT_BL 4

T-Watch

The LilyGO T-Watch requires special libraries. You can't use the standard TFT_eSPI library, you must get the T-Watch library that includes custom libraries.

TTGO LoRa32

To use LoRa, we need to set the pin definitions to match.

const int csPin = 18;          // LoRa radio chip select
const int resetPin = 14;       // LoRa radio reset
const int irqPin = 26;         // must be a hardware interrupt pin

#define SDA 4
#define SCL 15  
// Initialize the OLED display using Arduino Wire:
SSD1306Wire display(0x3c, SDA, SCL); 

void setup() {
  LoRa.setPins(csPin, resetPin, irqPin);

  // set OLED RST
  pinMode(16, OUTPUT);
  digitalWrite(16, HIGH);
}

To use the hardware UARTs in the ESP32 you can remap them to any suitable GPIO pins. They do need to be input/output though. On the LoRa32 I've used pins 12 and 13 as they are suitable. Serial is already used for the USB, and Serial1 may be used for internal stuff, so I used Serial2 as the easiest option.

#define RXD2 13
#define TXD2 12
void setup()
{
  Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
}

Some example sketches showing this at work. While messing around getting communication going between two ESP32 boards I used my phone to test connection. Then I remembered that XCSoar was installed, which can accept GPS input over bluetooth serial (or UDP). A quick check showed a simple serial to bluetooth worked just fine.

XCSoar supports UDP as well, so I tried that. It is a bit more complicated as you need to assemble each NMEA sentence and send it in a single UDP packet.

Espressif toolchain

I did need to install the ESP32 toolchain from Espressif for one project. This was straightforward on a Mac running OSX. Simply follow the instructions at espressif.com. I needed an older version of the toolchain for the project, which was no problem as espressif keep the previous versions available for just such issues.

The Espressif toolchain is a good old traditional command line system with complier, linker, and make. Easy for some-one comfortable with Unix command line environments. Perhaps a challenge for some-one used to graphical development environments.

i2c

To use I2C with these ESP32 modules you're likely to need to map some GPIO pins to the I2C bus. These new pin definitions are then passed to the Arduino Wire library begin function in setup. You must take care to use pins that are I/O rather than Input only. Check the datasheet. The T-Display board uses 21/22 for SDA/SCL I2C, which is the Arduino default, but the POE board doesn't break out those pins.

For example, on the POE board the expansion connector is:

PinFunctionPinFunction
36Input39Input
34Input35Input
16Input/Output32Input/Output
33Input/Output12Input/Output
04Input/Output15MOSI
02MISO14SCLK

So to use I2C we must select two pins and pass that to the Wire library. We can't use the top four pins (36,39,34,35) because they're input only. There are three pins used for SPI (02,14,15) so they're also not available. Any of the remaining pins can be used (16,32,33,12,04).

The code would include something like this:

#include <Wire.h>

// Pins used for i2c
#define I2C_SDA 33
#define I2C_SCL 32

void setup()
{
  Wire.begin(I2C_SDA,I2C_SCL);
}