Wiring for your board
The library keeps one set of pins for the ESP32-S3 and one for the classic ESP32, and picks between them from the board you chose in Tools. The board size has no say in it, which is the point, and also where the one gap in the table is.
Pins belong to your microcontroller
Two controls. The top one changes every number on the drawing. The bottom one, the size of the display board, changes nothing at all, and that is the thing worth sitting with for a moment.
The GPIO a wire lands on is a property of the microcontroller you are compiling for. The driver chip, the resolution, the offsets and the backlight polarity are properties of the glass. They never meet, so there is no combination to look up: pick your microcontroller, pick your display, and the two answers are independent.
The library goes further and picks the row for you, from what you selected in
Tools ▸ Board. Compile for an ESP32-S3 and you get the S3 pins; compile for
an ESP32 Dev Module and you get the classic ones. Nothing to edit. The defaults
are the pins of the Lonely Binary breakout; if you wire the eight holes to
other GPIOs, that is what setWiring() is for.
The gap in the table
There are two rows and no third one. The library chooses the S3 row when it is built for an S3, and the classic-ESP32 row otherwise.
Otherwise includes the ESP32-C3, and the classic row hands out GPIO 23 for data and GPIO 32 for the backlight. A C3's pins stop at GPIO 21. Neither of those exists.
So on a C3, and on anything else that is not one of the two named chips, the
default pins are not a starting point. In the version of the library tested for
this book, built against arduino-esp32 3.3.10, a C3 does not get as far as
wrong pins: the classic row names the VSPI bus, which a C3 does not have, and
the compile stops. The library says it is for the two chips and nothing else.
The override below is for what it is for: an ESP32 or ESP32-S3 whose default pins are taken by something else.
LB_Wiring pins = LB_WIRING; // start from the default for this chip
pins.cs = 5; // ...then change what your board actually has
pins.dc = 16;
pins.rst = 17;
pins.mosi = 23;
pins.sclk = 18;
pins.backlight = 4;
display.setWiring(pins); // before begin()
display.begin();The same call is how you tell the library that a hole is not wired. With the CS
or BL solder jumper bridged, set
pins.cs or pins.backlight to -1 so nothing drives the pad.
Copy LB_WIRING rather than declaring an empty one. It carries an SPI bus
number whose meaning is not the same on every chip, and starting from the
default gives you a bus that is already correct for the chip you are building
for.
printInfo() prints the pins actually in use and marks any you overrode, which
turns a wiring mistake into a line in the serial log instead of a blank screen.
More than one display
Clock and data are shared, and each display gets its own CS. That is ordinary SPI, and it is the reason CS exists: without it, two displays on one bus both take every byte. Give each its own RST too, because a reset pulse reaches every display wired to it.
When it does not work
The library is written for the ESP32-S3 and the classic ESP32 and has no row for anything else. Compiled for an ESP32-C3 with arduino-esp32 3.3.10 it stops with 'VSPI' was not declared, because the classic row names a SPI bus a C3 does not have, and its pins (GPIO 23 for data, GPIO 32 for the backlight) are past the C3's last GPIO anyway. Use an S3 or a classic ESP32, or drive the board with your own code from the eight holes.
Override them. Copy LB_WIRING into a variable, change only the fields that differ, and pass it to setWiring before begin. Start from the default rather than filling one in from scratch — the SPI bus number in it means different things on different chips, and copying gets that right for free.
No. Pins belong to your microcontroller, the driver and resolution belong to the screen, and the two do not interact. Swapping to another of the six boards changes one constant in the sketch and no wiring at all, because the eight holes and the 15-way socket are the same on all six.
Clock and data can be shared, and each display needs its own CS. Give each its own RST as well: begin() pulses RST, and a shared reset would wipe a display that is already running. This book has not run two LB_Display objects on one SPI host, so treat that part as untested.
What a single panel constant resolves to, and why five settings hide behind it.
The one line that changes →Edit this page — content/books/lcd/wiring-for-your-board.mdx
Questions about this product
See what other owners have asked, and read their solutions.
This page covers several products. Choose yours to see the right discussions.
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.