RFID Modded Safe
This project is about my RFID Modded Safe.
I’ve modded an old electronic toy-safe, which is unlocked by typing the 4-char password.
I’ve unsoldered the locking-mechanism from the circuitboard, and connected it to the Arduino instead.
Then I connected a ID-20 RFID Reader to the Arduino and programmed it to read the tag, and see if it was allowed to enter the safe.
If it was allowed, the Arduino will keep the safe unlocked in 3 seconds!
I’ve also made this video to show how it works:
httphd://www.youtube.com/watch?v=oxuD–7wWE8
You can grab the code here, and try it out:
#include <NewSoftSerial.h> NewSoftSerial ID12(5,6); // RX,TX // RFID reader ID-12 for Arduino // Based on code by BARRAGAN // and code from HC Gilje - http://hcgilje.wordpress.com/resources/rfid_id12_tagreader/ // Modified for Arudino by djmatic // Modified for ID-12 and checksum by Martijn The - http://www.martijnthe.nl/ // // Use the drawings from HC Gilje to wire up the ID-12. // Remark: disconnect the rx serial wire to the ID-12 when uploading the sketch void setup() { Serial.begin(9600); // connect to the serial port ID12.begin(9600); pinMode(12, OUTPUT); } void loop () { byte i = 0; byte val = 0; byte code[6]; byte checksum = 0; byte bytesread = 0; byte tempbyte = 0; if(ID12.available() > 0) { if((val = ID12.read()) == 2) { // check for header bytesread = 0; while (bytesread < 12) { // read 10 digit code + 2 digit checksum if( ID12.available() > 0) { val = ID12.read(); if((val == 0x0D)||(val == 0x0A)||(val == 0x03)||(val == 0x02)) { // if header or stop bytes before the 10 digit reading break; // stop reading } // Do Ascii/Hex conversion: if ((val >= '0') && (val <= '9')) { val = val - '0'; } else if ((val >= 'A') && (val <= 'F')) { val = 10 + val - 'A'; } // Every two hex-digits, add byte to code: if (bytesread & 1 == 1) { // make some space for this hex-digit by // shifting the previous hex-digit with 4 bits to the left: code[bytesread >> 1] = (val | (tempbyte << 4)); if (bytesread >> 1 != 5) { // If we're at the checksum byte, checksum ^= code[bytesread >> 1]; // Calculate the checksum... (XOR) }; } else { tempbyte = val; // Store the first hex digit first... }; bytesread++; // ready to read next digit } } // Output to Serial: if (bytesread == 12) { // if 12 digit read is complete Serial.print("5-byte code: "); for (i=0; i<5; i++) { if (code[i] < 16) Serial.print("0"); Serial.print(code[i], HEX); Serial.print(" "); } Serial.println(); Serial.print("Checksum: "); Serial.print(code[5], HEX); Serial.println(code[5] == checksum ? " -- passed." : " -- error."); Serial.println(); if (code[0] == 0x01 && code[1] == 0x07 && code[2] == 0x7A && code[3] == 0x21 && code[4] == 0xD9 && code[5] == checksum) { Serial.println("Case Unlocked by User1"); digitalWrite(12, HIGH); delay(3000); Serial.println("Case Locked"); digitalWrite(12, LOW); } if (code[0] == 0x01 && code[1] == 0x07 && code[2] == 0x7A && code[3] == 0x1A && code[4] == 0xBA && code[5] == checksum) { Serial.println("Case Unlocked by User2"); digitalWrite(12, HIGH); delay(3000); Serial.println("Case Locked"); digitalWrite(12, LOW); } } bytesread = 0; } } }
Hi there,
great work indeed!
i need to ask u some questions…could u please send me an email?
thanks in advance!
Marco from Italy
Hello Thomas,
Great project congratulations.
Im actually trying to do something similar but with 3 rfid antennas connected to one Arduino Uno. But im not succedding… theres some problem when i conncet more than 1 antenna, im using the Software Seral library + Arduino v1.0 Ide. Do you have any idea what could be wrong ?? Thanks
Rodrigo (from Chile…)
@Rodrigo
If you are going to add multiple modules you should use use 3 different serial ports to distinguish between the data from each reader.
With the software serial library you should definitely be able to use 2 modules – one connected to the hardware serial port and the other connected to the software serial port.