Das Modul bietet einen Einstieg in die RFID/NFC Interaktion.
Das Modul besitzt sieben Pins, 3.3V, RST, GND, IRQ, MISO (Master Input, Slave Output), MOSI (Master Output, Slave Input), SCK (Serial Clock), SDA.
RFID-RC522 | Raspberry PI |
---|---|
3.3V | Pin 1 – 3.3V |
RST | Pin 22 – GPIO 25 |
GND | Pin 25 – DNC |
IRQ | |
MISO | Pin 21 – SP10 MISO |
MOSI | Pin 19 – SP10 MOSI |
SCK | Pin 23 – SP10 SCLK |
SDA | Pin 24 – SP10 CEO N |
Das Modul nutzet SPI (Serial Peripheral Interface).
Um das Modul zu laden nutzt man modprobe.
1 2 |
sudo modprobe spi_bcm2708 sudo modprobe spi-bcm2835 |
Man kann es auch wie folgt beim Starten laden.
1 |
sudo nano /etc/modprobe.d/raspi-blacklist.conf |
Folgende Zeile wird dazu auskommentiert.
1 |
#blacklist spi-bcm2708 |
Um zu testen ob das Modul geladen und erkannt worden ist, können folgende Kommandos genutzt werden.
1 2 |
lsmod | grep spi_ ls -la /sys/bus/spi/devices/ |
Dann installiert man SPI-Py und die benötigten Werkzeuge.
1 2 3 4 5 6 |
sudo apt-get install python-dev sudo apt-get install gcc git clone https://github.com/lthiery/SPI-Py cd SPI-Py sudo python setup.py install |
Um das Modul zu nutzen gibt es eine Python Implementierung des Beispiel Codes.
1 2 3 |
git clone https://github.com/mxgxw/MFRC522-python cd MFRC522-python sudo python Read.py |
Nachdem das Programm zum lesen gestartet wurde, wird die Karte ausgelesen.
1 2 3 4 5 6 7 8 9 10 |
Welcome to the MFRC522 data read example Press Ctrl-C to stop. Card detected Card read UID: 4,64,218,95 Size: 8 Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] Card detected Card read UID: 194,200,140,69 Size: 8 Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] |