Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Latest commit

 

History

History
91 lines (67 loc) · 5.21 KB

README.md

File metadata and controls

91 lines (67 loc) · 5.21 KB

Fablab Doorman

An Arduino Yun based RFID access control system

This project was designed with the intent to allow the access to the Fablab/Makerspace to the registered members. Every member is provided with an RFID tag which is stored in a users database. Using a database permits to dinamically manage the users subscription and associate different level of permission and time access profiles.

Components:

Logical Structure

The Arduino YUN was chosen for its ability to combine the reliability of a microcontroller with the potential of a Linux system.
The RFID reader, the electromechanical lock (or multiple ones), push buttons and other inuputs are connected to the microcontroller. Instead, on the OpenWRT there is implemented the user access logic and the database. Plus the feature to add/remove connecting remotly to the YUN.
Every time a new RFID tag is read, the microntroller ask permission to open the door to the control access logic hosted on the OpenWRT side.

The communication between the two processors is done using the Bridge protocol, that allows the microcontroller to execute the python script with the control access logic only when a new RFID card code is available.

Setup Instructions

OpenWRT setup

It's recommended to use the latest Arduino YUN OpenWRT image, available here and following the sysupgrade guide to flash it.

Prepare your SD card by creating an empty folder in the root directory named "arduino". When OpenWrt-Yun finds this folder on an attached storage device, it creates a link to the SD to the "/mnt/sd" path.

The Arduino YUN doesn't come with a database management system pre-installed so we need to install it including the dependencies to use with a python script. SQlite3 was the coiche for its lightweight footprint and for being designed to being embedded into programs.

Run this command inside the YUN OpenWRT shell to install all the dependencies:

opkg install libsqlite3 sqlite3-cli python-sqlite3
Upload all files and sketch

As it's structured, this project can be uploaded completely by using only the Upload button on the Arduino IDE, you just have to worry about selecting the network port (instead of the serial port) as upload port in the "Tools > Port" menu. The sketch would be normally compiled and flahsed on the microcontroller and the python script contained inside the "www" sketch folder will be copied at the following path on the Yun:

/mnt/sd/arduino/www/FablabDoorman
Database Structure

The database is called logger.db and is structured with two tables called allowedusers and inothedoor.
The allowedusers is the table containing the all the users who can open the door. Table structure:

  • id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  • username TEXT NOT NULL
  • cardcode TEXT NOT NULL (must be expressed in hex format without any separator and no prefix)
  • timeAccessProfile TEXT NOT NULL (can be defined inside the python script)

The intothedoor is a table used to log all the access, structured with the following scheme:

  • id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  • datetime TEXT NOT NULL
  • cardcode TEXT NOT NULL

For simplicty database structure is automatically created after the first execution. You can connect to your YUN via SSH and manually run the python script to setup the database.

Adding a New User

Adding a new user can be made only manually by inserting a new row to the allowedusers table. Instructions:

  • connect to your YUN via SSH
  • move to the FablabDoorman directory: $ cd /mnt/sd/arduino/www/FablamDoorman
  • open the database: sqlite3 logger.db
    this will open the database in the interactive mode and now you can issue the sqlite3 commands to operate on the tables
  • Insert new user:
    INSERT INTO allowedusers (username, cardcode, timeAccessProfile)] VALUES ("Mario Rossi", "A1B2C3D4", "ordinario");
  • modify a user, such as if you want to change the cardcode or the time profile:
    UPDATE allowedusers SET cardcode="DEADBEEF" WHERE username="Mario Rossi";
  • Delete a User:
    DELETE FROM allowedusers WHERE username="Mario Rossi";
Checking the Log file

Checking the log file is fairly easy if you are connected via SSH to the YUN. Simply open the database as described above and submit your query. A couple of examples:

  • View the entire log: SELECT * from intothedoor;
  • use the WHERE clause to filter your query, example:
    SELECT * from intothedoor WHERE username="Mario Rossi";

TODO

We experienced that this system isn't enough reliable to work 24-7, it requieres to be rebooted occasionally. You can activate the watchdog that will reboot the YUN if the Linux kernel get stuck. $ watchdog /dev/watchdog to activate with defaults parameters
Otherwise you can configure a cron job to restart the YUN periodically.