Skip to content
esp-labsESP32-S3 bench guide
ESP32-S3 DevKitC pinoutThis lesson uses: VCC on 3V3, BLK on 7, RES on 8, DC on 9, CS on 10, SDA on 11, SCL on 12, GND on GND, BTN on 5, BOOT on 0.ESP32-S3WROOM-1 N16R8BOOTRSTRGBUSBCOM3V3VCC3V3RST45BTN67BLK151617188RES3469DC10CS11SDA12SCL13145VGNDGNDGNDTX 43RX 441242414039383736350BOOT454847212019GNDGND
  • used in this lesson
  • safe GPIO
  • avoid
  • power
  • ground
  • button input
  • RC522
Between lessons
  1. Ctrl+C closes the monitor on the Mac only. The board keeps running.
  2. Unplug USB: this is what stops the program and the screen
  3. Rewire while off
  4. Check VCC is on 3V3, no loose ends
  5. Plug in, flash the next lesson

Never unplug during Writing at 0x…. Pin changing from output to input? Flash first, then wire.

Lesson B6

Bluetooth LE · lesson 6 of 8

A Bluetooth keyboard and a remote for your music

built, not flashed

The board becomes a real Bluetooth keyboard: the same HID service every wireless keyboard has, so phones, Macs and PCs use it with their own driver. Its button turns into a remote: play/pause and skip the music on your phone (which can be playing on your JBL speaker), change the volume, click through slides, or type text you send from the serial monitor. You write the Report Map that tells the computer what our bytes mean, and you see why a keyboard never sends letters, only key numbers.

Goal

Pair the board as a keyboard, control your music with the button, and type text in the right layout.

You're done when

  • Your phone or Mac lists Bench B6 as a connected keyboard, and the screen's status bar shows the lock (encrypted) and the key (bonded).
  • A click on the media view pauses and resumes your music; a double-click skips the track; touching GPIO 2 turns it up.
  • type yes types “yes”, not “zes”: layout matches the computer's keyboard setting.
  • On the keys view you can read a press as bytes: modifier bits, key number, and the all-zero release after it.

You will learn

  • HID over GATT
  • report map
  • key numbers vs characters
  • keyboard layouts
  • consumer control
  • bonding
  • media remote
uv run pio run -d labs/ble-lab-b6 -e ble-lab-b6 -t upload
Open this lab's code on GitHubesp-labs / labs / ble-lab-b6 (opens in a new tab)

Parts required

Parts library
  • ESP32-S3-DevKitC-1 + USB-C data cable
  • 1.9″ ST7789 screen
  • Smartphone (Bluetooth)
  • Optional: Push button

A key press, from button to letter

Type in the box or press a key below and follow it: the board turns the character into a key number with ITS layout setting, sends 8 bytes, and the computer turns the number back into a character with ITS layout. Set the two layouts differently and type yes: that's the bug layout de fixes.

USB/BLE HID report descriptor breakdown for keyboard keycodes and consumer media controls. Type in the box or press a key below and follow it: the board turns the character into a key number with ITS layout setting, sends 8 bytes, and the computer turns the number back into a character with ITS layout. Set the two layouts differently and type yes: that's the bug layout de fixes.

  • Key concepts: HID over GATT, report map, key numbers vs characters, keyboard layouts, consumer control, bonding, media remote.
  • Signals & pins: 3V3 (VCC), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC), GPIO10 (CS).

Interactive diagram loads after page initialization.

Why the board can't play to your speaker

Your JBL plays music over Classic Bluetooth audio. The ESP32-S3 only has Bluetooth LE, so it can't stream to it, but it can be the remote for the phone that does. Press a media key to follow it, or try the direct path to see where it fails.

Interactive BLE media remote simulator sending play/pause and volume HID reports. Your JBL plays music over Classic Bluetooth audio. The ESP32-S3 only has Bluetooth LE, so it can't stream to it, but it can be the remote for the phone that does. Press a media key to follow it, or try the direct path to see where it fails.

  • Key concepts: HID over GATT, report map, key numbers vs characters, keyboard layouts, consumer control, bonding, media remote.
  • Signals & pins: 3V3 (VCC), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC), GPIO10 (CS).

Interactive diagram loads after page initialization.

What the screen shows

Six views. Media and slides are modes: there the button is the remote (click, double-click, hold), and a 2-second hold moves on. On the other views a click moves on as usual.

