RFID entry system

From i3Detroit
Jump to: navigation, search


This system will replace the current one, it is projected to be network connected and control all entry and exit through the front door. It is based around an arduino mega 2560, Open Access Control 3.0, and a beagle bone, allowing the logging of everything to do with the door. The network connectivity means easy integration with proposed EMS/Fire emergency buttons. This also means integration with the CRM for automatic control of access, easy new user addition, reporting of failed entry attempts, reporting of power outages, etc...

System design evolution

  • Originally this was going to use the SCC1080 displays inside and outside, inside for log file viewing and outside for normal status display. Optimistically this was going to include the keypad on the display as an input supplemental to the wiegand reader's keypad. This revision was going to be on the network with the ethernet shield. This revision also talked about having a pocket level reader for easy entry.
  • There was then talk about getting a supplemental keypad that was not the SCC1080s as getting the input to work as we wanted proved a bit more difficult than expected. The idea for they pay phone keypad originated here, but was going to be polled by the mega with discreet IO.
  • When it was determined the SCC1080 displays were a bit large (and not technically rated for michigan winters) we'd switch to an hd44780 outside and an SCC1080 inside (since I can read button inputs in single unit mode with a bit of a hack). The hd44780 was to be driven out a '595 to reduce pin count.
  • Ethernet shield scrapped for serial to beaglebone to put it on the network. The idea to have the bone do all the logic and the mega be essentially an IO slave started here. Having the mega hash the PINs started here, originally wanted SHA1 or SHA256, couldn't make cryptosuite work, went with md5.
  • The idea to have a dot matrix printer as a physical log file has been there for most of the time, but it helped the interior SCC1080 get dropped as being redundant.
  • The keypad polling was optimized with a 4017 and a little bit of voodoo. cutting the pin count down to 2 for the keypad and 2 for the 44780 (as resets were handled with diode/capacitor/resistor startup reset circuits). This was quickly scrapped for 3/3 as the reset lines are needed for stability/repeatability.
  • The mega was decided to be a smarter IO slave that does acceptance of cards and PINs.
  • The mega was decided to store a version of the CRM user file in the onboard EEPROM.
  • Due to LCDs like the 44780 being finicky with contrast and temperature the contrast line was run to a pwm pin and through a 100uF cap to filter it to ~DC. This means the LCD shows nothing if not hooked up to a dunctioning controller as it's not getting a contrast voltage. The contrast is set to a constant value, will update later with a manual set function and a set by temperature function.
  • The polled keypad and bit banged display were dropped for an I2C controlled one based on an attiny2313, which worked with test code but was really slow at reading key presses. That was fixed by cutting a delay(30) to delay(1) in the software debounce code in the attiny2313.
  • The system ostensibly worked at this point, but it was horribly unstable, adding capacitance to the power lines in the lcd/keypad controller seems to have fixed most of that.
  • The temperature sensor was added and a command to poll it was added, work well.
  • Somewhere in the last few updates the printer was tried with the soldered together circuit and it was found to not function, several defines and some solder patching later it worked again.
  • tried and failed to make this a multi-file project, need to break some of these things up, holy shit.
  • A manual contrast set function was added, will calculate how to set based on temp later, for now that could be implemented in the bone by just polling for temp and setting contrast.
  • Battery voltage checking was updated to shorten the check time from once an hour to once every five minutes if the voltage drops below the threshold, and sets it back once it goes back above the threshold.
  • Hip reader revised to be a parallax blue one encased in a brick of epoxy, the problem is it outputs in hex digits... as characters... over serial... at 2400bps... well, at least we can probably do this over software serial andhave to convert the array of characters intercepted to a long. Also need to figure out what one of the bits in the parallax stream means, mine outputs an extra bit making the second character an 8, I think it's a mode bit, or a type bit, or something.
  • At this point the only thing that uses delays is the reader beep commands (which I parametricised and added an arbitrary repeat function for) and I use that delay to display error messages for a given duration, although that could be changed to even MORE millis() calls



The original code is here: http://www.accxproducts.com/wiki/index.php?title=Open_Access_3.0

Parallel port documentation: http://nemesis.lonestar.org/reference/computers/interfaces/centronics.html

Whole git repository [[1]]

Library I borrowed from http://awtfy.com/ and modified slightly to parse comands [[2]]

Current best working code [[3]]

