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 B7

Bluetooth LE · lesson 7 of 8

A Bluetooth MIDI instrument

built, not flashed

The board becomes a MIDI instrument over Bluetooth LE, using the standard BLE-MIDI service that GarageBand, Audio MIDI Setup, Android synth apps and Chrome all understand. MIDI carries notes, not sound: the synth on the other side makes the sound (and can send it to your JBL). Play with the button, five touch wires, serial commands and a 16-step drum machine; notes played on the other side light the board's piano strip and its LED. You see how notes are packed with timestamps, and why the connection interval sets the latency.

Goal

Play notes from the board into a synth, and see the synth's notes on the board.

You're done when

  • GarageBand (or the ble-app Music tab) lists Bench B7 and makes a sound when you click the button.
  • tune twinkle plays the tune; beat house + seq on plays drums on channel 10.
  • Notes you play on the synth's keyboard light the board's piano strip in blue, and the LED takes each note's colour.
  • The link view shows your connection interval, and you can say how long a note may wait for the radio.

You will learn

  • MIDI messages
  • BLE-MIDI packets
  • timestamps
  • running status
  • connection interval = latency
  • capacitive touch
  • General MIDI drums
uv run pio run -d labs/ble-lab-b7 -e ble-lab-b7 -t upload
Open this lab's code on GitHubesp-labs / labs / ble-lab-b7 (opens in a new tab)

Parts required

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

One note, byte by byte

Play the little keyboard (click, or the keys A to K on your computer). Notes pressed within one connection event share one packet. Watch the header, the timestamps, the status byte and running status, the trick that drops repeated status bytes.

BLE MIDI timestamped packet encoder packing Note On/Off and velocity bytes over GATT. Play the little keyboard (click, or the keys A to K on your computer). Notes pressed within one connection event share one packet. Watch the header, the timestamps, the status byte and running status, the trick that drops repeated status bytes.

  • Key concepts: MIDI messages, BLE-MIDI packets, timestamps, running status, connection interval = latency, capacitive touch, General MIDI drums.
  • Signals & pins: 3V3 (VCC), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC), GPIO10 (CS).

Interactive diagram loads after page initialization.

Why notes wait: the connection interval

A connected device may only talk at connection events, one every interval. Pick an interval and play: each note waits for the next event. Then compare a synth that plays notes when they arrive with one that uses the timestamps.

Latency jitter chart comparing BLE connection intervals for real-time MIDI performance. A connected device may only talk at connection events, one every interval. Pick an interval and play: each note waits for the next event. Then compare a synth that plays notes when they arrive with one that uses the timestamps.

  • Key concepts: MIDI messages, BLE-MIDI packets, timestamps, running status, connection interval = latency, capacitive touch, General MIDI drums.
  • Signals & pins: 3V3 (VCC), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC), GPIO10 (CS).

Interactive diagram loads after page initialization.

What the screen shows

Five views. On keys, sequencer and roll the button is the instrument (click a note, double-click a chord or start/stop the drums, hold for all notes off, hold 2 s to move on).

