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 R1

RFID & NFC · lesson 1 of 8

Wire the reader and talk to its chip

built, not flashed

Its own firmware (rfid-lab-r1; every RFID lab has its own) with our own driver in kit/lib/rfid-kit: no RFID library, so every byte is ours to see. Eight wires put the RC522 on the S3's second SPI bus, so it never shares with the screen. The first conversation is with the chip itself, not a card: its version register, the self-test from the datasheet, and 3,200 bytes through its FIFO and back.

Goal

Prove that the ESP32 and the reader chip talk to each other reliably over SPI, before any card is involved. Keep the card and the tag away for now.

You're done when

  • The monitor says VersionReg 0x92: MFRC522 v2.0 (or 0x91, or a clone's value), not 0x00 or 0xFF.
  • selftest ends with self-test passed: 64/64 bytes match on a genuine NXP chip (91h/92h), or self-test consistent: 2 runs, same 64 bytes on a clone such as the FM17522 (88h/B2h).
  • loopback says 0 of 3200 bytes wrong.
  • On the chip view: the square glows teal and the bus counters keep climbing.

You will learn

  • SPI address byte
  • registers
  • FIFO
  • datasheet self-test
  • two SPI buses
  • reading a bus fault
uv run pio run -d labs/rfid-lab-r1 -e rfid-lab-r1 -t upload
Open this lab's code on GitHubesp-labs / labs / rfid-lab-r1 (opens in a new tab)

Parts required

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

One register read, bit by bit

Every command in this lesson is built from transfers like this one. It is what a logic analyser would show on the four SPI wires while the ESP32 reads one register: 16 clock ticks, two bytes. The first byte goes out on MOSI and says which register and read or write; during the second byte the chip answers on MISO. chip does exactly this with VersionReg. Use ◀ ▶ to step bit by bit, pick another register, or choose a fault to see what a loose wire turns the answer into: that is how you'll read 00h or FFh in your own monitor.

SPI bus signal timing diagram showing SCK, MOSI, MISO, and independent Chip Select (CS) lines for the RC522 and ST7789. Every command in this lesson is built from transfers like this one. It is what a logic analyser would show on the four SPI wires while the ESP32 reads one register: 16 clock ticks, two bytes. The first byte goes out on MOSI and says which register and read or write; during the second byte the chip answers on MISO. chip does exactly this with VersionReg. Use ◀ ▶ to step bit by bit, pick another register, or choose a fault to see what a loose wire turns the answer into: that is how you'll read 00h or FFh in your own monitor.

  • Key concepts: SPI address byte, registers, FIFO, datasheet self-test, two SPI buses, reading a bus fault.
  • 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: SPI address byte, registers, FIFO, datasheet self-test, two SPI buses, reading a bus fault.
  • Signals & pins: 3V3 (VCC), 3V3 (RC 3.3V), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC).

Interactive diagram loads after page initialization.

RC522 wiring (8 new wires, the screen stays as it is)

