Raspberry Pi C++ library for MFRC522 and other RFID RC522 based modules.
Read and write different types of Radio-Frequency IDentification (RFID) cards on your Raspberry Pi using a RC522 based reader connected via the Serial Peripheral Interface (SPI) interface.
Adapted from https://github.com/miguelbalboa/rfid Inspired by https://github.com/paguz/RPi-RFID and many of its forks
This simply uses the same methods as https://github.com/miguelbalboa/rfid but mocks all Arduino only method with the bcm2835 library for raspberry pi.
Has the same methods, signatures, functions, and limitations as https://github.com/miguelbalboa/rfid (at least it should)
(Do the following on your Raspberry Pi)
- Open https://pinout.xyz/pinout/spi in your browser as a reference.
- Connect the 3.3v pin on the MFRC522 to any 3.3v pin on the Raspberry Pi.
Connect the RST pin on the MFRC522 to any GPIO pin on the Raspberry Pi.
Connect the GND pin on the MFRC522 to any ground pin on the Raspberry Pi.
Leave the IRQ pin unconnected.
Connect the MISO pin on the MFRC522 to the MISO pin (19) on the Raspberry Pi.
Connect the MOSI pin on the MFRC522 to the MOSI pin (21) on the Raspberry Pi.
Connect the SCK pin on the MFRC522 to the SCLK pin (23) on the Raspberry Pi.
Connect the SDA pin on the MFRC522 to any GPIO pin on the Raspberry Pi.
(GPIO pins are just pins that are not ground or power)
https://www.raspberrypi-spy.co.uk/2014/08/enabling-the-spi-interface-on-the-raspberry-pi/
-
Download the latest version of the bcm2835 library on http://www.airspayce.com/mikem/bcm2835/
-
Use
cdto navigate to the folder where bcm2835-1.xx.tar.gz is downloaded -
Run the following commands to install the library
tar zxvf bcm2835-1.xx.tar.gz
cd bcm2835-1.xx
./configure
make
sudo make check
sudo make install- Download this repo by running
git clone https://github.com/CoolCyberBrain/RPi-MFRC522.git - Enter the folder by running
cd RPi-MFRC522 - Build the ReadNUID example by running the following command
g++ src/**/*.cpp src/*.cpp examples/ReadUidMultiReader/ReadUidMultiReader.cpp -I src -I src/RPi-Arduino-SPI -std=c++17 -lbcm2835- Run the example by running the following command (if you don't run in sudo the program will crash, need sudo to access the GPIO pins)
sudo ./a.out