| Crates.io | uhf-rfid |
| lib.rs | uhf-rfid |
| version | 1.0.1 |
| created_at | 2025-11-28 19:44:47.15983+00 |
| updated_at | 2025-12-04 14:38:03.125052+00 |
| description | Driver for M5Stack UHF RFID reader with support for multiple transport backends |
| homepage | |
| repository | https://github.com/awalland/uhf-rfid |
| max_upload_size | |
| id | 1955934 |
| size | 904,789 |
A Rust driver for M5Stack UHF RFID readers with support for multiple transport backends.
esp-idf-halserialport crateAdd 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"] }
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(())
}
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(())
}
Licensed under either of:
at your option.