Gallery of ST7789 screens shown across the ESP32-S3 Bluetooth LE labs. Six views. Media and slides are modes: there the button is the remote (click, double-click, hold), and a 2-second hold moves on. On the other views a click moves on as usual.

  • Key concepts: HID over GATT, report map, key numbers vs characters, keyboard layouts, consumer control, bonding, media remote.
  • Signals & pins: 3V3 (VCC), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC), GPIO10 (CS).

Interactive diagram loads after page initialization.

Commands, in order

Type these in the serial monitor (uv run pio device monitor) unless the grey tag says otherwise. The coloured tag says what should be near the board while it runs.

  1. uv run pio run -d labs/ble-lab-b6 -e ble-lab-b6 -t uploadMac terminalno phone needed
    Does
    Builds lab B6 and flashes it (no new downloads: NimBLE came with B1).
    You should see
    ble-lab-b6: NimBLE 2.5.1 up, advertising as keyboard "Bench B6", the command list. The screen opens on the media view: “pair me: Bluetooth settings > Bench B6”.
    If not
    “Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
  2. Bluetooth settings → Bench B6 → Connect / Pairon your phonephone paired
    Does
    Your phone or Mac connects, reads the Report Map, asks to pair (HID needs encryption), and stores a bond so it reconnects by itself next time.
    You should see
    + connected, then + secured: Just Works, bonded, key 16 B. The status bar shows the linked rings, a violet lock and a key. A Mac may open the Keyboard Setup Assistant: close it, or press the key it asks for and pick ISO (German) or ANSI (US).
    If not
    Listed but won't connect: forget here AND “Forget This Device” on the phone, then pair again. A bond kept on only one side is the usual cause.
  3. (media view) click · double-click · touch GPIO 2push button / BOOTpaired as keyboard/MIDI
    Does
    Start music on the phone (to its speaker, earbuds or your JBL). Click = play/pause, double-click = next track, hold under 2 s = mute, touch the wire on GPIO 2 / 1 (after touch on) = volume up / down.
    You should see
    The icon ripples, a dot runs board → phone → speaker, and the music reacts. The monitor prints > media key: play/pause (usage 0CD).
    If not
    Nothing happens? The app must have audio focus: play something first. On a Mac, Music/Spotify react; a browser tab may not.
  4. type hello benchserial monitorpaired as keyboard/MIDI
    Does
    Open Notes (or any text field) on the paired device, then type this in the monitor. The board queues 2 reports per character (press, release) and sends 6 per frame, 8 ms apart.
    You should see
    “hello bench” appears on the phone or Mac. The typer view fills its progress bar, then says typed 11 keys.
    If not
    Only the line says not paired yet? Pair first. Letters come out wrong: see layout.
  5. layout de (or layout us)serial monitorpaired as keyboard/MIDI
    Does
    Tells the board which layout the COMPUTER is set to, so it picks the right key for each character. Saved in NVS.
    You should see
    layout German (QWERTZ) (saved). Now type yes gives “yes” on a German Mac. Characters the layout needs AltGr/Option for (@ [ ] { } \ | ~) are skipped with a warning.
    If not
    Still y/z swapped: the computer's layout is the other one. Check the input menu in the Mac's menu bar.
  6. key cmd+spaceserial monitorpaired as keyboard/MIDI
    Does
    One key or a combo: modifiers (cmd, ctrl, alt, shift) plus a key (enter, tab, esc, arrows, f1-f12, a letter).
    You should see
    Spotlight opens on the Mac (on an iPhone with a keyboard, the search too). The keys view shows modifier byte 08 (left GUI) and key 2C (space).
    If not
    Windows: key win+r opens Run, key ctrl+alt+delete the security screen.
  7. snippet my@mail.example (then double-click on typer)serial monitorpaired as keyboard/MIDI
    Does
    Saves a text in NVS; a double-click on the typer view (or snippet alone) types it. A tiny macro pad.
    You should see
    snippet saved, and the text on the typer view.
  8. (hold the button 2 s) → slides viewpush button / BOOTpaired as keyboard/MIDI
    Does
    Open a presentation (Keynote, PowerPoint, Google Slides in present mode). Click = right arrow (next), double-click = left arrow, hold under 2 s = b (black screen).
    You should see
    The slide on the screen slides in from the side you moved to; the deck on the computer follows.
  9. (click to the keys view)push button / BOOTpaired as keyboard/MIDI
    Does
    The last reports, byte by byte: the modifier bits, the key numbers, and what each press types with the board's layout.
    You should see
    down mod 02 key 04 types 'A' then up all zero for a capital A.

