Access Control Application for Security and Research Lab (SoC) - Adolfo Ibáñez University, Viña del Mar
This application manages the access control of the Security and Research Lab at Adolfo Ibáñez University in Viña del Mar. It displays the current students present in the lab on a screen connected to a Raspberry Pi 4, which is set up to use a TV for display. The application also generates a QR code to facilitate easy access for students to log in or out through an online form.
The system aims to streamline the lab's attendance monitoring process, ensuring that everyone who enters or leaves is registered accordingly.
- Attendance Display: Shows the list of students currently inside the lab, highlighting tutors.
- Login/Logout System: Uses an online form accessible via QR code to register entry and exit.
- Records Management: Keeps track of attendance records and allows administrators to view them securely.
-
Login/Logout Process: The login/logout form can be accessed via the displayed QR code on the lab's TV screen. Users must select their name, choose either "Entrada" (Entry) or "Salida" (Exit), and input a password to confirm their action.
-
Dashboard Display: The TV shows the list of students in the lab, dynamically updated every few seconds. Students identified as tutors are highlighted for distinction.
-
Records: Administrators can access detailed records of lab attendance, including the name, action (entry/exit), and timestamp.
- Backend: Powered by Flask, managing form submission, attendance updates, and data retrieval.
- Frontend: HTML pages serve different purposes:
index.html
: Main display page showing students present in the lab. Refreshes every 600 seconds.login.html
: Login/logout form for students to register their entry or exit.records.html
: Shows the full list of entries and exits for administrative purposes.home.html
: Acts as the homepage with navigation options for registering entry/exit and viewing records.
The project was developed in Python 3.11 and it's dependencies are listed in requirements.txt
:
Flask==2.2.5
qrcode[pil]==7.3.1
google-api-python-client==2.39.0
google-auth==2.6.6
google-auth-oauthlib==0.4.6
google-auth-httplib2==0.1.0
requests==2.32.2
werkzeug==3.0.6
schedule==1.2.2
python-dotenv==1.0.1
To install them, run:
pip install -r requirements.txt
after cloning the project.
-
Hardware Setup: Connect a TV to the Raspberry Pi using an HDMI cable.
-
Cloning the Project: Clone this repository to the Raspberry Pi:
git clone <repository-url> cd <repository-folder>
-
Environment Variables: Create a
.env
file for Google API credentials and set up the necessary environmental variables, such asCLIENT_ID
,CLIENT_SECRET
, etc. Use thexxxxxxxx-yyyyyyyyyy.json
for the appropriate service account credentials. These should be generated using Google Cloud Platform. -
Running the Application: Start the Flask server:
python ingresos.py
The app will be accessible at
http://<raspberry-pi-ip>:5001
. You can change the port modifying the value on the Python code. -
Display Configuration: Set up the Raspberry Pi to automatically open a browser in fullscreen mode to
http://localhost:5001
upon boot. This ensures the student presence screen is always visible.
For the public web section of this app, the site was deployed to PythonAnywhere since it fits the needs of this project. You can choose any host you like, but these instructions are based on this platform and no other is mantained here at the moment.
-
Create an account and create a Web App using
Flask
,Python 3.10
and change the name of the main file of the app toingresos.py
when prompted. -
Go to the Files section, and inside the
mysite/
directory upload the contents inside theWEB
folder. Be sure to mantain the order of the files, keeping the structure of thestatic/
andtemplates/
folders and it's contents. Inside the<your_username>/
folder, along withmysite/
put thexxxxxxxx-yyyyyyyyyy.json
file with the credentials for Google API. -
Open a Bash Console on PythonAnywhere, and install the requirement:
pip install gspread
Then make sure to close the console by typing
exit
. -
Go to the Web tab again, enable
Force HTTPS
under the Security section, and restart the app. -
You are now good to go! By default, your site is live at
https://<your_username>.pythonanywhere.com/
. Be sure to update the URL for the QR code generated atingresos.py
!
-
Student Entry/Exit: Students use the QR code displayed on the TV screen to access the form
login.html
. They must select their name, action (entry or exit), and provide the password to confirm their entry or exit. -
Viewing Records: Administrators can view the complete list of attendance records by entering to the spreadsheet configured.
index.html
: Displays the current students in the lab along with a QR code for easy login/logout.login.html
: Form for students to log in or out. Password-protected.records.html
: Displays all attendance records. Password-protected for admin use.home.html
: Homepage providing access to login/logout and records viewing.xxxxxxxx-yyyyyyyyyy.json
: Service account credentials for Google API access.registros.json
: Contains attendance records, including the name, action, and timestamp.requirements.txt
: Lists all necessary packages for the application.
- Google API Integration: The application uses Google APIs for secure record handling and potential data export.
- Auto Refresh: The student list on the screen refreshes every 3 seconds for real-time updates.
- Styling: Custom styles and JavaScript (such as
particles.js
) are used to provide a visually appealing interface.
- RFID Integration: Add RFID scanning for quicker entry/exit registration.
- Notification System: Send notifications to students or admins when predefined conditions are met (e.g., overcrowding).
- Sebastián Dinator - Developer and Maintainer
Feel free to contribute by forking the repository and submitting pull requests.
This project is licensed under the GNU GPLv3 License.