RFID Lock

Servo!

One of the final bits of this project is the servo. (A servo's a small motor that'll hold a given position.) In my case, I'm using a servo to actually turn the deadbolt. It's a little bit important.

I'd assumed that a servo's powered by the power and ground and that an analog voltage (0 or +5) on the signal line would move the servo. Surprisingly, that didn't work. It appears that the servo wants a PWM input to the signal line, even if it's just a 1% on, 99% off signal.

The Arduino has a Servo library that does all the hard work for me. I wrote a few more lines, and voila! Moving servo.

To polish the gizmo a little more, I added feedback to the reader. When an illegal key is detected, the reader blinks between red and green, beeping every 100 ms. A legal key turns on the green LED while the door's unlocked.

I also polished up the wiring. I'd been running the HID reader off of a wall wart, with a jack made of electrical tape. The Arduino, meanwhile, was depending on a computer for life support. I used a coin cell and LED as a continuity tester to wire the Arduino up the right way to the wall wart (we don't have a multimeter), and fixed up the connecting jack for better (if not good) reliability.

The entire gizmo runs on wall power, turns a servo, and remembers legal keys across reboots. All that's left is attaching the servo to the wall.

Squee.

EEP!

Previously on My Hobbies, I showcased how the Arduino could read from the cardreader. Since then, I added code to save and load cards from EEPROM. What's EEPROM, you ask? Good question!

EEPROM is an unpowered rewritable type of memory. When a program's running, the Arduino stores variables in RAM (Random Access Memory). This memory is durable for many read-write cycles, but zeroes out when power's lost. EEPROM (Electrically Erasable Programable Read Only Memory) is only good for about 100,000 read-write cycles, is fairly slow (3.3ms/read), and only stores bytes (8 bits), but retains data across reboots.

Quick aside: The name EEPROM contains a contradiction. How is memory read only and erasable?

The answer lies more in history than anything. Early PROM (Programmable Read Only Memory) chips were programmed permanently. Programming these chips burned out internal fuses (tiny wires), leaving a physically changed circuit.

The next iteration of the chips, EPROM (Erasable Programmable Read Only Memory; image above), allowed for reprogramming. Exposing the die of the board to a UV light would reset it to an unprogrammed state.

EEPROM is a third iteration of ROMs. The Read Only restriction is long gone, but lives on in the acronym.

Opening Doors

Second post! That's a thing, right? Good.

Last time, I got as far as reading out bits from the card. I noticed a few things about the output bits:

  • The first half of the code was always the same.
  • The code was around 35 bits long.

With enough cards, I could have reverse-engineered the card code, but Cyborg Mode is easier. A few quick searches turned up a site explaining the HID format. In essence, the card has two pieces of data stored on it: a 12 bit facility code (same of all Lafayette cards), and a 20-bit card code (different on each). A quick aside: 220=1,048,576, so Lafayette's 2,500 students use only a smidge of the possible combinations.

Reading Secrets

See that picture? Good. The college uses readers just like those all across campus for access control. They're on the front of all of the academic buildings, all the dorms - just about everywhere uses these phobs.

A few days ago, I bought one of them. (It's wild what you can buy on EBay. Really wild.) The reader arrived on Monday, and sat around for a while. Midway through the week, I decided to have at it.