A RFID based access control system written in Go for Raspberry Pi + MFRCC522 tag readers + MIFARE RFID tags.
Craftdoor is a software suite for an RFID-powered door access system on a federation of Raspberry Pi devices. With the exception of the "master", each Raspberry Pi is connected to an RFID reader and a door. Registered members may tap the RFID reader with their MIFARE RFID tag to open the adjacent door.
The system is administered via a WebUI interface and accompanying REST API served by the master device. Persistent state is stored in a SQLite database on the master device. See below for valid endpoints.
Instructions below for building, configuring, and launching the webserver.
Note: At time of writing, only a single "master" Raspberry Pi is supported.
To start the software suite, do the following on the master Raspberry Pi device,
- Connect RC522 to master Raspberry Pi's hardware SPI interface. Follow instructions here.
- Download
golang
from https://golang.org. Follow installation instructions here. Verify that go is installed by runninggo version
in a terminal. Expect to see >= 1.14. - Install GCC cross-compiler,
$ sudo apt install gcc-arm-linux-gnueabi libc6-armel-cross \
libc6-dev-armel-cross binutils-arm-linux-gnueabi
- Run
cmd/master/main.go
. This will launch a webserver listening on port 8080.
$ git clone https://github.com/pakohan/craftdoor.git
$ cd craftdoor/cmd/master
$ go run main.go develop.json
Note: If the RC522 RFID reader is not detected, a fake, dummy interface will be used. This dummy interface cannot interact with RFID tags.
Once main.go
is launched, the following endpoints are available via the HTTP
webserver,
POST /init
: Writes a default key to an active RFID tag. Only for testing.GET /state?id=<UUID>
: Get the state of a particular RFID tag as soon as it's put in front of the reader. You must specify which tag you want by its UUID.
For doors,
GET /doors
: list doors in databasePOST /doors
: Create a new door.PUT /doors/<id>
: Update an existing door.DELETE /doors/<id>
: Delete an existing door.
Similar to doors, one can query and manager members and roles via /members
and /roles
.
cmd/
master/
develop.db # sqlite database used during development
develop.json # JSON config used during development
main.go # main binary for this project
schema.sql # SQL for initializing develop.db
config/
config.go # JSON config file API
controller/
controller.go # HTTP request handling logic.
...
lib/
change_listener.go
db.go # initialize database schema
rc522.go # reader implementation for RC522 RFID reader.
reader.go # interfaces for an RFID reader
state.go # State of an RFID tag.
model/ # database definitions, API
model.go
...
service/ # business logic for adding/removing keys, doors, etc
vendor/ # third-party code