GPIO door lock control
- Tested on a Pi Zero W running Raspbian GNU/Linux 9
- The Pi should be powered with an adapter rated between 5.1V - 5.2V, 2.5A
- The card readers tested are of the type PN532
- The door lock is triggered by raising a single GPIO pin
- Pins are numbered using the wiringPi scheme
- The cardreader is assumed connected with I²C on interface #1 (the lowest I²C pin numbers)
- Authorized card numbers are downloaded from hackerhula
Schematics of the circuit can be found in /schematics which have been
created with gschem
.
Install dependencies
# apt install wiringpi libnfc5 libnfc-dev build-essential
Build nfcreader
$ cd nfcreader
$ make
Enable I²C interface
# echo 'dtparam=i2c_arm=on' >> /boot/config.txt
Specify where the NFC device can be found by libnfc
# echo 'device.connstring = "pn532_i2c:/dev/i2c-1"' > /etc/nfc/libnfc.conf
Copy systemd service file to system folder
# cp doord.service /etc/systemd/system
Set password to upstream card list in environment variable
# vim /etc/systemd/system/doord.service
Reload, enable and start the service
# systemctl daemon-reload && systemctl enable doord.service && systemctl start doord.service
Reboot!
Trigger door lock
$ GPIO_PIN_DOOR=0 STAY_UNLOCKED_SEC=2 open-door
Connect with SSH from the local network and use the password stored from hackerpass infrastructure/hackeriet-door-trigger
.
The shell of the entry
user is the open-door
script. Connect with caution.
$ ssh entry@10.0.20.10
NOTE Up to date information about this functionality can be found in https://github.com/hackeriet/door-remote
https://door-remote.hackeriet.no
See /test/run-test.sh to see how to use mocks in doord.py
.
The test script currently has to be run from the project root to get correct paths.
- Make sure wiring is correct. Easy to mix up CLOCK and DATA wires when connecting the I²C device.
- Measure output voltage on the 5V rail. If it's below 5 volts, the card readers may malfunction.
- Make sure the power rating of the power supply is as high as expected (see first section of this document)
- To debug the I²C interface,
i2c-tools
contains some nice utils. Specificallyi2cdetect
which dumps all addresses found on the I²C bus (i2cdetect -y 1
for bus number 1) libnfc-bin
andlibnfc-examples
contains some libnfc utilities. Specificallynfc-poll
andnfc-scan-devices
are helpful in detecting a correctly connected nfc device
# journalctl -u doord.service -f
- jonnor, Mathsterk @trygvis from #bitraf @ chat.freenode.org for wiring advice