A first build on the pluggable terminal base
One LED on GPIO 0, then one button on GPIO 1, wired into the right-hand block with three pieces of wire. No soldering and no screwdriver, and neither pin is the display, the serial port or a boot pin.
What you need
An ESP32-C3 OLED board on the base, a red LED, a 330 ohm resistor, a push button, a small breadboard, and three lengths of solid hookup wire. The terminal's maker lists 22 to 18 AWG, so use wire in that range; a thinner jumper wire may slide out. Strip 8 to 9 mm from each end that goes into the base.
Seat the board first, with V5 over 5V, and the cable out. Plug the cable in last.
Wire the LED
Use the right-hand block, switch end at the top. The silkscreen reads, top to bottom, 0, 1, 2, TX, RX, 3V, GND, 5V. GPIO 0 and 1 are the first two ways, and the one ground way is the seventh.
- Push one wire into the first way, GPIO 0, until it stops. Tug it.
- Push another into the GND way, seventh from the top. Tug it.
- Run the GPIO 0 wire to a breadboard row, then the 330 ohm resistor from that row to the LED's long leg. Run the GND wire to the breadboard's ground rail, and the LED's short leg to the rail.
The base has one ground way and a way takes one wire, so the LED and the button return to the rail rather than to the way. GPIO 0 pushes about 4 mA through the resistor and a red LED, with the resistor setting the current. GPIO 0 is not the display, not the serial port and not read at reset.
To blink only, the loop is one line shorter:
void loop() {
digitalWrite(LED, (millis() / 500) % 2);
}Add the button
The same figure, second step. One more wire: the second way, GPIO 1. Put the button between that row and the ground rail, with its two wires on opposite corners.
The pin idles HIGH, held up by a resistor inside the chip, which is what
INPUT_PULLUP turns on. Pressing the button joins the pin to ground, so it
reads LOW. The sketch ORs that with the blink, so the LED stays on while you
hold the button.
The sketch
Open the Serial Monitor at 115200. It prints one line at start-up and then nothing; the LED and the button are the output.
To take a wire out, press the grey tab on its way and pull. The base itself needs nothing: no jumper to move and no screw to undo.
The code
Blinks an LED on GPIO 0 once a second and holds it on while a button on GPIO 1 is pressed. It prints one line at start-up, so you can tell an upload fault from a wiring fault without moving a wire.
// ESP32-C3 OLED on the Pluggable Terminal Base: blink an LED, hold it
// on with a button.
//
// Wiring, right-hand block of the base (printed 0 1 2 TX RX 3V GND 5V):
// way 0 -> 330 ohm -> LED long leg
// way 1 -> button, one side
// way GND -> breadboard ground rail
// LED short leg and the button's other side -> that ground rail
// The board is seated with V5 over 5V, and the cable goes in last.
//
// Arduino IDE, Tools menu:
// Board ESP32C3 Dev Module
// USB CDC On Boot Enabled
// Flash Size 4MB (32Mb)
// Upload Speed 921600
// No library needed.
const int LED = 0;
const int BUTTON = 1;
void setup() {
Serial.begin(115200);
pinMode(LED, OUTPUT);
pinMode(BUTTON, INPUT_PULLUP); // the pin idles HIGH
delay(1500); // let the USB port enrol
Serial.println("LED on GPIO 0, button on GPIO 1");
}
void loop() {
bool pressed = digitalRead(BUTTON) == LOW;
bool blink = (millis() / 500) % 2; // flips every half second
digitalWrite(LED, pressed || blink);
}The button is read with INPUT_PULLUP, so pressed reads LOW and the test is == LOW. The LED is switched from the clock, not with delay(), which is why the button answers at once instead of after the half-second wait.
When it does not work
Turn the LED round: it only conducts one way, and the long leg goes toward the resistor and the GPIO 0 way. Then check that the resistor shares a breadboard row with the wire from the way, and that the LED's other leg shares a row with the ground rail. If both are right, tug each wire in the base: a wire that moves never seated.
A four-legged push button has two pairs of legs joined inside, so two wires on legs of the same side make a permanently closed switch. Put the wires on legs on opposite sides, diagonally. Also remember it reads backwards: pressed is LOW, released is HIGH.
The sketch is running if the LED blinks. Set USB CDC On Boot to Enabled in the Tools menu and upload again, then open the monitor at 115200. Left disabled, Serial.println goes nowhere. The board's USB port also disappears and returns when the chip resets, so reopen the monitor after pressing RST.
That is the board and the cable, not the base. Check the Port in the Tools menu, then use manual download mode: hold BOO, press and release RST, wait a second, release BOO and upload again. And check the board went in the right way round, before the cable.
Bridge one solder pad and the board can read its own cell on GPIO 2.
Battery level, on the screen →Edit this page — content/books/c3oled/pluggable-first-build.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.