Bluetooth LE · lesson 2 of 8
The board shouts its own data
In B1 the board listened. Now it becomes a beacon: it packs live values (button presses, the chip's temperature, uptime) into its own 31-byte advertisement, so any phone nearby can read them without connecting. The same budget then carries an iBeacon, an Eddystone-URL or just a name. You choose how often it shouts (the interval) and how loud (TX power), and see what that would cost a coin-cell beacon.
Make the board broadcast live values that your phone reads without ever connecting.
You're done when
- nRF Connect lists Bench B2 and shows Manufacturer data 0xFFFF whose bytes change every second (the uptime) and when you double-click (the presses).
- The packet view shows 24 of 31 bytes in coloured structures, and the changing bytes flash white.
mode ibeaconshows up as an iBeacon on Android (on iPhone apps can't see iBeacons: that's iOS, not you),mode urlas an Eddystone URL in nRF Connect.- With
connectable offandscanresp offthe packet view says ADV_NONCONN_IND, nRF Connect no longer offers Connect, and the interval can't go below 100 ms. - You can explain from the budget view why beacons advertise every 500-1000 ms and not every 20.
On the board
You will learn
- broadcaster role
- 31-byte budget
- AD structures
- manufacturer data
- iBeacon & Eddystone
- ADV_IND · SCAN_IND · NONCONN
- interval & advDelay
- TX power vs battery
uv run pio run -d labs/ble-lab-b2 -e ble-lab-b2 -t uploadParts required
Parts library- ESP32-S3-DevKitC-1 + USB-C data cable
- 1.9″ ST7789 screen
- Smartphone (Bluetooth)
- Optional: Push button
Build an advertisement
Every field you add costs its data plus 2 bytes (length and type). Put each one in the advertisement, in the scan response (sent only when a scanner asks), or leave it out, and watch the 31-byte budget fill. The board's four modes are presets.
Interactive BLE advertising payload builder showing the 31-byte legacy PDU budget for flags, name, and service UUIDs. Every field you add costs its data plus 2 bytes (length and type). Put each one in the advertisement, in the scan response (sent only when a scanner asks), or leave it out, and watch the 31-byte budget fill. The board's four modes are presets.
- Key concepts: broadcaster role, 31-byte budget, AD structures, manufacturer data, iBeacon & Eddystone, ADV_IND · SCAN_IND · NONCONN, interval & advDelay, TX power vs battery.
- Signals & pins: 3V3 (VCC), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC), GPIO10 (CS).
Interactive diagram loads after page initialization.
When does a scanner hear it?
The board sends each advertising event on channels 37, 38 and 39 in a row, every interval plus a random 0-10 ms. A phone listens on one channel at a time, for a window out of each scan interval. Slide the numbers and count what gets caught. Switch the random delay off to see why it exists.
Timing comparison of BLE advertising intervals (20 ms to 10.24 s) trading discovery latency against power draw. The board sends each advertising event on channels 37, 38 and 39 in a row, every interval plus a random 0-10 ms. A phone listens on one channel at a time, for a window out of each scan interval. Slide the numbers and count what gets caught. Switch the random delay off to see why it exists.
- Key concepts: broadcaster role, 31-byte budget, AD structures, manufacturer data, iBeacon & Eddystone, ADV_IND · SCAN_IND · NONCONN, interval & advDelay, TX power vs battery.
- Signals & pins: 3V3 (VCC), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC), GPIO10 (CS).
Interactive diagram loads after page initialization.
What the screen shows
Four views. A click goes to the next one; a double-click anywhere counts a press into the packet; a long press switches advertising on or off.
Gallery of ST7789 screens shown across the ESP32-S3 Bluetooth LE labs. Four views. A click goes to the next one; a double-click anywhere counts a press into the packet; a long press switches advertising on or off.
- Key concepts: broadcaster role, 31-byte budget, AD structures, manufacturer data, iBeacon & Eddystone, ADV_IND · SCAN_IND · NONCONN, interval & advDelay, TX power vs battery.
- 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.
uv run pio run -d labs/ble-lab-b2 -e ble-lab-b2 -t uploadMac terminalno phone needed- Does
- Builds lab B2 and writes it to the board.
- You should see
- The packet view:
bench ADV_IND every 100 msand two rows of coloured cells. - If not
- “Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
uv run pio device monitorMac terminalno phone needed- Does
- Opens the serial monitor.
- You should see
+ bench ADV_IND every 100 ms, 24+7 Band the command list.
nRF Connect → Scanner → Bench B2 (tap the row, don't connect)on your phonephone: scanner app open- Does
- The phone is the scanner now (one board can't hear itself). Tapping the row opens the advertisement's details.
- You should see
- Complete Local Name
Bench B2, Manufacturer data0xFFFF 0x01…; the last two bytes (uptime) change every second. Tap RAW to see all 24 bytes. - If not
- Not listed: pull down to refresh;
adv on. On iPhone, Manufacturer data shows as one hex string: the same bytes.
(double-click the button) or presspush button / BOOTphone: scanner app open- Does
- Counts a press into the packet. The board replaces the advertisement data; the controller sends the new bytes from the next event on.
- You should see
- presses 1: in the next packet; on the packet view two cells flash white; in nRF Connect byte 4-5 of the manufacturer data becomes01 00.
bytesserial monitorno phone needed- Does
- Prints both packets structure by structure.
- You should see
[02 01 | 06] Flags,[09 09 | 42 65 6E 63 68 20 42 32] Name,[0A FF | FF FF 01 01 00 2E 10 2C 01] Manufacturer data.
mode ibeaconserial monitorphone: scanner app open- Does
- Apple's layout: 4C 00 02 15, a 16-byte UUID, major, minor, the power at 1 m. 30 of 31 bytes: the name moves to the scan response.
- You should see
+ ibeacon ADV_IND every 100 ms, 30+10 B. Android nRF Connect: “iBeacon”, UUID BA5E0000-B1E5-…, Major 1, Minor 2. B1 on another board would show the beacon kind in violet.- If not
- iPhone shows nothing special, or not the beacon: iOS filters iBeacon frames out of every app's scan. Only Core Location (region monitoring) sees them.
mode url, then url https://github.com/serial monitorphone: scanner app open- Does
- Eddystone-URL: service data FEAA with a compressed URL (https:// = 1 byte, .com/ = 1 byte).
- You should see
- nRF Connect shows Eddystone URL https://github.com/. A URL too long:
x the URL doesn't fit…, and the old one stays. - If not
- Android used to pop these up as notifications (Physical Web); that's gone since 2018. Apps still decode them.
connectable off, then scanresp offserial monitorphone: scanner app open- Does
- First ADV_SCAN_IND (may be scanned, not connected), then ADV_NONCONN_IND: a pure broadcast that answers nobody.
- You should see
- The packet view's title changes; nRF Connect's Connect button disappears; the scan response row empties.
- If not
intervalraised to 100 ms: the floor for non-connectable adverts (Bluetooth 4.x rule; 5.0 allows 20, beacons stay at 100+).
interval 20, interval 1000serial monitorphone: scanner app open- Does
- How often the board shouts. Click to the air and budget views for each.
- You should see
+ … every 1000 ms; nRF Connect's interval column (Android) or the RSSI graph updates slower; the budget's coin-cell life jumps from weeks to years.- If not
interval 20refused with connectable off: switch connectable on first.
power -12, power 9serial monitorphone: scanner app open- Does
- TX power in dBm (the shell's built-in command). Lower = shorter range and less current.
- You should see
- nRF Connect's RSSI drops by about 20 dB at the same distance; the name mode's TX power field changes too.
adv off (or a long press)serial monitorphone: scanner app open- Does
- Stops advertising. The board is invisible.
- You should see
- advertising off: the board is invisible; nRF Connect greys it out after a few seconds.
Steps
0 of 6 ticked. Ticks are saved in this browser.
Anyone nearby can read what the board broadcasts: never put anything private in an advertisement. 0xFFFF is the company ID the Bluetooth SIG reserves for tests, fine on a bench, not for a product. iPhone apps can't see iBeacon frames at all (iOS removes them from scans), so test that mode on Android or with B1 on a second board. The budget view is an estimate for a typical coin-cell beacon chip with its stated assumptions: this ESP32-S3 board itself draws about 80 mA with the screen on, far too much for a coin cell. The one radio can't hear itself, so the phone is the scanner in this lab.
Preview: what you should see
Interactive BLE scanner and GATT monitor simulating NimBLE advertising discovery and characteristic updates.
- Key concepts: broadcaster role, 31-byte budget, AD structures, manufacturer data, iBeacon & Eddystone, ADV_IND · SCAN_IND · NONCONN, interval & advDelay, TX power vs battery.
- 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 pinoutExplore 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
- 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
- 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?
- Anyone nearby can read what the board broadcasts: never put anything private in an advertisement. 0xFFFF is the company ID the Bluetooth SIG reserves for tests, fine on a bench, not for a product. iPhone apps can't see iBeacon frames at all (iOS removes them from scans), so test that mode on Android or with B1 on a second board. The budget view is an estimate for a typical coin-cell beacon chip with its stated assumptions: this ESP32-S3 board itself draws about 80 mA with the screen on, far too much for a coin cell. The one radio can't hear itself, so the phone is the scanner in this lab.
- If “uv run pio run -d labs/ble-lab-b2 -e ble-lab-b2 -t upload” does not work
- “Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
- If “nRF Connect → Scanner → Bench B2 (tap the row, don't connect)” does not work
- Not listed: pull down to refresh;
adv on. On iPhone, Manufacturer data shows as one hex string: the same bytes. - If “mode ibeacon” does not work
- iPhone shows nothing special, or not the beacon: iOS filters iBeacon frames out of every app's scan. Only Core Location (region monitoring) sees them.
- If “mode url, then url https://github.com/” does not work
- Android used to pop these up as notifications (Physical Web); that's gone since 2018. Apps still decode them.
- If “connectable off, then scanresp off” does not work
intervalraised to 100 ms: the floor for non-connectable adverts (Bluetooth 4.x rule; 5.0 allows 20, beacons stay at 100+).- If “interval 20, interval 1000” does not work
interval 20refused with connectable off: switch connectable on first.- 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.