Steps

0 of 7 ticked. Ticks are saved in this browser.

While an iPhone or iPad is connected to a hardware keyboard, its on-screen keyboard hides: disconnect the board (or switch Bluetooth off) to get it back. To unpair, forget the board on both sides (forget here, “Forget This Device” there). The ESP32-S3 has Bluetooth LE only: it can't stream audio to a speaker or headphones (that's Classic Bluetooth, A2DP), so the board controls the phone and the phone plays to your JBL. Volume and track keys go to whichever app has audio focus. Hosts disagree on what Option/AltGr characters live where, so the German table only types what it can type the same way on Mac and Windows.

Preview: what you should see

Interactive BLE scanner and GATT monitor simulating NimBLE advertising discovery and characteristic updates.

  • Key concepts: HID over GATT, report map, key numbers vs characters, keyboard layouts, consumer control, bonding, media remote.
  • Signals & pins: 3V3 (VCC), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC), GPIO10 (CS).

Interactive diagram loads after page initialization.

ESP32-S3 peripherals used in this lab

Open interactive GPIO pinout

Explore the hardware blocks, pin rules, and registers behind this experiment.

  • GPIO and IO MUX

    45 pins, and a matrix that routes almost any signal to almost any pin

  • SPI

    Fast four-wire bus for screens, card readers and flash

  • Touch sensor

    Fourteen pins that feel a finger through capacitance

  • Bluetooth LE

    Bluetooth 5 Low Energy: beacons, phones, keyboards, MIDI

  • UART

    Three serial ports, the one you see in the serial monitor

  • CPU

    Two Xtensa LX7 cores at up to 240 MHz

Troubleshooting & hardware gotchas

See all 17 ESP32-S3 hardware gotchas
What if it does not work or behaves unexpectedly?
While an iPhone or iPad is connected to a hardware keyboard, its on-screen keyboard hides: disconnect the board (or switch Bluetooth off) to get it back. To unpair, forget the board on both sides (forget here, “Forget This Device” there). The ESP32-S3 has Bluetooth LE only: it can't stream audio to a speaker or headphones (that's Classic Bluetooth, A2DP), so the board controls the phone and the phone plays to your JBL. Volume and track keys go to whichever app has audio focus. Hosts disagree on what Option/AltGr characters live where, so the German table only types what it can type the same way on Mac and Windows.
If “uv run pio run -d labs/ble-lab-b6 -e ble-lab-b6 -t upload” does not work
“Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
If “Bluetooth settings → Bench B6 → Connect / Pair” does not work
Listed but won't connect: forget here AND “Forget This Device” on the phone, then pair again. A bond kept on only one side is the usual cause.
If “(media view) click · double-click · touch GPIO 2” does not work
Nothing happens? The app must have audio focus: play something first. On a Mac, Music/Spotify react; a browser tab may not.
If “type hello bench” does not work
Only the line says not paired yet? Pair first. Letters come out wrong: see layout.
If “layout de (or layout us)” does not work
Still y/z swapped: the computer's layout is the other one. Check the input menu in the Mac's menu bar.
If “key cmd+space” does not work
Windows: key win+r opens Run, key ctrl+alt+delete the security screen.
Four pins are read at reset
GPIO0, GPIO3, GPIO45 and GPIO46 are sampled the moment the chip comes out of reset: they pick the boot mode, the flash voltage, the ROM log and the JTAG source. Anything wired to them must not pull them the wrong way at power-up. After reset they are normal pins again.
GPIO3 has no pull resistor at reset
GPIO0 has a weak pull-up and GPIO45/46 weak pull-downs, but GPIO3 floats. When the eFuses make it choose the JTAG source, an outside circuit has to hold it at a clear level.
GPIO47 and 48 run at 1.8 V on R16V modules
Modules with the ESP32-S3R16V chip set the flash voltage to 1.8 V, and GPIO47/48 share that supply. A 3.3 V part on those pins sees the wrong levels.
The pins are not 5 V tolerant
A high input may go up to the pin's supply plus 0.3 V, so about 3.6 V on a 3.3 V board, and the power pins are rated to 3.6 V at most. 5 V from a sensor or an Arduino can damage the chip: use a level shifter or a divider.