Skip to content
esp-labsESP32-S3 bench guide
ESP32-S3 DevKitC pinoutThis lesson uses: VCC on 3V3, RC 3.3V on 3V3, BLK on 7, RES on 8, DC on 9, CS on 10, SDA on 11, SCL on 12, GND on GND, RC SDA on 15, RC SCK on 16, MOSI on 17, MISO on 18, RC RST on 14, IRQ on 13, RC GND on GND, BTN on 5, BOOT on 0.ESP32-S3WROOM-1 N16R8BOOTRSTRGBUSBCOM3V3VCC3V3RC 3.3VRST45BTN67BLK15RC SDA16RC SCK17MOSI18MISO8RES3469DC10CS11SDA12SCL13IRQ14RC RST5VGNDGNDGNDRC GNDTX 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 R3

RFID & NFC · lesson 3 of 8

Two cards at once: anticollision

built, not flashed

Lay the card and the tag on the reader together. Both answer at the same instant, bit by bit, and where their UIDs differ the reader hears a collision. Anticollision walks down the bits like a binary tree: pick a branch, ask again with that prefix, select the card that's left, halt it, repeat until nobody answers.

Goal

Find both cards at once, and point to the exact bit where their UIDs collided.

You're done when

  • inventory lists 2 cards with both UIDs.
  • It names the collision bit, and the walk-through above lands on the same bit with your two UIDs.

You will learn

  • bit collisions
  • binary tree walk
  • NVB
  • BCC
  • cascade levels
  • SAK
  • HALT · WUPA
uv run pio run -d labs/rfid-lab-r3 -e rfid-lab-r3 -t upload
Open this lab's code on GitHubesp-labs / labs / rfid-lab-r3 (opens in a new tab)

Parts required

Parts library
  • ESP32-S3-DevKitC-1 + USB-C data cable
  • 1.9″ ST7789 screen
  • RC522 card reader
  • MIFARE card and key fob

Anticollision: a walk down the bits

The two rows are the UID bits of two cards, in the order they travel (least significant bit of byte 0 first). Step through: where the bits differ the reader hears a collision, picks 1, and only the matching card keeps answering. Type your own UIDs from the monitor.

Interactive binary tree walkthrough of ISO14443-A anticollision resolving two RFID cards in the same RF field. The two rows are the UID bits of two cards, in the order they travel (least significant bit of byte 0 first). Step through: where the bits differ the reader hears a collision, picks 1, and only the matching card keeps answering. Type your own UIDs from the monitor.

  • Key concepts: bit collisions, binary tree walk, NVB, BCC, cascade levels, SAK, HALT · WUPA.
  • Signals & pins: 3V3 (VCC), 3V3 (RC 3.3V), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC).

Interactive diagram loads after page initialization.

What the screen shows

The board's screen has six views. A click on the push button (or BOOT) goes to the next one, a double-click runs the action written at the bottom left, a long press pauses card polling. Pick a view to see what each part means; the numbers match the list below it.

Gallery of ST7789 display screens rendered during the RC522 RFID labs. The board's screen has six views. A click on the push button (or BOOT) goes to the next one, a double-click runs the action written at the bottom left, a long press pauses card polling. Pick a view to see what each part means; the numbers match the list below it.

  • Key concepts: bit collisions, binary tree walk, NVB, BCC, cascade levels, SAK, HALT · WUPA.
  • Signals & pins: 3V3 (VCC), 3V3 (RC 3.3V), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC).

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/rfid-lab-r3 -e rfid-lab-r3 -t uploadMac terminalcard: doesn't matter
    Does
    Flashes lab R3's own firmware: everything from R2, plus inventory (and a double-click on the card view runs it). help lists exactly this lab's commands.
    You should see
    rfid-lab-r3: reader task started, then this lab's command list and views.
    If not
    “Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
  2. lay the card and the tag togetherwith your handscard + tag together
    Does
    Both cards wake on the same WUPA. The poll resolves the collision and selects one of them.
    You should see
    The card view shows one UID (always the same one) and an amber line: collision at bit 23 (your bit will differ).
    If not
    Only one card found? Overlap them more: both must sit inside the antenna's loop.
  3. inventory (or double-click on the card view)serial monitorcard + tag together
    Does
    Switches the field off for 10 ms so every card restarts, then REQA → select → halt, again and again until nobody answers.
    You should see
    #1 9C:4F:6A:0D … collision at level 1 bit 23 -> chose 1, #2 9C:4F:2A:1B …, then inventory: 2 cards in the field.
    If not
    select failed (collision): move the cards a little and run it again.
  4. inventory with one card, then noneserial monitorcard on, then move it
    Does
    Same walk, nothing to resolve.
    You should see
    1 card without a collision line, then 0 cards.

Steps

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

Bits travel least-significant first, so “bit 23” is bit 6 of the third UID byte. Our driver is tested for two cards at once: with three or more, the chip's collision position after the first branch is harder to trust. 7-byte UIDs take two cascade levels; the first part starts with 88h, the cascade tag.

Preview: what you should see

Interactive RC522 13.56 MHz RFID reader simulator showing tag detection, VersionReg 0x92, UIDs, and serial monitor logs.

  • Key concepts: bit collisions, binary tree walk, NVB, BCC, cascade levels, SAK, HALT · WUPA.
  • Signals & pins: 3V3 (VCC), 3V3 (RC 3.3V), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC).

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

  • UART

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

  • CPU

    Two Xtensa LX7 cores at up to 240 MHz

  • SRAM

    512 KB of fast on-chip RAM for your code and data

  • ROM

    384 KB of factory code: the bootloader and download mode

Troubleshooting & hardware gotchas

See all 17 ESP32-S3 hardware gotchas
What if it does not work or behaves unexpectedly?
Bits travel least-significant first, so “bit 23” is bit 6 of the third UID byte. Our driver is tested for two cards at once: with three or more, the chip's collision position after the first branch is harder to trust. 7-byte UIDs take two cascade levels; the first part starts with 88h, the cascade tag.
If “uv run pio run -d labs/rfid-lab-r3 -e rfid-lab-r3 -t upload” does not work
“Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
If “lay the card and the tag together” does not work
Only one card found? Overlap them more: both must sit inside the antenna's loop.
If “inventory (or double-click on the card view)” does not work
select failed (collision): move the cards a little and run it again.
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.