AZ-Delivery RFID RC522 Manual

Reader with rfid chip and rfid card
Hide thumbs Also See for RFID RC522:

Advertisement

Welcome!
Thank you for purchasing our AZ-Delivery RFID RC522 Reader with RFID
Chip and RFID Card. On the following pages, we will introduce you to how
to use and set-up this handy device.
Have fun!

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the RFID RC522 and is the answer not in the manual?

Questions and answers

Summary of Contents for AZ-Delivery RFID RC522

  • Page 1 Welcome! Thank you for purchasing our AZ-Delivery RFID RC522 Reader with RFID Chip and RFID Card. On the following pages, we will introduce you to how to use and set-up this handy device. Have fun!
  • Page 2: Operating Conditions

    Areas of application Education and teaching: Use in schools, universities and training institutions to teach the basics of electronics, programming and embedded systems. Research and development: Use in research and development projects to create prototypes and experiments in the fields of electronics and computer science. Prototype development: Use in the development and testing of new electronic circuits and devices.
  • Page 3 consult a doctor. Caution: Keep the product out of the reach of children and pets to avoid accidental contact and swallowing of small parts. Note: Store the product in a safe, closed container when not in use. Attention: Avoid contact of the product with food and drinks.
  • Page 4 RFID means radio-frequency identification. RFID uses electromagnetic fields to transfer data over short distances. RFID tags are used in many industries, for example, an RFID tag attached to an automobile during production can be used to track its progress through the assembly line, RFID-tagged pharmaceuticals can be tracked through warehouses, implanting RFID microchips in livestock and pets allows positive identification of animals, etc.
  • Page 5: Specifications

    Specifications » Chip: MFRC522 » Operating frequency: 13.56MHz » Power supply voltage: 3.3V » Current: 13 - 26mA » Read Range: Approx 30mm » Communication: SPI interface » Max Data Transfer Rate: 10Mbit/s » Dimensions: 40 x 60mm [1.6 x 2.4in] The reader is a near-field device, not an actual radio.
  • Page 6 The pinout of the reader Power supply voltage is 3.3V! Do not connect 5V to this pin, or else you could destroy the device! The reader uses SPI interface to communicate with a microcontroller. Interrupt IRQ pin is on HIGH state all the time, and when the interrupt event happens, it changes its state to LOW for a brief period of time.
  • Page 7 How to set-up Arduino IDE If you did not install Arduino IDE already, this is how to do it. Go to the link: https://www.arduino.cc/en/Main/Software and download installation file for your operating system platform. For Windows, double click on downloaded ".exe" file and follow instructions in installation window.
  • Page 8 For Linux, download file with extension ".tar.xz", which then you need to extract. When you extract it, go to the extracted directory, and open terminal in that directory. You need to run two “.sh” scripts, first called "arduino-linux setup.sh", and second called "install.sh". To run first script in terminal, run the following command: sh arduino-linux-setup.sh user_name user_name - is the name of super user in the Linux operating system.
  • Page 9 Next thing is to check if your PC can detect the ATmega328p board. Open freshly installed Arduino IDE, and go to: Tools > Board > {your board name here} {your board name here} should be the Arduino/Genuino Uno, as you can see on the image below:...
  • Page 10 After this you need to select the port on which the microcontroller board is connected. Go to: Tools > Port > {port name goes here} If you connected the ATmega328p board on the usb port, there should be several port names. Because we are using Arduino IDE on Windows, port names are like on image below: For Linux users, port name is “/dev/ttyUSBx”...
  • Page 11 Connecting the reader with ATmega328p Connect the reader with the ATmega328p as shown on the connection diagram below: Module pin > ATmega328p pin 3.3V > 3.3V ! Red wire > D9 Purple wire > GND Black wire IRQ > D2 Ochre wire MISO >...
  • Page 12 The library for Arduino IDE To use the module with ATmega328p it is recommended to download and install library for it. Open Arduino IDE and go to: Tools > Manage Libraries. New window will open, type “RFID 522” in the search box, and install library called “MFRC522”...
  • Page 13 Sketch example #include <SPI.h> #include <MFRC522.h> #define RST_PIN 9 // Configurable, see typical pin layout above #define SS_PIN 10 Configurable, see typical pin layout above #define IRQ_PIN 2 // Configurable, depends on hardware MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance MFRC522::MIFARE_Key key;...
  • Page 14 void loop() { (bNewInt) { // New read interrupt Serial.print(F("Interrupt. ")); mfrc522.PICC_ReadCardSerial(); // Read the tag data // Show some details of the PICC Serial.print(F("Card UID:")); dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size); Serial.println(); clearInt(mfrc522); mfrc522.PICC_HaltA(); bNewInt = false; activateRec(mfrc522); delay(100); // MFRC522 interrupt serving routine void readCard() { bNewInt = true;...
  • Page 15 When you upload the sketch to the ATmega328p, open Serial Monitor, (Tools > Serial Monitor). The output should look like the output on the image below: When you bring RFID Card or Chip near the reader, an interrupt happens, and the UID number of the Card/Chip is sent to the Serial Monitor. At the beginning of the sketch two libraries are imported, SPI for SPI interface and MFRC522 for RFID reader.
  • Page 16 the specific card. Then the bNewInt variable is created. When interrupt happens, the state of bNewInt variable changes to true, which indicates that interrupt happened. Then in the code we check for the state of bNewInt variable and print the corresponding output to the Serial Monitor (more about this later in the text).
  • Page 17 represents the interrupt event itself. For the purpose of this example we are using FALLING edge of the digital signal, that comes on the IRQ_PIN, as interrupt event. The value of this argument can also be RISING or BOTH, but we are not using that in our example.
  • Page 18 Connecting the reader with Raspberry Pi Connect the reader with Raspberry Pi as shown on the connection diagram below: Module pin > Raspberry Pi pin SDA (SS) > GPIO8 [pin 24] Gray wire > GPIO11 [pin 23] Blue wire MOSI >...
  • Page 19 The library for Python In order to use the reader with the Raspberry Pi it is recommended to download a library for Python. The library we are going to use is called “pi rc522”. To install this library, open a terminal and run the following commands, one by one: sudo apt-get update sudo apt-get upgrade...
  • Page 20: Python Script

    Python script from pirc522 import RFID from time import sleep reader RFID() keys list() key_read True print('[press ctrl+c to end the script]') try: while True: reader.wait_for_tag() error, tag_type reader.request() if not error: error, uid reader.anticoll() if not error: len(keys) > keys: uid: key_read...
  • Page 21 Save the script by the name "rfid.py" into default script directory. To run the script open terminal in the directory where you saved the script and run the following command: python3 rfid.py The output should look like the output on the image below: To end the script press "CTRL + C".
  • Page 22 At the beginning of the script we import two libraries, one called pirc522 that we just installed and the other is for time. Then we create reader object, using the following line of the code: reader = RFID() You can connect the SDA pin of the reader to CE1 (GPIO7 [pin 26]) instead of CE0 (GPIO8 [pin 24]).
  • Page 23 Then we create try-except-finally block. We do this in order to detect keyboard interrupt. Keyboard interrupt happens when we press CTRL + C on the keyboard. finally part of try-except-finally block is used to clean the GPIO pins of any used interfaces or defined pin modes after keyboard interrupt.
  • Page 24 Then, again we check if there is an error while reading UID. If there are no errors we proceed with checking if UID number is already in the keys list. If the UID number is not in the keys list, we add a new number, and print message “New tag detected! UID: number”, where number is UID number of the tag.
  • Page 25 If you are looking for the high quality microelectronics and accessories, AZ-Delivery Vertriebs GmbH is the right company to get them from. You will be provided with numerous application examples, full installation guides, eBooks, libraries and assistance from our technical experts.

Table of Contents