This is a program that uses RFID cards to allow access to machines at the shop. We are Raspberry Pi zero and Arduino micro pro to control separate parts.
The Pi controls reading the RFID, connection with the cloud mfrc522, and basic logic.
The Arduino drives the screen, controls the relays, connects to switches and e-stops, and adds the ability to add extra functionality due to its analog pins.
1- Raspberry Pi 3 and above. Make sure it includes on-board Wi-Fi. We used the raspberry pi zero, for it has smaller form factor. 2- SPI RFID ID reader. We used RC522. 3- Breadboard 4- Jumper wires 5- Arduino board. We used Arduino micro pro, for it has smaller form factor. 6- Screen. We used SSD1306, for it is cheap and small. 7- On/off switch 8- E-Stop 9- 8 GB or above SD-card for storing the OS for the raspberry Pi
-
Insert the SD-card into your computer and download and run Raspberry Pi OS manager
-
Run the OS image manager
-
OS choose Raspberry PI OS (other) then choose Raspberry Pi Lite (32b-bit)
-
In the storage option, choose the SD-card you inserted. Make sure that it's empty or everything will be deleted.
Troubleshooting: If you're running windows machine and you have controlled access feature enabled, make sure to allow the program to write on the external storage. Windows thinks it is unauthorized access and stops it.
-
Click write to write the Raspberry Pi image into the sd card.
-
When the program finishes, transfer sd-card to your raspberry pi.
-
connect pi to an external display and keyboard, and power the it.
-
Log in to the Pi with default credentials. username: pi password: raspberry 7-connect the Pi to the internet, if you're using Carleton network, you can find more information here.
-
Install git using the following command:
sudo apt install git -y
-
Run the following command to import the project
-
Install NodeJS for your board, you can know your system architecture by running
uname -m
. For the raspberry Pi Zero, we found this tutorial to be helpful. -
change directory to the project folder using
cd ./2021-027-Access-Control
-
run
npm i
to install the dependencies. -
Create a google service account and enable the google sheets API in it.
-
Download the Credentials in .Json file and keep them in a safe place. Warning: Don't upload them to GitHub!
-
Create a google sheet and give the service account you made access to it.
-
Create a
config.json
file with the following attributes"spreadSheetID" : the spreadsheet ID which comes after https://docs.google.com/spreadsheets/ in your address bar. "device": the name of the device the pi you're using is going to connect to, it should be one of the cells in the first row of your google sheet. "KeyFile" : the path to the Credentials file, we suggest it to be /boot/Credentials.Json because you can easily transfer the Credentials to the boot directory from your computer. "sheetName" : the name of the subsheet if you are using the default sheet name should be "Sheet1"
An example would be:
{ "spreadSheetID" : "1k3eZkkqm1bWA3lk8gUgfoR6Xpb2vVaX4iaqnizi5iDc", "device": "CCIS-LAT-001", "KeyFile" : "/boot/Credentials.json", "sheetName" : "Authorizations" }
-
Move both the
config.json
file and theCredentials.Json
files to your boot directory.
- Make sure you have the Arduino enrironment setup from here
- Open the ArduinoProgram/hardwareController folder from this repo.
- open
hardwareController.ino
using the Arduino IDE, connect the arduino to your computer, from the tools drop down menu, select the port and board type and upload the code to the arduino.
mfrc522 | Raspberry Pi Pin |
---|---|
vcc | 1 |
RST | 22 |
GND | 6 |
MISO | 21 |
MOSI | 19 |
SCK | 23 |
SDA | 24 |
IRQ | - |
SSD1306 | Arduino Pin |
---|---|
VCC | VCC |
GND | GND |
SCL | 3 |
SDA | 4 |
Raspberry Pi Pin | Arduino Pin |
---|---|
8 | RX |
10 | TX |
device | Arduino Pin |
---|---|
E-Stop | 5 (See diagram) |
Switch | 4 (See diagram) |
We edited the RFID read code from this repo, so thanks to devrim-oguz for his contribution.