Read RFID tags with module rc522 on a Raspberry Pi 4
Before you start you have to active the spi interface for the Raspberry Pi 4
sudo raspi-config
Enable spi interface under Interfacing options
If you want to check with an LED whether an RFID tag has been read, you must connect the following GPIO pins of the Raspberry Pi:
Pi Pin 11 to anode of LED (+ 3.3 V)
Pi Ground to cathode of LED (- GND)
RFID Reader Connection library MFRC522 Repo
Place the RFID tags on every side of the cube.
To read the RFID tags the distance between the reader and the tags should be within 2 cm.
To write the sides 1 to 6 on the RFID tags use the script write_rfid.
- Place the 1. side of the cube on the reader
- Wait until the RFID tag is written
- Lift the cube and wait 10 seconds
- Place the 2. side of the cube on the reader
- ...
To check the written ID on the RFID tags use the script test_read_rfid
Run the interface script to send the requests to the backend of our website interface. Before running you should check:
-
Is the RC522 module connected
-
Are the RFID tags for every side of the cube written form 1 to 6
-
Is the usb stick with the media files connected to the Raspberry Pi
-
Is the usb path to the media files right
def find_usb_media_path(base_path='/media/admin'):
Line 14 (Path on Raspberry Pi)
media_paths = { 0: "", 1: os.path.join(usb_media_path, "videos/Rexroth1/"), 2: os.path.join(usb_media_path, "videos/Rexroth2/"), 3: os.path.join(usb_media_path, "videos/Rexroth3/"), 4: os.path.join(usb_media_path, "videos/Rexroth4/"), 5: os.path.join(usb_media_path, "videos/Rexroth5/"), 6: os.path.join(usb_media_path, "videos/Rexroth6/"), }
Line 98 to 106 (Define Folder paths for 1 to 6 on usb stick)
Place the media files inside the folders 1 to 6 for every cube side
Backuppath locally if USB is not connted to Raspberry Pi
data_media_path = '/home/admin/Desktop/
You habe to setup the Path usb_media_path with the 6 rexroth folders by yourself
-
Run the frontend and backend with npm start and the interface.py with python interface.py over the command line
Improve the perfomance of the frptend and backend with gernating of buiild files inseid their folders
npm run build
To start the frotend automatically copy the folder cube-frontend/dist/frontend/browser
to var/www/html
The frontend can be called up in the browser under localhost
The backend and interface can be started with the start_backend.sh
and start_interface.sh
when both folders are cloned into the folder home/admin/Documents/
(Both files can be placed on the desktop of the Raspberry Pi)
Otherwise:
Start backend and fortend insede their folders with npm run start
and open localhost:4200
in your browser
The interface is started with python interface.py