RFID & NFC · lesson 8 of 8
A friend lives on every card
A lab for kids, built from R7's parts. Its own firmware (rfid-lab-r8) makes every card the home of a friend: a fox, a robot, a dragon, a penguin, an alien, a cat, a frog or a unicorn. Tap a card and its friend pops out on the board's screen with stars in its colours, and in 3D in a small React app (esp-labs/apps/friends-app), with its own move, sparkles, sky and tune. Card 1 and card 2 show different friends; tap both and they play together. A new card adds itself on its first tap, and you drag a friend onto it. The app has two tabs: Play for the kids, Setup for the grown-up (real or pretend board, reader health, the card list, sound, calm motion, day or night).
Give the white card and the key tag a friend each, then tap them and watch both friends play.
You're done when
- The app's Setup tab shows live, the reader chip B2h, and the card count going up as you tap new cards.
- A new card shows a wobbling ? on the screen and “New card! Who lives here?” in the app.
- After dragging a friend onto it, the friend pops out on the screen and in 3D at the same moment.
- Tapping card 1, then card 2, puts two different friends on the 3D stage, each on its own numbered card.
- Poking a friend on the 3D stage makes it play its move again.
On the board
You will learn
- UID as a key
- auto-enrolment
- state on the board, show in the app
- WebSocket push
- drag and drop with pointer events
- three.js toon shading
- Web Audio
- accessible alternatives (tap, keyboard)
uv run pio run -d labs/rfid-lab-r8 -e rfid-lab-r8 -t uploadParts required
Parts library- ESP32-S3-DevKitC-1 + USB-C data cable
- 1.9″ ST7789 screen
- RC522 card reader
- MIFARE card and key fob
- 2.4 GHz Wi-Fi network
Meet the cast
The eight friends, drawn the way the board draws them (circles and triangles, no pictures in flash). Press one to see what it does. The board stores only its id; the app knows its move, sparkles, sky and tune.
Binary payload encoder packing pixel avatar sprites and friend metadata into MIFARE Classic data blocks. The eight friends, drawn the way the board draws them (circles and triangles, no pictures in flash). Press one to see what it does. The board stores only its id; the app knows its move, sparkles, sky and tune.
- Key concepts: UID as a key, auto-enrolment, state on the board, show in the app, WebSocket push, drag and drop with pointer events, three.js toon shading, Web Audio, accessible alternatives (tap, keyboard).
- Signals & pins: 3V3 (VCC), 3V3 (RC 3.3V), GPIO7 (BLK), GPIO8 (RES), GPIO9 (DC).
Interactive diagram loads after page initialization.
Follow one tap, and a new card getting a friend
The card only brings its UID. The board decides who lives there, shows it on its own screen and tells every app.
Read/write protocol sequence transferring custom friend profiles onto physical MIFARE Classic cards. The card only brings its UID. The board decides who lives there, shows it on its own screen and tells every app.
- Key concepts: UID as a key, auto-enrolment, state on the board, show in the app, WebSocket push, drag and drop with pointer events, three.js toon shading, Web Audio, accessible alternatives (tap, keyboard).
- 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.
uv run pio run -d labs/rfid-lab-r8 -e rfid-lab-r8 -t uploadMac terminalcard: doesn't matter- Does
- Flashes the friends firmware. It uses R7's web libraries and the Wi-Fi network W1/W2 saved.
- You should see
- FRIENDS stage, a breathing card outline and “Tap a card!”,
http://bench.localat the bottom once Wi-Fi joins. - If not
- “no Wi-Fi saved: run W1 once”: flash W1,
join, then R8 again.
tokenserial monitorcard: doesn't matter- Does
- Prints the admin token (the same one W2 and R7 use). Moving a friend onto a card needs it.
- You should see
Admin token: 3f…- If not
- Keep it out of chats and git.
cd esp-labs/apps/friends-app && cp .env.example .envMac terminalcard: doesn't matter- Does
BENCH_URL=http://bench.local(or the IP fromstatus),BENCH_TOKEN=the token.- You should see
- A git-ignored .env next to package.json.
pnpm install, then pnpm devMac terminalcard: doesn't matter- Does
- Starts the app on port 5175 (it can run next to the door-app). Vite forwards /api and /ws to the board and adds the token. A tablet on the same Wi-Fi can open it on the Mac's address.
- You should see
http://localhost:5175: Play and Setup tabs, “board live” at the top.- If not
- No board at hand? Setup → Pretend board plays by the same rules in the browser.
tap a card it hasn't seenwith your handscard on, then move it- Does
- The board adds it as the next card (up to 12) with nobody on it.
- You should see
- Screen: a wobbling ? card, “New card! Give it a friend”. App: a new tile calling for a friend.
- If not
- “12 cards!”: forget one in Setup, or serial
forget 3.
drag a friend onto the cardin the appcard: doesn't matter- Does
- Or tap the friend, then the card (or Enter, Enter with the keyboard). Sends
PUT /api/card?uid=… {"character":"robot"}, then shows it. Serial:give 2 robot. - You should see
- The friend pops out on the screen and on the 3D stage; the tile shows its face.
- If not
- 401: BENCH_TOKEN is missing or old, restart
pnpm devafter changing .env.
tap card 1, then card 2with your handscard on, then move it- Does
- Each tap: the friend's move, sparkles, sky and tune. Two cards within 30 s play together; three at most.
- You should see
- Two friends on the stage, each standing on its numbered card.
- If not
- No sound: touch the page once (browsers need that), or check Setup → Sound.
Setup → name on this cardin the appcard: doesn't matter- Does
- A name for that friend on that card (up to 15 plain characters). Serial:
name 1 Rusty,name 1 -to go back. - You should see
- “Hi again! Rusty” on the screen and in the bubble.
cards, castserial monitorcard: doesn't matter- Does
- Lists every card with its friend and visits, and the friends this firmware knows.
- You should see
1 9C4F2A1B fox Foxy taps 5
Steps
0 of 7 ticked. Ticks are saved in this browser.
The friend is not on the card: the board keeps a list (UID → friend id) in its NVS, namespace friends, separate from R7's door list. So any card works, even one you can't write, and moving a friend is instant. The same idea as R7 (the card only brings its UID) in a friendlier costume. The 3D figures are built in code from spheres, cones and boxes with toon shading, so there are no model files, and the board's screen draws the same shapes in 2D.
Preview: what you should see
Interactive MIFARE card avatar viewer displaying friend profiles stored directly on RFID tags.
- Key concepts: UID as a key, auto-enrolment, state on the board, show in the app, WebSocket push, drag and drop with pointer events, three.js toon shading, Web Audio, accessible alternatives (tap, keyboard).
- 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 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
- Wi-Fi
2.4 GHz 802.11b/g/n, as a station, an access point or both
- 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 friend is not on the card: the board keeps a list (UID → friend id) in its NVS, namespace friends, separate from R7's door list. So any card works, even one you can't write, and moving a friend is instant. The same idea as R7 (the card only brings its UID) in a friendlier costume. The 3D figures are built in code from spheres, cones and boxes with toon shading, so there are no model files, and the board's screen draws the same shapes in 2D.
- If “uv run pio run -d labs/rfid-lab-r8 -e rfid-lab-r8 -t upload” does not work
- “no Wi-Fi saved: run W1 once”: flash W1,
join, then R8 again. - If “token” does not work
- Keep it out of chats and git.
- If “pnpm install, then pnpm dev” does not work
- No board at hand? Setup → Pretend board plays by the same rules in the browser.
- If “tap a card it hasn't seen” does not work
- “12 cards!”: forget one in Setup, or serial
forget 3. - If “drag a friend onto the card” does not work
- 401: BENCH_TOKEN is missing or old, restart
pnpm devafter changing .env. - If “tap card 1, then card 2” does not work
- No sound: touch the page once (browsers need that), or check Setup → Sound.
- 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.
- ADC2 stops working while Wi-Fi is on
- The ADC2 channels (GPIO11-20) cannot be used at the same time as Wi-Fi: the radio shares ADC2 through an arbiter. Put analog sensors on ADC1 (GPIO1-10), as the sound labs do with GPIO6.
- 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.