uhf-rfid

Crates.iouhf-rfid
lib.rsuhf-rfid
version1.0.1
created_at2025-11-28 19:44:47.15983+00
updated_at2025-12-04 14:38:03.125052+00
descriptionDriver for M5Stack UHF RFID reader with support for multiple transport backends
homepage
repositoryhttps://github.com/awalland/uhf-rfid
max_upload_size
id1955934
size904,789
Armin Walland (awalland)

documentation

README

Build codecov

uhf-rfid

A Rust driver for M5Stack UHF RFID readers with support for multiple transport backends.

Features

  • ESP32 UART support - Native UART transport for ESP32 using esp-idf-hal
  • Desktop serial support - Serial port transport using the serialport crate
  • Full EPC Gen2 support - Tag polling, reading, writing, locking, and killing
  • Advanced configuration - Region settings, RF link profiles, frequency hopping, and more
  • Vendor extensions - NXP UCODE and Impinj Monza specific commands

Installation

Add to your Cargo.toml:

[dependencies]
uhf-rfid = "0.1"

Enable the appropriate feature for your platform:

# For desktop/Linux serial port
uhf-rfid = { version = "0.1", features = ["serial"] }

# For ESP32
uhf-rfid = { version = "0.1", features = ["uart-esp32"] }

Usage

Desktop (Serial Port)

use uhf_rfid::{UhfRfid, SerialTransport};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let transport = SerialTransport::new("/dev/ttyUSB0", 115200)?;
    let mut rfid = UhfRfid::new(transport);

    // Get firmware version
    let version = rfid.get_firmware_version()?;
    println!("Firmware: {}", version);

    // Poll for a single tag
    if let Some(tag) = rfid.single_poll()? {
        println!("Found tag: {} (RSSI: {})", tag.epc, tag.rssi);
    }

    // Poll for multiple tags (100 inventory rounds)
    let tags = rfid.multiple_poll(100)?;
    for tag in tags {
        println!("Tag: {}", tag.epc);
    }

    // Poll with callback for real-time processing (100 inventory rounds)
    let count = rfid.multiple_poll_with_callback(100, |tag| {
        println!("Discovered tag: {} (RSSI: {})", tag.epc, tag.rssi);
    })?;
    println!("Total tags found: {}", count);

    Ok(())
}

ESP32 (UART)

use esp_idf_svc::hal::peripherals::Peripherals;
use uhf_rfid::{UhfRfid, UartTransport};

fn main() -> anyhow::Result<()> {
    esp_idf_svc::sys::link_patches();

    let peripherals = Peripherals::take()?;

    let transport = UartTransport::new(
        peripherals.uart1,
        peripherals.pins.gpio17, // TX
        peripherals.pins.gpio16, // RX
        115200,
    )?;

    let mut rfid = UhfRfid::new(transport);

    // Get firmware version
    let version = rfid.get_firmware_version()?;
    println!("Firmware: {}", version);

    // Poll for tags
    if let Some(tag) = rfid.single_poll()? {
        println!("Found tag: {} (RSSI: {})", tag.epc, tag.rssi);
    }

    Ok(())
}

Supported Operations

  • Polling: Single and multiple tag inventory
  • Memory access: Read/write tag memory banks (EPC, TID, User, Reserved)
  • Security: Lock and kill tags
  • Configuration: TX power, region, channel, frequency hopping, baud rate
  • Advanced: Select filtering, query parameters, RF link profiles
  • Vendor-specific: NXP EAS, read protect; Impinj Monza QT

License

Licensed under either of:

at your option.

Commit count: 0

cargo fmt