RFID RC 522 On the Raspberry Pi 3 by Barend on 2017-01-13

Using the RFID RC552 on the Raspberry Pi3

 

 

 

 

A bit of History:

 

The Exact roots of where radio frequency identification technology came from is a bit blurry. But it all points to the same place: World war II. Radar was used to detect planes approaching, and warn the gunners to get ready for action! Problem…. They didn’t know who’s planes it was.

 

(This image was brought to you by: https://coreykope.com/2015/06/23/friendly-fire/)

 

Why was the radar upgrade so important you ask??

To quote Elon Musk: “The scope of your success is determined by your previous failures”.

 

Lett’s have a look at what we had as a solution for detecting planes before radar…

 

(These images have been brought to us by the historic images group:http://rarehistoricalphotos.com/aircraft-detection-radar-1917-1940/)

 

Women have similar abilities as the above when they “detect” that someone is gossiping about them!! (I Know!! Terrible joke!! ) . Back to facts… This was the actual military issue airplane detection equipment!!

 

 

To eliminate the human factor, They needed to create an electrical system to detect incoming planes.

Germany and Great Britan were amongst the first countries to complete the system. called:

 

……….. 

 

They started out being able to detect and object. (not just sound). This left them with the problem of identifying the Allied, from the Axis planes. The Germans quickly realized that if you rolled your planes as they returned, it would alter the radio signal reflected back to base.

 

 

 

This crude method was able to inform the ground crews that they were German planes and not allied aircraft. That was essentially, the first passive RFID system invented!

 

History lesson OVER!!

 

 

(This image was brought to you by:http://daily-life-buff.com/children-do-in-fact-experience-sleeping-disorders/)

 

 

Looking at the components we will be using:

RFID RC552

 

What do you get you ask??

 

  • 1 x RFID-RC522 module
  • 1 x Standard S50 blank card (Non-contact IC card)
  • 1 x S50 special-shaped card (key ring shape)
  • 1 x Straight and 1 x angled male to male header(Soldering required)

 

Let’s look at some of the specs:

 

  • Electrical parameters:
  • Operating current :13-26mA/DC 3.3V
  • Idle current :10-13mA/DC 3.3V
  • Sleep current: <80uA
  • Peak current: <30mA
  • Operating Frequency: 13.56MHz
  • Supported card types: mifare1 S50, mifare1 S70 MIFARE Ultralight, Mifare Pro, MIFARE DESFire
  • Product physical characteristics: size: 40mm×60mm
  • Environmental Operating temperature: -20 to +80°C
  • Environmental Storage Temperature: -40 to +85°C
  • Relative humidity: relative humidity 5%-95%

 

Additional parts that you might need?

 

 

The Wiring:

(Remember to have your Pi switched-off while you do your wiring. Wiring live can cause short circuits and damage your Pi)
Name Pin# Pin Name
3.3V 1 3V3
RST 22 GPIO25
GND Any Any Ground
IRQ none none
MISO 21 GPIO09
MOSI 19 GPIO10
SCK 23 GPIO11
SDA 24 GPIO08

 

 

Enable Device Tree:

Go into your terminal and complete the following:

 

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 the SPI:

Run raspi-config

sudo raspi-config

Select option: 

  • “9 Advanced Options ” (Then:)
  • A5 SPI
  • and select: Yes

 

Then press Enter three times to enable SPI as default settings Select finish

 

  • Reboot the Pi with:

Sudo Reboot

 

Install pyhon-dev and git:

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

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 (this one is programmed. But I have not been able to write anything on the card yet.)

sudo python Write.py
 

 

 

Resources:

Thank you for the following that have supplied us with awesome links and images!!!

 

  • https://www.sunfounder.com/wiki/index.php?title=How_to_Use_an_RFID_RC522_on_Raspberry_Pi
  • http://www.penguintutor.com/news/raspberrypi/rfid-rc522
  • http://raspmer.blogspot.co.za/2015/07/how-to-use-rfid-rc522-on-raspbian.html
  • https://www.google.co.za/search?q=british+flag&espv=2&biw=1366&bih=589&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjvn8Pwjb_RAhXsBcAKHcLJDLYQ_AUIBigB#imgrc=wgzzMMo9KwrRCM%3A
  • https://www.google.co.za/search?q=german+flag&espv=2&biw=1366&bih=589&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjO7eDkjb_RAhVjJcAKHQyWC_EQ_AUIBigB#imgrc=Q1JKf_cJParCjM%3A
  • https://e2e.ti.com/support/embedded/tirtos/f/355/t/436644
  • http://luxemodo.com/10-strange-jobs-will-believe-people-used/

 

 

 

 

This Tutorial has proudly been brought to you by: Pishop.co.za