Radio Frequency Identification (RFID) is a technology that uses radio waves to passively identify a tagged object. It is used in several commercial and industrial applications, from tracking items along a supply chain to keeping track of items checked out of a library.
In this tutorial, you’ll learn how to use raspberry pi 4 and RFID readers to obtain card ID information.
First, enable the SPI in the Raspbian system by clicking on the menu, then preferences, then Raspberry pi configuration, and from the interfaces, enable the button next to the SPI field, as in the image below:
Now we must install some libraries so that we can use the RFID with the Raspberry Pi 4 board without problems. Enter these commands in order in the terminal:
• sudo apt-get update
• sudo apt-get upgrade
• sudo apt-get install python3-dev python3-pip
• sudo pip3 install spidev
• sudo pip3 install mfrc522
Connect the wires between the MFRC522 RFID module and the Raspberry Pi 4 board, as shown in the image below.
Connections from the Raspberry pi 4 to the breadboard :
• Raspberry pi 4 GPIO GND pin → Breadboard ground line
• Raspberry pi 4 GPIO 3.3V pin → Breadboard VCC line
Connections from the RFID module :
• RFID 3.3V pin →Breadboard VCC line
• RFID RST pin →Raspberry pi 4 GPIO 25 pin
• RFID GND pin →Breadboard ground line
• RFID IRQ pin →unconnected
• RFID MISO pin →Raspberry pi 4 GPIO 9 pin
• RFID MOSI pin →Raspberry pi 4 GPIO 10 pin
• RFID SCK pin →Raspberry pi 4 GPIO 11 pin
• RFID SDA pin → Raspberry pi 4 GPIO 8 pin
Now on your Raspberry Pi, click on the menu, then choose programming, then open the Thonny ide program.
Now copy that code into it, The function of this code is to print the card ID on a window when you bring the card near the RFID sensor.
Now run the code, you will find that the Raspberry Pi 4 board print the card ID on a window when you bring the card near the RFID sensor.