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 R4

RFID & NFC · lesson 4 of 8

Open the card's memory

built, not flashed

A MIFARE Classic 1K holds 1,024 bytes: 16 sectors × 4 blocks × 16 bytes. Every sector has its own lock, the trailer: two keys plus access bits that say who may read or write each block. Open each sector of your own card with the factory key and dump it.

Goal

Dump your own card's whole memory and explain block 0 and one sector trailer byte by byte.

You're done when

  • dump ends with dump: 16 sectors read, and the memory view is all coloured (no grey “closed” sectors).
  • In the dump you can point to the UID in block 0 and to FF 07 80 69 in a trailer, and the decoder above explains what FF 07 80 allows.

You will learn

  • sectors & blocks
  • sector trailers
  • access bits (stored twice)
  • 3-pass authentication
  • encrypted frames
  • manufacturer block
uv run pio run -d labs/rfid-lab-r4 -e rfid-lab-r4 -t upload
Open this lab's code on GitHubesp-labs / labs / rfid-lab-r4 (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

The card's memory, in 3D

Each cabinet is a sector, each slab a block, the top slab the trailer with its lock. Click a sector, then Authenticate: only then can its blocks be read.

3D map of MIFARE Classic 1K memory: 16 sectors, 4 blocks per sector, Key A/B authentication, and access bits. Each cabinet is a sector, each slab a block, the top slab the trailer with its lock. Click a sector, then Authenticate: only then can its blocks be read.

  • Key concepts: sectors & blocks, sector trailers, access bits (stored twice), 3-pass authentication, encrypted frames, manufacturer block.
  • Signals & pins: 3V3 (VCC), 3V3 (RC 3.3V), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC).

Interactive diagram loads after page initialization.

Access bits decoder

Bytes 6–8 of every trailer decide who may do what in that sector. Tick the bits or type the three bytes from your dump.

MIFARE Classic sector trailer access-bit decoder showing safe vs locked read/write permissions. Bytes 6–8 of every trailer decide who may do what in that sector. Tick the bits or type the three bytes from your dump.

  • Key concepts: sectors & blocks, sector trailers, access bits (stored twice), 3-pass authentication, encrypted frames, manufacturer block.
  • Signals & pins: 3V3 (VCC), 3V3 (RC 3.3V), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC).

Interactive diagram loads after page initialization.

Authenticate and read, step by step

What one read 4 does on the bus and in the air.

ISO14443-A handshake sequence showing REQA/WUPA, ATQA, anticollision cascade, and SAK responses. What one read 4 does on the bus and in the air.

  • Key concepts: sectors & blocks, sector trailers, access bits (stored twice), 3-pass authentication, encrypted frames, manufacturer block.
  • Signals & pins: 3V3 (VCC), 3V3 (RC 3.3V), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC).
  • Walkthrough flows: read.

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: sectors & blocks, sector trailers, access bits (stored twice), 3-pass authentication, encrypted frames, manufacturer block.
  • 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-r4 -e rfid-lab-r4 -t uploadMac terminalcard: doesn't matter
    Does
    Flashes lab R4's own firmware: everything from R3, plus the memory view, dump and read. help lists exactly this lab's commands.
    You should see
    rfid-lab-r4: 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. dump (or double-click on the memory view)serial monitorcard on, held still
    Does
    For each of the 16 sectors: authenticate with the factory key A, read its 4 blocks, decode the trailer. About 1.5 s; keep the card still.
    You should see
    64 lines (block, 16 bytes, ASCII, meaning), then dump: 16 sectors read. The memory view: block 0 amber, empty blocks dark, trailers coral.
    If not
    Grey “closed” sectors: their key isn't the factory key (a card someone set up): the lab leaves those alone. “no card”: it moved; run it again.
  3. read 0serial monitorcard on the reader
    Does
    Authenticates sector 0 and reads block 0 only.
    You should see
    UID (4 bytes), BCC, then 08 04 00 (SAK, ATQA), then the maker's bytes.
  4. read 1 (with trace on)serial monitorcard on the reader
    Does
    The same for block 1, with the sniffer showing the frames.
    You should see
    AUTH key A marked as done inside the chip, then READ and 16 bytes, both “[encrypted on air]”.

Steps

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

Authentication runs inside the MFRC522 (its MFAuthent command): the ESP32 hands over the key and never sees the handshake, and the key never goes into the trace. The firmware only uses the factory key, on cards you own, and never writes block 0 or a trailer: a trailer with broken access bits locks its sector for good.

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: sectors & blocks, sector trailers, access bits (stored twice), 3-pass authentication, encrypted frames, manufacturer block.
  • 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?
Authentication runs inside the MFRC522 (its MFAuthent command): the ESP32 hands over the key and never sees the handshake, and the key never goes into the trace. The firmware only uses the factory key, on cards you own, and never writes block 0 or a trailer: a trailer with broken access bits locks its sector for good.
If “uv run pio run -d labs/rfid-lab-r4 -e rfid-lab-r4 -t upload” does not work
“Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
If “dump (or double-click on the memory view)” does not work
Grey “closed” sectors: their key isn't the factory key (a card someone set up): the lab leaves those alone. “no card”: it moved; 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.