Test of the keypad matrix scanner based on a 4017 [[4]]

Sketch to read from the RTC, commented out lines to set RTC [[5]]

Sketch to test RFID reader, outputs on serial [[6]]

Working printer test, takes serial in and outputs to the parallel port [[7]]

Old test of the 595 based 44780 [[8]]


OpenAccess Control v3.0 (6 relays populated)

Arduino Mega 2560

HD44780 on an attiny 2313 i2c controller

pay phone keypad on an attiny 2313 i2c controller

ID-12 RFID reader in Wiegand mode

Parallax 2400bps uart RFID reader encased in epoxy

Dot matrix printer (Panasonic KX-P1124)

Arduino Mega pin usage
Arduino Mega Open Access Shield
0 Reset Reset button
1 3.3v
2 5v 5v
3 Gnd Gnd
4 Gnd Gnd
5 Vin
6 Analog 0 Alarm 0
7 Analog 1 Alarm 1
8 Analog 2 Alarm 2
9 Analog 3 Alarm 3
10 Analog 4 Alarm 4
11 Analog 5 Alarm 5
12 Analog 6 Alarm 6
13 Analog 7 Alarm 7
14 Analog 8 Alarm 8
15 Analog 9 Alarm 9
16 Analog 10 Alarm 10
17 Analog 11 Alarm 11
18 Analog 12 Alarm 12
19 Analog 13 Alarm 13
20 Analog 14 Alarm 14
21 Analog 15 Battery Voltage monitor (has a 4:1 voltage divider)
22 Digital 0/PWM/RX0/USB serial
23 Digital 1/PWM/TX0/USB serial
24 Digital 2/PWM/interrupt 0 Reader 2, D0
25 Digital 3/PWM/interrupt 1 Reader 2, D1
26 Digital 4/PWM Reader 2, LED1
27 Digital 5/PWM Reader 2, LED2
28 Digital 6/PWM Reader 2, Buzzer
29 Digital 7/PWM Reader 1, Buzzer
30 Digital 8/PWM Reader 1, LED2
31 Digital 9/PWM Contrast (PWM)
32 Digital 10/PWM
33 Digital 11/PWM
34 Digital 12/PWM
35 Digital 13/PWM/LED
36 Gnd
37 Aref
38 Digital 14/TX3 RS485 TX
39 Digital 15/RX3 RS485 RX
40 Digital 16/TX2 RS485 transmit/receive
41 Digital 17/RX2 Reader 1, LED1
42 Digital 18/TX1/interrupt 5 Reader 1, D1
43 Digital 19/RX1/interrupt 4 Reader 1, D0
44 Digital 20/SDA/interrupt 3 SDA (RTC/AT24C1024)
45 Digital 21/SCL/interrupt 2 SCL (RTC/AT24C1024)
46 5v 5v
47 5v 5v
48 Digital 22
49 Digital 23
50 Digital 24
51 Digital 25
52 Digital 26
53 Digital 27
54 Digital 28
55 Digital 29
56 Digital 30 One wire thermistor
57 Digital 31 Relay 0 through ULN2803
58 Digital 32 Relay 1 through ULN2803
59 Digital 33 Relay 2 through ULN2803
60 Digital 34 Relay 3 through ULN2803
61 Digital 35 Relay 4 through ULN2803
62 Digital 36 Relay 5 through ULN2803
63 Digital 37 Relay 6 through ULN2803 (unpopulated relay)
64 Digital 38 Relay 7 through ULN2803 (unpopulated relay)
65 Digital 39 /Strobe
66 Digital 40 D1
67 Digital 41 D0
68 Digital 42 D3
69 Digital 43 D2
70 Digital 44/PWM D5
71 Digital 45/PWM D4
72 Digital 46/PWM D7
73 Digital 47 D6
74 Digital 48 Exit button (to ground)
75 Digital 49 /Busy
76 Digital 50/MISO
77 Digital 51/MOSI
78 Digital 52/SCK
79 Digital 53/SS
80 Gnd Gnd Gnd
81 Gnd Gnd Gnd

Outdoors cable pin usage
Pin Signal Direction Pin Signal Direction
1 +12v n/a 2 +12v n/a
3 i2c data bi 4 i2c clock bi
5 Signal Direction 6 Signal Direction
7 thermistor bi 8 Signal Direction
9 Signal Direction 10 Signal Direction
11 contrast PWM DC 12 Signal Direction
13 wiegand0 input 14 wiegand1 input
15 ground n/a 16 ground n/a

