Lawrence Technological University
College of Arts and Science
Department of Mathematics and Computer Sciences

Handouts

RFID tag reader and a garage door opener

   I wanted to be able to open my garage door when coming home on a bicycle. I do not have an external keypad or an extra remote. But I did have some RFID tags and a reader (that operates as a simple keyboard wedge) left over from a project last year. There is a control panel just inside the door that sends various signals over a pair of wires to the main opener unit. Spoofing the full range of signals may be a later project. For today I just emulate the simplest command: to open or close the door by pressing the main button on the control panel and shorting the 2 wires together for > 200 milliseconds. The Arduino and the circuit below is overkill for this project but might make the other command signals easier to emulate and make it easier to connect this to my household WiFi.

   Resources used:

   The RFID reader is outside the garage and the rest is inside. If the Arduino receives an RFID it recognizes Pin 12 powers a relay (with the help of a small NPN transistor) to short the control panel button for 1/2 second. Switch 1, which comes with Adafruit's Proto Board, can be used to power the relay manually. An extra LED shows when the relay is powered.

Schematic

   The Arduino code:

// garagedoor
// Open the garage door with MiFare key fob.
#include <PS2Keyboard.h>

const int DataPin = 8;
const int IRQpin =  2;
const int relay = 12;
PS2Keyboard keyboard;

void setup() {
  pinMode(relay, OUTPUT);
  delay(1000);
  keyboard.begin(DataPin, IRQpin);
  Serial.begin(9600);
  Serial.println("Waiting for RFIDs:");
}
char buffer[15];
int i;
char c;
char *id[4] = {"3548067320","3178793323","3180056203","3178945411"};
void loop() {
  // Await an ID number.
  i = 0;
  while(i < sizeof(buffer)) {
    if (keyboard.available()) {
      c = keyboard.read();
      if (c == 0x0d) {
        buffer[i] = '\0';     
        break;
      } else {
        buffer[i] = c;
      }
      i++;
    }
  }
  Serial.println(buffer);
  for (i = 0;i < 4;i++) {
    if (strcmp(buffer,id[i]) == 0) break;
  }
  if (i < 4) {
    Serial.print("Matches ID #");
    Serial.println(i);
    // Open the door.  Pulse > 200ms.
    digitalWrite(relay, HIGH); 
    delay(500);
    digitalWrite(relay, LOW);
  }
}

Revised May 10, 2014