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 B5

Bluetooth LE · lesson 5 of 8

Your own app, straight to the board

built, not flashed

nRF Connect is a screwdriver; now you build the tool. esp-labs/apps/ble-app is a small React app that uses Web Bluetooth: the browser itself becomes the GATT client, so a web page on your Mac or phone talks to the board with no Wi-Fi, no server and no app store. The firmware keeps B3's Bench service and adds four characteristics: a Canvas you draw on from the phone, Sensors that stream five times a second, a Speed test that pushes notifications as fast as the radio allows, and Link controls to change the connection while you watch the speed move.

Goal

Control and draw on the board from a web page, and measure how many bytes per second your link really carries.

You're done when

  • The app's Connect tab lists the Bench service with LED … Uptime plus Canvas, Sensors, Speed and Link (ba5e0010-0013), and its byte log shows every operation.
  • A stroke drawn in the Sketch tab appears on the board's sketch view within a fraction of a second.
  • The Live tab charts four lines; touching a jumper wire on GPIO 1 makes the touch line jump.
  • A 50 kB speed run ends with a kB/s figure in the app and the same run as a bar on the board's speed view; after Fast interval or 2M PHY the next run is visibly faster (or you can say why not).

You will learn

  • Web Bluetooth
  • GATT client in JavaScript
  • write without response
  • binary protocols
  • notification streams
  • throughput = MTU × packets ÷ interval
  • 2M PHY & long packets
uv run pio run -d labs/ble-lab-b5 -e ble-lab-b5 -t upload
Open this lab's code on GitHubesp-labs / labs / ble-lab-b5 (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

One colour change, from JavaScript to the LED

What happens between navigator.bluetooth.requestDevice() in the app and the LED changing colour, and how a notification finds its way back into a chart. Each step shows the real call or the real bytes on air. Pick a flow, then step with ◀ ▶.

Web Bluetooth API flow connecting Chrome/Android directly to the ESP32-S3 GATT server. What happens between navigator.bluetooth.requestDevice() in the app and the LED changing colour, and how a notification finds its way back into a chart. Each step shows the real call or the real bytes on air. Pick a flow, then step with ◀ ▶.

  • Key concepts: Web Bluetooth, GATT client in JavaScript, write without response, binary protocols, notification streams, throughput = MTU × packets ÷ interval, 2M PHY & long packets.
  • Signals & pins: 3V3 (VCC), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC), GPIO10 (CS).

Interactive diagram loads after page initialization.

How fast can it go?

Throughput is decided by four numbers: how big each packet may be (MTU), how often the two radios meet (the connection interval), how many packets fit in one meeting, and how fast the bits fly (PHY). Move the sliders: the timeline shows three connection events with every packet drawn to scale, and the result is the same formula the Speed tab measures.

BLE throughput calculator comparing connection interval, ATT MTU size, and PHY rate. Throughput is decided by four numbers: how big each packet may be (MTU), how often the two radios meet (the connection interval), how many packets fit in one meeting, and how fast the bits fly (PHY). Move the sliders: the timeline shows three connection events with every packet drawn to scale, and the result is the same formula the Speed tab measures.

  • Key concepts: Web Bluetooth, GATT client in JavaScript, write without response, binary protocols, notification streams, throughput = MTU × packets ÷ interval, 2M PHY & long packets.
  • Signals & pins: 3V3 (VCC), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC), GPIO10 (CS).

Interactive diagram loads after page initialization.

What the screen shows

Six views. Click for the next one; double-click on sketch clears it, on speed it starts a 50 kB run, on gatt it sends a Button click. Every gesture also reaches the app as a Button notification, as in B3.