Gallery of ST7789 screens shown across the ESP32-S3 Bluetooth LE labs. Five views. On keys, sequencer and roll the button is the instrument (click a note, double-click a chord or start/stop the drums, hold for all notes off, hold 2 s to move on).

  • Key concepts: MIDI messages, BLE-MIDI packets, timestamps, running status, connection interval = latency, capacitive touch, General MIDI drums.
  • 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-b7 -e ble-lab-b7 -t uploadMac terminalno phone needed
    Does
    Builds lab B7 and flashes it.
    You should see
    advertising as MIDI instrument "Bench B7", the command list, the keys view with five keys and a piano strip.
    If not
    “Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
  2. Mac: Audio MIDI Setup → Window → Show MIDI Studio → Bluetooth icon → Bench B7 → Connecton your phonepaired as keyboard/MIDI
    Does
    macOS connects to the board as a MIDI device (it may ask to pair: accept). Then open GarageBand with a software instrument: it hears every MIDI device.
    You should see
    + connected, asked for a 7.5-15 ms interval (low latency), + a synth is listening (subscribed). The keys view says “synth listening”.
    If not
    iPhone/iPad: GarageBand → open a keyboard → settings (gear) → Advanced → Bluetooth MIDI Devices → Bench B7. Android: a BLE-MIDI app (e.g. “MIDI BLE Connect”) plus any synth. Chrome: the ble-app Music tab.
  3. (click the button)push button / BOOTpaired as keyboard/MIDI
    Does
    Plays the next note of the scale (300 ms). Double-click = a chord. Hold under 2 s = all notes off.
    You should see
    A sound from GarageBand; the key lights violet on the piano strip; the roll draws a violet bar.
    If not
    No sound but “synth listening”: in GarageBand, pick a software instrument track (not audio) and turn the volume up.
  4. tune twinkle (or ode, frere)serial monitorpaired as keyboard/MIDI
    Does
    Schedules a whole public-domain tune at the current tempo. loop() sends each note when it's due.
    You should see
    tune twinkle: 14 notes, 8.4 s and the tune from the synth.
  5. beat house, then seq onserial monitorpaired as keyboard/MIDI
    Does
    The drum machine: 4 drums x 16 steps on MIDI channel 10, where General MIDI keeps the drums (36 kick, 38 snare, 42 hi-hat, 39 clap).
    You should see
    The sequencer view's playhead walks the grid; GarageBand plays drums (pick a drum kit track for the real sound).
    If not
    Drums sound like piano notes: the track's instrument isn't a drum kit.
  6. touch onserial monitorpaired as keyboard/MIDI
    Does
    Five jumper wires on GPIO 1, 2, 6, 13, 14 (loose ends) become keys of the pentatonic scale. Hands off while it measures the baseline.
    You should see
    touch on: 5 keys, pentatonic from C4; touching a wire end lights its key and plays the note, a firmer touch = louder.
    If not
    GPIO 13 and 14 are the RC522's wires from the RFID track: unplug the reader, or use the first three keys.
  7. (play the synth's own keyboard)in the apppaired as keyboard/MIDI
    Does
    GarageBand (or the ble-app piano) sends MIDI back to the board as writes.
    You should see
    Blue keys on the piano strip, blue bars on the roll, the LED in the note's colour, < note E4 vel 96 ch 1 lines.
    If not
    On a Mac, GarageBand doesn't send to MIDI devices: use the ble-app piano, or a DAW with MIDI output.
  8. (click to the link view)push button / BOOTpaired as keyboard/MIDI
    Does
    Explains the latency: notes wait for the next connection event.
    You should see
    Your interval (7.5-15 ms if the host agreed, often 11.25 or 15 on Apple devices) and a press dropping to the next tick.

Steps

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

MIDI is instructions, not audio: the board never makes a sound itself (it has no speaker). The synth's audio can go anywhere it can play, your JBL included, through the phone or Mac's own Bluetooth. Apple hosts usually grant 11.25-15 ms connection intervals for MIDI, so a note waits up to one interval; the timestamps inside each packet let a good synth keep the rhythm anyway. If the Mac asks to pair, accept: the board allows Just Works bonding. Only public-domain tunes are built in.

Preview: what you should see

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

  • Key concepts: MIDI messages, BLE-MIDI packets, timestamps, running status, connection interval = latency, capacitive touch, General MIDI drums.
  • 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?
MIDI is instructions, not audio: the board never makes a sound itself (it has no speaker). The synth's audio can go anywhere it can play, your JBL included, through the phone or Mac's own Bluetooth. Apple hosts usually grant 11.25-15 ms connection intervals for MIDI, so a note waits up to one interval; the timestamps inside each packet let a good synth keep the rhythm anyway. If the Mac asks to pair, accept: the board allows Just Works bonding. Only public-domain tunes are built in.
If “uv run pio run -d labs/ble-lab-b7 -e ble-lab-b7 -t upload” does not work
“Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
If “Mac: Audio MIDI Setup → Window → Show MIDI Studio → Bluetooth icon → Bench B7 → Connect” does not work
iPhone/iPad: GarageBand → open a keyboard → settings (gear) → Advanced → Bluetooth MIDI Devices → Bench B7. Android: a BLE-MIDI app (e.g. “MIDI BLE Connect”) plus any synth. Chrome: the ble-app Music tab.
If “(click the button)” does not work
No sound but “synth listening”: in GarageBand, pick a software instrument track (not audio) and turn the volume up.
If “beat house, then seq on” does not work
Drums sound like piano notes: the track's instrument isn't a drum kit.
If “touch on” does not work
GPIO 13 and 14 are the RC522's wires from the RFID track: unplug the reader, or use the first three keys.
If “(play the synth's own keyboard)” does not work
On a Mac, GarageBand doesn't send to MIDI devices: use the ble-app piano, or a DAW with MIDI output.
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.