Note

Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook! Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts.

Why Join?

  • Expert Support: Solve post-sale issues and technical challenges with help from our community and team.

  • Learn & Share: Exchange tips and tutorials to enhance your skills.

  • Exclusive Previews: Get early access to new product announcements and sneak peeks.

  • Special Discounts: Enjoy exclusive discounts on our newest products.

  • Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.

👉 Ready to explore and create with us? Click [here] and join today!

2.2.10 MFRC522 RFID Module

Introduction

Radio Frequency Identification (RFID) refers to technologies that use wireless communication between an object (or tag) and interrogating device (or reader) to automatically track and identify such objects.

Some of the most common applications for this technology include retail supply chains, military supply chains, automated payment methods, baggage tracking and management, document tracking and pharmaceutical management, to name a few.

In this project, we will use RFID for reading and writing.

Required Components

In this project, we need the following components.

../_images/list_2.2.7.png

It’s definitely convenient to buy a whole kit, here’s the link:

Name

ITEMS IN THIS KIT

LINK

Raphael Kit

337

Raphael Kit

You can also buy them separately from the links below.

COMPONENT INTRODUCTION

PURCHASE LINK

GPIO Extension Board

BUY

Breadboard

BUY

Jumper Wires

BUY

MFRC522 Module

BUY

Schematic Diagram

../_images/image331.png

Experimental Procedures

Step 1: Build the circuit.

../_images/image232.png

Step 2: Install the Spidev and MFRC522 libraries.

Step 3: Set up SPI (refer to SPI Configuration for more details. If you have set SPI, skip this step.)

Step 4: Go to the folder of the code.

cd ~/raphael-kit/python

Step 5: After running 2.2.10_write.py. You need to write a message first, press Enter to confirm, then put the card on the MFRC522 module, wait for “Data writing is complete” to appear and take the card away, or rewrite the message to another card and exit by Ctrl+C.

sudo python3 2.2.10_write.py
../_images/write_card.png

Step 6: Now run 2.2.10_read.py to read the information of the tag or card you have written.

sudo python3 2.2.10_read.py

Code Explanation

reader = SimpleMFRC522()

Instantiate SimpleMFRC522() class.

reader.read()

This function is used to read card data. If the reading is successful, id and text will be returned.

reader.write(text)

This function is used to write information to the card, press Enter key to finish writing. text is the information to be written to the card.

Phenomenon Picture

../_images/image233.jpeg