TTGO T-Display I2C pin location

You can’t always trust the datasheet.

The TTGO T-Display is a great little dev board, incorporating an ESP32 processor (with WiFi and Bluetooth support) and a small OLED display. With the header pins soldered on, it’s breadboardable — and even has a battery connector to use (and presumably charge) a small Lithium-Ion battery. Not bad for about $10.

Unfortunately, one effect of using such new technology is that the specifications sometimes change out from under you — and the firmware (let alone the documentation) takes a while to catch up. Production changes are made to solve problems, other changes are made that make these changes unnecessary, and then they’re reverted for only part of the system.

You’d think that something that breaks I2C would have been caught by now, though, especially when it’s a simple fix. Sometime in the development of the TTGO T-Display board (or a predecessor), an onboard LED was apparently placed on GPIO pin 22 (which serves as the SCL clock pin for I2C.) This LED was said to cause problems with I2C communications, so the solution was to remap SCL in the board definitions to pin 23 from pin 22.

The TTGO T-Display pinout, according to LilyGo.
Unfortunately, Pin 22 isn’t SCL. That’s defined as Pin 23…
…which isn’t brought out to a header.

Great — except nobody ever updated the pinout — or bothered to bring Pin 23 out to the header. A pin intended to connect to external peripherals is useless if it isn’t brought out to a pin where you can get it to the breadboard or external device.

A quick “Blink” clone test convinced me that nothing blinks when Pin 22 is made an output and toggled high to low, so most likely whatever LED was associated with Pin 22 was deleted long ago. Trying out SoftWire (a software-based I2C implementation) on pins 21/23 worked fine, clearing the way to change it back.

A quick Google search led me to the location of the pin definitions file for the T-Display board:

C:\Users\<user>\AppData\Local\Arduino15\packages\
esp32\hardware\esp32\1.0.4\variants\ttgo-t1\pins_arduino.h

SDA and SCL are defined just a few lines into this file. Once SCL was changed back to 22, the built-in Wire library started working. If I2C doesn’t work on your TTGO T-Display, this is why. Make the change to the file listed in bold above, and it should work.

I’d submit a pull request, but I can’t figure out who’s responsible for maintaining the ESP32 variant in the Arduino libraries. Searching through the TTGO T-Display Github doesn’t pull up any references to the SCL pin (only SCLK).

This entry was posted in Arduino, C, Coding, Digital, Troubleshooting. Bookmark the permalink.

Leave a Reply