Gallery of ST7789 screens shown across the ESP32-S3 Bluetooth LE labs. Six views. Click for the next one; double-click on sketch clears it, on speed it starts a 50 kB run, on gatt it sends a Button click. Every gesture also reaches the app as a Button notification, as in B3.

  • Key concepts: Web Bluetooth, GATT client in JavaScript, write without response, binary protocols, notification streams, throughput = MTU × packets ÷ interval, 2M PHY & long packets.
  • 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-b5 -e ble-lab-b5 -t uploadMac terminalno phone needed
    Does
    Builds lab B5 and writes it to the board.
    You should see
    The sketch view: “Open the ble-app, connect”. The radio icon shows rings: advertising as Bench B5.
    If not
    “Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
  2. cd esp-labs/apps/ble-app && pnpm install && pnpm devMac terminalno phone needed
    Does
    Installs the app once (React, Vite, TypeScript, exact versions) and serves it at http://localhost:5177. No server code: Vite only hands the page to the browser.
    You should see
    ➜ Local: http://localhost:5177/
    If not
    Port busy: another lab's app runs; stop it or pnpm dev --port 5178.
  3. open http://localhost:5177 in Chrome → Connectin the appphone: scanner app open
    Does
    The browser's own device chooser opens (a page can never connect by itself). It lists boards with the Bench service, names starting with “Bench”, or BLE-MIDI instruments.
    You should see
    Pick Bench B5. The Connect tab shows the GATT explorer; the monitor prints + connected: …. The first time, macOS asks to allow Chrome to use Bluetooth.
    If not
    “Web Bluetooth isn't available here”: use Chrome or Edge, and localhost (not 127.0.0.1 or the Mac's IP).
  4. Control tab: drag the colour wheel, send a messagein the appphone connected
    Does
    Each move writes 3 bytes to LED (throttled to one write per 80 ms); Send writes up to 40 bytes of UTF-8 to Message.
    You should see
    The LED follows your finger; < write LED 1F 5C 99 lines in the monitor and blue packets crossing the app's air strip.
    If not
    LED stays put after led auto: move the wheel again, the board claims the LED back.
  5. Sketch tab: drawin the appphone connected
    Does
    Strokes go to Canvas (ba5e0010) as writes without response: 02 cc cc w n + 3 bytes per point, every 50 ms. The board queues them in the NimBLE task and draws them in loop().
    You should see
    The same lines on the board's sketch view; at the bottom 412 cmds 96 writes 9120 B.
    If not
    DROPPED on the board: you drew faster than 16 queued writes; nothing breaks, a few strokes are missing. sketch: a command was cut off: the app fell back to 20-byte writes (MTU 23).
  6. Live tab (then touch the wire on GPIO 1)in the appphone connected
    Does
    Subscribes to Sensors: 12 bytes every 200 ms (temperature, touch, free heap, RSSI, a sequence number).
    You should see
    Four moving lines in the app and the same four sparklines on the board's live view; “notifying the app: 230 sent”. Touching the wire's free end makes the touch value jump by thousands.
    If not
    Touch line flat: GPIO 1 has no wire; any jumper works, the bare metal end is the sensor.
  7. Speed tab: 50 kB → Runin the appphone connected
    Does
    Subscribes to Speed and writes 01 50 C3 00 00. A small task on the board notifies 50,000 bytes in (MTU − 3)-byte packets until the stack's buffers are full, waits, and continues; then a 15-byte summary.
    You should see
    Monitor: < write Speed: start 50000 bytes then + speed: 50000 B in 2310 ms = 21.6 kB/s. The app shows a bar with the same order of magnitude.
    If not
    speed: subscribe to Speed (ba5e0012) first: open the Speed tab once before running from serial.
  8. Speed tab: Fast interval, 2M PHY, Long packets → Run againin the appphone connected
    Does
    Writes 1, 3 and 5 to Link: the board asks the central for a 7.5–15 ms interval, the 2M PHY and 251-byte radio packets.
    You should see
    - new params: 15.00 ms …, - PHY now 2M / 2M; the next run is faster. The board's speed view keeps one bar per run with MTU, interval and PHY.
    If not
    No change: the central decides. macOS often keeps 15 ms and allows 2M; some phones refuse 7.5 ms or 2M. That is the lesson: the peripheral can only ask.
  9. pnpm tunnel → open the https address on your phoneMac terminalphone: scanner app open
    Does
    A cloudflared quick tunnel gives the app an https://…trycloudflare.com address, because phones only allow Web Bluetooth on https.
    You should see
    Android: Chrome opens it and the same chooser appears. iPhone: open it in the free Bluefy browser (Safari has no Web Bluetooth).
    If not
    Bluefy says the page isn't secure: use the https address, not http.

Steps

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

Still no pairing: anyone near can connect, draw and read the sensors. B4's lock works the same here if you combine them. The app only ever sees boards you pick in the browser's chooser, and the browser hides some standard services from web pages on purpose. iPhones and Macs cache a device's GATT table by its address: if the explorer shows B3's old rows, turn Bluetooth off and on. Throughput depends mostly on the central: the same board is often 2-4× faster with a Mac than with a phone.

Preview: what you should see

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

  • Key concepts: Web Bluetooth, GATT client in JavaScript, write without response, binary protocols, notification streams, throughput = MTU × packets ÷ interval, 2M PHY & long packets.
  • 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

  • Temperature sensor

    Measures the die's own temperature

  • UART

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

Troubleshooting & hardware gotchas

See all 17 ESP32-S3 hardware gotchas
What if it does not work or behaves unexpectedly?
Still no pairing: anyone near can connect, draw and read the sensors. B4's lock works the same here if you combine them. The app only ever sees boards you pick in the browser's chooser, and the browser hides some standard services from web pages on purpose. iPhones and Macs cache a device's GATT table by its address: if the explorer shows B3's old rows, turn Bluetooth off and on. Throughput depends mostly on the central: the same board is often 2-4× faster with a Mac than with a phone.
If “uv run pio run -d labs/ble-lab-b5 -e ble-lab-b5 -t upload” does not work
“Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
If “cd esp-labs/apps/ble-app && pnpm install && pnpm dev” does not work
Port busy: another lab's app runs; stop it or pnpm dev --port 5178.
If “open http://localhost:5177 in Chrome → Connect” does not work
“Web Bluetooth isn't available here”: use Chrome or Edge, and localhost (not 127.0.0.1 or the Mac's IP).
If “Control tab: drag the colour wheel, send a message” does not work
LED stays put after led auto: move the wheel again, the board claims the LED back.
If “Sketch tab: draw” does not work
DROPPED on the board: you drew faster than 16 queued writes; nothing breaks, a few strokes are missing. sketch: a command was cut off: the app fell back to 20-byte writes (MTU 23).
If “Live tab (then touch the wire on GPIO 1)” does not work
Touch line flat: GPIO 1 has no wire; any jumper works, the bare metal end is the sensor.
If “Speed tab: 50 kB → Run” does not work
speed: subscribe to Speed (ba5e0012) first: open the Speed tab once before running from serial.
If “Speed tab: Fast interval, 2M PHY, Long packets → Run again” does not work
No change: the central decides. macOS often keeps 15 ms and allows 2M; some phones refuse 7.5 ms or 2M. That is the lesson: the peripheral can only ask.
If “pnpm tunnel → open the https address on your phone” does not work
Bluefy says the page isn't secure: use the https address, not http.
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.