rppal_mfrc522

Crates.iorppal_mfrc522
lib.rsrppal_mfrc522
version0.2.0
created_at2025-06-07 18:19:06.30158+00
updated_at2025-07-06 00:35:24.841398+00
descriptionMFRC522 interface crate using the rppal crate and SPI
homepage
repositoryhttps://github.com/jlyonsmith/rppal_mfrc522
max_upload_size
id1704281
size1,600,253
John Lyon-Smith (jlyonsmith)

documentation

README

RPPAL MFRC522

coverage Crates.io Docs.rs

Details

This is a crate for controlling MFRC522 based RFID boards. It is specifically designed to work with rppal over an SPI interface. My goal for this library was to be able to easily, reliably and synchronously read the 4-byte UID from PICC cards, key fobs and stickers when building escape room puzzles.

I was motivated to build this crate because I sadly could not get the mfrc522 crate to work. Specifically the select() call seems broken. I was able to get the very old Python code in mfrc522-python working. So I reproduced the Python code in Rust, then merged in some of the nicer design elements of the mfrc522 crate.

In the process I tried to fully document what the code is doing in comments to remove a lot of the mystery about the MFRC522 chip configuration and interfacing. Wherever possible I linked to the MFRC522 datasheet section so you can read about it yourself. I also included the PDF's for the MFRC522 and PICC cards in the repository.

What is implemented:

  • SPI communication with an MFRC522 board using rppal::spi::Spi.
  • uid() function to read card identifiers
  • version() function to read the board manufacturing identifier
  • Proper division of timeouts across internal calls

What does not work:

  • Collision detection of multiple cards
  • Reading/writing the PICC card data

I used the [cross][4] crate for cross compilation to the aarch64-unknown-linux-gnu Raspberry Pi 64-bit platform. I have not been able to get the code coverage to work properly so the 100% code coverage number is incorrect.

Command Line Tool

The crate includes a command line program for testing called rppal-mfrc522. Run it with the --help argument to see options.


Commit count: 30

cargo fmt