RC522 pinESP32-S3Role
SDAGPIO 15chip select (NSS) in SPI mode, not I2C data
SCKGPIO 16SPI clock, from the ESP32
MOSIGPIO 17data ESP32 → chip
MISOGPIO 18data chip → ESP32
IRQGPIO 13optional: the chip says “done”
GNDGNDthe right header's top pin
RSTGPIO 14reset; low = power-down
3.3V3V3the second 3V3 pin. Never 5V

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-r1 -e rfid-lab-r1 -t uploadMac terminalcard away
    Does
    Builds lab R1's firmware and writes it to the board (no new downloads: it only uses the display libraries you already have).
    You should see
    Hard resetting via RTS pin…. The screen starts on the card view: rings, “Hold a card or tag”.
    If not
    “Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
  2. uv run pio device monitorMac terminalcard away
    Does
    Opens the serial monitor. Opening it restarts the board, so you see the start-up lines.
    You should see
    RC522 on SPI3: SS 15 SCK 16 MOSI 17 MISO 18 RST 14 IRQ 13 · 4 MHz then VersionReg 0x92: MFRC522 v2.0 and the command list.
    If not
    0x00: the chip isn't powered or MISO is stuck low: check 3.3V, GND, RST. 0xFF: nobody drives MISO: check MISO (18) and SDA (15).
  3. chipserial monitorcard: doesn't matter
    Does
    Reads VersionReg (37h) once more: the 2-byte transfer shown above, live.
    You should see
    The same line as at start-up (0x92, or e.g. 0xB2: FM17522 (clone)). Run it a few times, and again after moving the card around: it must never change.
    If not
    It changes, or turns into 00h/FFh after you touched the reader = a loose wire. Press the RC522's header in or solder it, then reset.
  4. resetserial monitorcard: doesn't matter
    Does
    Pulses the RST wire (a hard reset of the chip), sets it up again and reads VersionReg. The firmware also checks VersionReg by itself every 2 s and does this on its own when the chip goes quiet.
    You should see
    hard reset: VersionReg 0x92 (or your clone's value). If the chip had gone quiet: chip back after a hard reset = it had hung; still 0x00 after a reset = a wire.
    If not
    Still 00h/FFh: power off, press the header pins in (or solder them), check 3.3V, GND, MISO (18), SDA (15).
  5. selftestserial monitorcard: doesn't matter
    Does
    The datasheet's digital self-test (section 16.1.1): resets the chip and has it compute a fixed 64-byte sequence. A genuine NXP chip (91h/92h) is compared with the datasheet's table. A clone has no table, so the test runs twice and the two runs are compared. Polling pauses while it runs, so the card can stay where it is.
    You should see
    4 rows of 16 bytes with no ! marks, then self-test passed: 64/64 bytes match (NXP) or self-test consistent: 2 runs, same 64 bytes (clone). The chip view says passed or consistent.
    If not
    self-test skipped: chip silent (0x00) = the chip wasn't answering before the test even started: a wire, see reset. ! marks = bytes that differ: re-seat SCK/MOSI/MISO and run again. doesn't run the self-test = some clones simply don't have it; loopback is the test that counts then.
  6. loopbackserial monitorcard: doesn't matter
    Does
    Writes 64-byte patterns into the chip's FIFO and reads them back, 50 times: 3,200 bytes each way.
    You should see
    FIFO loopback: 0 of 3200 bytes wrong at 4 MHz in teal at the bottom right of the screen.
    If not
    Any errors at 4 MHz = a bad contact on SCK, MOSI or MISO, or wires much longer than 20 cm.
  7. regsserial monitorcard: doesn't matter
    Does
    Prints 15 registers with their bits and what they mean.
    You should see
    VersionReg 92h, TxControlReg 83h (antenna on), RFCfgReg 40h (33 dB gain), TPrescalerReg A9h + TReloadReg 03 E8 (a 25 ms timer: 1,000 ticks of 25 µs).
    If not
    TxControlReg 80h = antenna off: the chip was reset without our set-up. Unplug and replug the board.
  8. spi 20, then loopback, then spi 4serial monitorcard: doesn't matter
    Does
    Optional peek at the edge lab: runs the bus at 20 MHz, twice the chip's rating, then back to the default.
    You should see
    Maybe a few wrong bytes at 20 MHz, maybe none: it depends on your wires. The chip view's SPI clock turns amber above 10.
    If not
    Always finish with spi 4. The R6 edge lab measures this properly.

Steps

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

The on-board RGB LED tells you what the reader sees: a bright green flash each time a card is read, steady green while one lies on the reader, red if the reader chip stops answering (a wire), off otherwise. Many RC522 boards come with the header loose: push-in pins lose contact, so solder it or press it in firmly. IRQ is optional: without it the firmware polls, and the chip view says “polling” (R6 compares both). The card's position doesn't change any of R1's results. But handling it near the reader is the moment loose header pins lose contact: if VersionReg turns 00h/FFh afterwards, the firmware notices within 2 s, tries a hard reset and tells you whether it was a hang or a wire.

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: SPI address byte, registers, FIFO, datasheet self-test, two SPI buses, reading a bus fault.
  • 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

  • RMT

    Plays and records exact pulse trains: IR remotes, RGB LEDs

  • 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

Troubleshooting & hardware gotchas

See all 17 ESP32-S3 hardware gotchas
What if it does not work or behaves unexpectedly?
The on-board RGB LED tells you what the reader sees: a bright green flash each time a card is read, steady green while one lies on the reader, red if the reader chip stops answering (a wire), off otherwise. Many RC522 boards come with the header loose: push-in pins lose contact, so solder it or press it in firmly. IRQ is optional: without it the firmware polls, and the chip view says “polling” (R6 compares both). The card's position doesn't change any of R1's results. But handling it near the reader is the moment loose header pins lose contact: if VersionReg turns 00h/FFh afterwards, the firmware notices within 2 s, tries a hard reset and tells you whether it was a hang or a wire.
If “uv run pio run -d labs/rfid-lab-r1 -e rfid-lab-r1 -t upload” does not work
“Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
If “uv run pio device monitor” does not work
0x00: the chip isn't powered or MISO is stuck low: check 3.3V, GND, RST. 0xFF: nobody drives MISO: check MISO (18) and SDA (15).
If “chip” does not work
It changes, or turns into 00h/FFh after you touched the reader = a loose wire. Press the RC522's header in or solder it, then reset.
If “reset” does not work
Still 00h/FFh: power off, press the header pins in (or solder them), check 3.3V, GND, MISO (18), SDA (15).
If “selftest” does not work
self-test skipped: chip silent (0x00) = the chip wasn't answering before the test even started: a wire, see reset. ! marks = bytes that differ: re-seat SCK/MOSI/MISO and run again. doesn't run the self-test = some clones simply don't have it; loopback is the test that counts then.
If “loopback” does not work
Any errors at 4 MHz = a bad contact on SCK, MOSI or MISO, or wires much longer than 20 cm.
If “regs” does not work
TxControlReg 80h = antenna off: the chip was reset without our set-up. Unplug and replug the board.
If “spi 20, then loopback, then spi 4” does not work
Always finish with spi 4. The R6 edge lab measures this properly.
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.