This project is intended to replace the code that was originally running on the RFID door control system for Quelab.
The program just runs in a loop doing the following:
- Listen for input from the USB serial port connected to a PC
- Read events from RFID reader
- Process sensor Input from Door Lock, Door Open
- Handle periodic Timer events to either relock the door, or send Status of Health
Previously there was hardware connected to control an Open Sign, but this will most likely not be used in the current implementation to simply wiring connections.
The most automated way to build/deploy to an arduino nano is using docker. The easiest is likely with Arduino UI.
Just connect the arduino devices USB (assuming /dev/ttyUSB0) port to your computer and issue the following commands:
docker build -t quelab-rfid-arduino .
docker run -it --rm --device=/dev/ttyUSB0 -v $(pwd):/sketch quelab-rfid-arduino uploadOther Commands available:
- bash
- build
- monitor (uses gnu screen exit with 'Ctrl-a ')
- upload
- Schlage Electronic Lock
- Arduino Nano
- RDM6300
- clock drift is pretty severe on the device I bought. I have to restart the device once a day to be able to effectively read cards again.
The data link layer uses a simplified ISO High-level Data Link Control.
| Flag | Information | FCS | Flag |
|---|---|---|---|
| 8 bits | Variable length, n * 8 bits | 16 bits | 8 bits |
| ~ | [payload] | [xmodem crc16] | ~ |
All serial communication is processed a single byte at a time. This allows the Arduino to do other processing without getting bogged down handing serial communications. It uses a pretty standard Frame start/end flag 0x7e ~. The HDLC used here is somewhat non standard because it lacks some features like address (unnecessary for peer communications) and Control.
The HDLC implementation is taken from a library found online and modified to use xmodem crc in place of the PPP CRC16. This is mostly because xmodem CRC seems to be better supported.
- HDLC library → modified HDLC library (my fork to use xmodem crc instead of PPP)
- CRC FAQ
The application layer protocol is simply JSON. JSON is probably an unexpected choice for arduino communications because it is super verbose and would be a waste of memory for complicated applications. I attempted to use Google's MessagePack initially, but couldn't find a library that played nicely with the HLDC used for communications. One advantage of JSON though is it is widely supported in all programming languages w/o add on libraries and it is human readable. In the future it may be necessary to increase the ArduinoJSON buffer if larger messages are necessary. JSON makes it easy to write a PC application that communicate with the Arduino.
{"message":"status","door_open":true,"locked":true,"lock_open":false}{"message":"rfid_card","rfid_hex":"62E3086CED08","rfid":552173}{"message": "lock_ctrl", "unlock": true}- RDMS630 library Used to communicate with the RFID reader over a bit bang serial port
- ArduinoJson Building and Parsing JSON data, could be done manually but there is no kill like overkill...
- elapsedMillis Makes access to built in timer of the Atmel chip simple.



