Difference between revisions of "How to Use an RFID RC522 on Raspberry Pi"

From Wiki
Jump to: navigation, search
(Resource)
(Resource)
Line 84: Line 84:
  
 
=='''Resource'''==
 
=='''Resource'''==
[http://wiki.sunfounder.cc/index.php/File:MFRC522_datasheet.pdf MFRC522 datasheet][[File:PDF.jpg]]
+
[http://wiki.sunfounder.cc/images/c/c6/MFRC522_datasheet.pdf MFRC522 datasheet][[File:PDF.jpg]]

Revision as of 07:35, 20 March 2017

Introduction

The MFRC522 is a highly integrated reader/writer IC for contactless communication at 13.56 MHz. The MFRC522 reader supports ISO/IEC 14443 A/MIFARE mode.
The MFRC522’s internal transmitter is able to drive a reader/writer antenna designed to communicate with ISO/IEC 14443 A/MIFARE cards and transponders without additional active circuitry. The receiver module provides a robust and efficient implementation for demodulating and decoding signals from ISO/IEC 14443 A/MIFARE compatible cards and transponders. The digital module manages the complete ISO/IEC 14443 A framing and error detection (parity and CRC) functionality.
RFID0127.png

Enable Device Tree

Edit /boot/config.txt

sudo nano /boot/config.txt

Add the line below to the bottom of config.txt

device_tree=on

Hit Ctrl + O to save, and Ctrl + X to exit.

Setup SPI:

Run raspi-config

sudo raspi-config

Go through: 9 Advanced Options -> A5 SPI->Yes
Then press Enter three times to enable SPI as default settings Select finish and reboot

Install python-dev and git:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-dev git

Wiring:

Name Pin# Pin Name
VCC 1 3V3
RST 22 GPIO25
GND Any Any Ground
MISO 21 GPIO9
MOSI 19 GPIO10
SCK 23 GPIO11
NSS 24 GPIO8
IRQ None None

Install SPI-Py

cd ~
git clone https://github.com/lthiery/SPI-Py.git
cd SPI-Py/
sudo python setup.py install

Get MFRC522-python library

cd ~
git clone https://github.com/mxgxw/MFRC522-python.git
cd MFRC522-python/

Now Run:

To read card

sudo python Read.py

To write card

sudo python Write.py

Resource

MFRC522 datasheetPDF.jpg