Design Specs


Open Access Control with Ethernet shield and mods
  • Inside
    • Arduino mega 2560
    • Open Access Control 3.0
    • BeagleBone
    • SCC 1080
    • Big blinking light
    • Buzzer/siren
    • Exit button
    • Power supply (signal about whether or not it's on)
    • Door magnet (actuator and feedback pin)
    • Dot matrix printer (Panasonic KX-P1124)
SCC 1080 display
  • Outside
    • Backlit 2x16 HD4470 parallel character LCD
    • Pay phone keypad
    • RFID reader at pocket height
    • RFID reader at keypad height
Whole system


  • Logging
    • Where to log
      • Serial to log file on beaglebone (periodically uploaded to server [daily?])
      • Dot matrix printer near door
    • What to log
      • Startup
      • Successful/failed entry
      • Successful/failed new user
      • Successful/failed user database (EEPROM) push/pull
      • Beaglebone space almost full (bone responsibility, push to printer, if desired)
      • Log file deleted (bone responsibility, push to printer, if desired)
      • Button pressed to exit the building
      • Goes into/out of doorbell mode
      • Goes into/out of door hold mode
      • Periodic battery voltage measurements
      • Voltage drops below threshold
    • How to log
      • log file named with current rtc date at the beginning of the day
      • Append all day long
      • Push at the end of the day
      • Delete x-days old files
      • Start new file with new date (automatically)
      • Same subroutine logs to lpt port
  • RTC
    • Used for logging and daily tasks
    • Set by NTP (bone responsibility)
  • Doorbell function
    • Sets off buzzer when button (#) is pressed
    • Opens door when in event mode (doorbell mode)
  • User database
    • EEPROM
    • Pushed from beaglebone CRM
    • Keep at least all the user databases from the last 24 hours on the beagle bone
    • Fields in CSV
      • Name
      • Privilege byte (determines certain powers, like event mode)
      • plaintext card id
      • PIN salted with card id MD5 hashed
  • Card swiped procedure
    • Swipe card
    • Print greeting; "welcome"
    • Wait for timeout (1 minute)
    • Prompt for PIN
    • Asterisks display on screen
    • <*> backspaces
    • End with <#>
    • If invalid prompt again
    • If 3 failed entries beaglebone is to call/text/e-mail owner of card and/or administrator
  • New user add procedure
    • Card in existing card from someone who can add new users
    • Press specific button (5) while the door is unlocked to add new user
    • Swipe new card
    • Wait for timeout (1 minute)
      • If timeout do nothing
    • Enter new PIN
    • Press <#>, open door
    • Card added with priv byte 1 in an availible spot
        • Push user (logged normally) to beaglebone to push back to CRM
  • Battery voltage
    • Check every couple of minutes minimum
    • If below threshold turn on light, alarm, something
    • Log voltage (even if normal) every day
  • Power supply
    • If power goes out trigger alarm, maybe alert server
  • Exit button
    • Press it to exit building, unlocks door for 5(?) seconds
  • Door magnet
    • Monitor if magnetic field is down when it shouldn't be
    • If it is, alarm server, audible/visual alarm, send e-mail, etc...
  • Failure modes
    • Server hosed, able to dump user database and log files from beaglebone
    • New reader, blank eeprom, populate from beaglebone
    • No server present, keep logging until beaglebone size reached, then delete oldest logs
    • No eeprom present, only hardcoded hashes in the code work


Finalize design document


  • write code for NTP RTC setting
  • write code for user database upload
  • write code for user database download
  • write code for logging things
  • write code for sending out e-mails/phonecalls based on errors
  • integrate thermistor code
  • place contrast value in command byte area
  • place time zone in command byte area
  • allow users to add their own pin
  • store card id plain


  • Work out light and sound outputs
  • Work out power supply status and door magnet status inputs
  • Populate remaining relays
  • Populate second Open Access board
  • Do something electrically sensible with the keypad and LCD pins, so they can be (opto?)isolated as they come inside.


  • Design/select interior mounting box
  • Construct exterior mounting box


  • Figure out a mapping between the printed 65535:65535 format used by the existing keypad (and the CRM) and individual bits in the Wiegand message.