This project seeks to accurately classify NFC-Cards based on their visual features to complement and fortify NFC-based access control systems. The solution involves utilised supervised machine learning classifiation techniques and algorithms along with an embedded alert system . The significance of this approach lies in its automated capability to restrict access to potentially cloned cards without requiring users to provide secondary identification (e.g. biometrics) whilst also providing cloning event alerts. The project’s scope operates under the assumption that stakeholder access systems have distinguishable cards or tags that are used by all users or employees.
To successfully run this project the following tools and libraries are required:
- Raspberry Pi (confirmed to work on both Model 4b & 5)
- NFC Module MFRC522
- Mifare Classic 1K NFC cards
- Green LED
- Red LED
- Raspberry Pi Camera Module 2
- 11 Wires (Female to Female)
To interact with the MFRC522 NFC Module, the MFRC522 python library is required. For compatibility with Raspberry Pi 5, this forked repo has been linked as a git sub module.
-
Insert the micro SD card into an external laptop with Raspberry Pi OS Imager
-
Launch the software and select the device you have access to, the recommended OS and the external location to write the image to.
Warning
This will override everything on the card
- Once Write is complete, remove the SD Card and insert into the Raspberry Pi. Connect power and monitor cables. Allow OS to boot.
-
Connect Raspberry Pi to a network
-
Click on the icon in the top right of the navbar
-
Sign in & follow the prompts to set up the device
-
On another device you will now be able to log into Raspberry Pi Connect and connect to the device via remote shell or Screen sharing.
-
Connect camera module to Raspberry Pi.
-
Ensure OS Software is up to date. (No other software is required)
-
Connect Raspberry Pi to power.
-
Open a terminal and enter in
rpicam-helloand a camera preview should be shown.
See additional commands and flags.
- Connect pins as shown below:
| Raspberry Pi 5 | MFRC522 Module | Red LED | Green LED |
|---|---|---|---|
| 1 | 3.3V | - | - |
| 6 | GND | - | - |
| 9 | - | Ground | - |
| 11 | - | Positive | - |
| 12 | - | - | Positive |
| 14 | - | - | Ground |
| 19 | MOSI | - | - |
| 21 | MISO | - | - |
| 22 | RST | - | - |
| 23 | SCK | - | - |
| 24 | SDA | - | - |
- Plug in Raspberry Pi.
- Open the terminal and enter in
sudo raspi-config. - Use the arrow keys to select
3 Interface Options. Press Enter. - Use the arrow keys to select
SPI. Press enter. - Select
Yesin the popup. Press enter. - Reboot the system before proceeding by running
sudo reboot. - Once rebooted, confirm that SPI has been enabled by running
lsmod │ grep spi. If spi_bcm2835 is shown in the list, proceed. Otherwise consult troubleshooting docs.
- Install required python packages by running
sudo apt install python3-dev python3-pip python3-venv - Clone the repository by entering
git clone https://github.com/daniegee/clone-guard.git. - Change directory
cd clone-guard. - Create a Virtual Python Environment by running
python3 -m venv env. - Start the virtual environment by running
source env/bin/activate. - Give the setup script executable permissions
chmod +x setup.sh - Initialise the git submodule & install required packages by running the custom script
./setup.sh. - Create and populate an
.envfile based off the variables defined in.env.template - Run the main script
python main.py - Place the card near the reader, and it should display the card UID in the terminal.
Conditions: project repo has been initialised and run at least once
- Open terminal and change into the repo's root directory
cd clone-guard-part-b - Start the virtual environment by running
source env/bin/activate. - Make script callable by running
chmod +x ./setup.sh - Initialise the git submodule & install required packages by running the custom script
./setup.sh. - Run the main script
python main.py - Place the card near the reader, and it should display the card UID in the terminal.
├── 3D models # 3D model blueprint used in the project
│ └── Case.gcode
│
├── classes # collection of classes used in the project
│ ├── EmailSender.py
│ ├── GradCAM.py
│ ├── LEDController.py
│ └── TFLiteImageClassifier.py
│
├── diagrams # Visualisations that show the current/updated state of the project
│ ├── CNN_model_architecture.png
│ ├── MFRC522_configuration_visual.png
│ └── pin_configuration_table.png
│
├── images # Images used to train, validate & test the model
│ ├── controlled_background # image dataset with controlled white background
│ │ └── ...
│ └── noise_background # image dataset with noisy background
│ └── ...
│
├── MFRC55-python
│ └── ... # Git SubModule
│
├── notebooks
│ ├── CNN.ipynb # Juypter notebook implementing a Convolution Neural Network (CNN) used in the project
│ ├── KNN.ipynb # Juypter notebook implementing a K-Nearest Neighbour (KNN) used in the project
│ └── SVM.ipynb # Juypter notebook implementing a Support Vector Machine (SVM) used in the project
│
├── scripts
│ └── cameraphotos.py # script used to automate image dataset collection
│
├── .gitignore
│
├── .gitmodules
│
├── main.py
│
├── README.md
│
├── requirements.txt # list of python dependencies
│
└── setup.sh # Script to install dependenciesDavid Prego
Daniella Gullotta


