If it's Friday, then it's usually time for Friday Hacks at resin.io! This means working on a project of our own interests - as long as it is connected to resin.io in some way. We have many dozens of hacking and maker ideas floating around in our team, there's always more to do than how many Fridays there are.
My most recent Friday Hacks project was adding an RFID lock system to our local office. It took a couple of Fridays to get it working and here are all the details, in case you want to set up your own system one day!
This project took longer than I expected, partly because I was trying a few different ways that would allow us to unlock the office door. One such attempt was using a Lockitron, but that would have meant that we couldn't unlock the door with a key anymore and that was just not going to work.
One enhancement that I wanted to add was support for encrypted key cards, such as Oyster, Apple/Android Pay and contact less bank cards. This required removing some checks from the Adafruit PN532 library. My version ignores invalid check sums instead of crashing with an error (which happens in the original library when reading these cards).
I plan to add a Flask server to the script, which can be exposed over a public device URL and would provide an API endpoint to open the door remotely. This can be combined with our Hubot such that the door could be opened by asking it on our company chat: hubot open the office (possibly adding some magic keywords for security, such as please - or something more secret)
I might also add a front-end that shows who is in the office, based on their card login - although this may be slightly Orwellian.
I chose to set up a Python script to implement the door lock logic. The source code is available on GitHub. The script has a straightforward (somewhat simplified) cycle of:
Setting up the external hardware through the GPIO
Loading the list of accepted card/tag IDs
Checking if there's a card to be read
If there is a card, check it against the list of accepted ones
If authorized, blink the LEDs for feedback and open the door
The script is deployed through resin.io, which allows some practical benefits. First, we can observe the logs from the lock script through an online dashboard and see entry attempts including tag IDs. This is handy when adding a new ID to the system as no additional equipment is needed: just scan and check the logs. Second, new card/tag IDs are authorized through adding environment variables in the dashboard (setting a series of variables such as CARD_1
, CARD_2
, ... containing the IDs), so no additional programming is required!
There are additional settings, such as how long to keep the door open, or how fast to blink the LEDs.
We can use a number of different RFID/NFC tags and cards as entry tokens, including (but not limited to) NFC Type 1 to 4, Oyster cards, contactless debit cards and Apple/Android Pay.
For the action of actually opening the door, I've modified the office buzzer system to allow operation via a relay, whilst the usual button press works too.
The NFC reader, LED ring and the relay are all controlled by the Raspberry Pi through the GPIO pins.
The whole setup is placed behind one of our front windows and a poster, so it's not visible from the outside, but tags and cards can still be brought within reach of the reader.
This is very impressive idea I like this project and I think you can click on office removals scunthorpe to learn the details that can help you in this field.
This is very impressive idea I like this project and I think you can click on office removals scunthorpe to learn the details that can help you in this field.