/RFID-RC522

Python files for using the RFID-RC522 Radiofrequency IC Card on the Beaglebone Black

Primary LanguagePythonMIT LicenseMIT

Python RC522 library

rc522 consists of two Python classes for controlling an SPI RFID module "RC522" using Beaglebone Black.

MIFARE datasheet datasheet.

MIFARE Access Bits Calculator Access Bits Calculator.

Sectors? Blocks?

Classic 1K MIFARE tag has 16 sectors, each contains 4 blocks. Each block has 16 bytes. All this stuff is indexed - you must count from zero. The library uses "block addresses", which are positions of blocks - so block address 5 is second block of second sector, thus it's block 1 of sector 1 (indexes). Block addresses 0, 1, 2, 3 are from the first sector - sector 0. Block addresses 4, 5, 6, 7 are from the second sector - sector 1, and so on. You should not write to first block - S0B0, because it contains manufacturer data. Each sector has it's sector trailer, which is located at it's last block - block 3. This block contains keys and access bits for corresponding sector. For more info, look at page 10 of the datasheet.

Connecting

Connecting RC522 module to SPI is pretty easy. You can use Beaglebone Black Pinout for reference.

Board pin name Board pin Beaglebone Black pin name
SDA 1 P9_17, SPI0_CS0
SCK 2 P9_22, SPI0_SCLK
MOSI 3 P9_18, SPI0_D1
MISO 4 P9_21, SPI0_D0
IRQ 5 P9_15, GPIO_48
GND 6 P9_01, Ground
RST 7 P9_23, GPIO_49
3.3V 8 P9_03, VDD_3V3

pins