There is a new version of this tutorial available. Check it out here!
I could carry my keys to unlock my building door, but I’d rather not. I could buzz up to my apartment and my girlfriend could buzz me in if she’s around, but that’s obnoxious. It would be best if I could buzz up a short-code to my apartment (a Morse message of sorts) and have it automatically buzz me in. Fortunately, that can be done with Arduino.
The Buzzer Situation
My apartment building is equipped with a Aiphone VC-K intercom and door release system. The entire system runs on 12V DC power with low current, so it’s much safer to interact with than any devices attached to a wall outlet. A quick web search for the model yielded a wiring diagram, a screwdriver provided quick access to the terminals in the handset unit, and a multimeter allowed me to understand how it works:
I have access to the VC-K unit in my apartment; the VC-M is at the front door. Terminals 1 and 2 provide communication with the front door. Terminal 3 is ground. Terminal 4 carries 12V and when connected to ground will unlock the door. By maintaing voltage in the locked state it is failsafe – a broken connection will keep the door locked and openable only by key. Terminal B drives the buzzer in the handset – its inactive state is 0v, but will send 12V when someone is pressing the buzzer for my unit at the front door.
Building the Circuit
An extremely basic solution could just connect the Buzzer terminal to the base of a transistor bridging terminal 4 and ground – pushing the buzzer for my apartment would connect terminal 4 to ground and release the door lock. It’s a serviceable solution but a) not very secure, and b) not very fun to make. The incorporation of an Arduino allows a more complex and customizable unlock button-press sequence which will open the door for a specific timed series of presses, and remained locked for single or any other sequence of presses.
For this project the new Arduino Micro is perfect – it provides all the I/O need in a tiny form factor that actually fit inside the handset’s wall-mounted enclosure. The Micros were released in November 2012, and are available on Amazon Prime for $26. I recommend the version with the male headers so the whole thing can sit right on a breadboard. If you do use the Micro for the first time, be sure your IDE and drivers are up to date even if you’ve used an Uno in the past.
An input pin (13) reads the state of the buzzer via an optocoupler which maintains separation between the Arduino’s power supply and the 12V buzzer. The circuit also connects an output pin (12) to the base of a transistor which connects terminal 4 and ground.
I chose to power the Arduino with a 9V battery. I was tempted to just plug into the 12v of the communications line (the Arduino Micro can optimally handle 7-12V), but I was worried about introducing static into the line that disrupt my neighbors’ use of it or draw attention to my modifications.
Circuit Diagram (Fritzing):
Programming the Arduino
The program is fairly simple: when the Buzzer is pressed its 12V (converted to 5v by the regulator) can be read as pin 13 == HIGH. A do-while loop measures the time intervals between subsequent presses and stores them in an array. It them compares that array to the hard-coded unlock sequence, and if they match within a certain tolerance the door is unlocked by setting pin 12 to HIGH for two seconds.
/*
* buzzer.ino
*
* Copyright 2013, Mouse Extinction
* URL: http://www.mouseextinction.com
* version 1.0, 25 MAY 2013
*/
const int buzzIn = 13; // pin connected to terminal B via
// voltage regulator
const int unlockOut = 12; // pin connected to base of
// transistor bridging terminal
// 4 and terminal 3 (ground)
const int debounce = 100;
const int maxWait = 5000; // wait a maximum of 2.0 seconds
// for change in state
const int maxCount = 3;
int codeArray[maxCount] = {500,1000,500}; // the duration
// between the given
// knock and the next
int buzzIndex = 0;
int fuzzyMillis = 200; // entry buzzes may fall within 200
// millis of timing specified by code
int listenArray[maxCount]; // will hold received buzz timing
int listenState = 0;
boolean buttonState = false;
void setup(){
pinMode(buzzIn,INPUT);
pinMode(unlockOut,OUTPUT);
}
void loop() {
listenState = digitalRead(buzzIn); // listen and move to
// code-entry fcn on any press
if(listenState == HIGH){
listen();
}
}
void listen(){
buttonState = false;
int x = 0;
buzzIndex = 0;
double start; // start timer
double now;
for(x=0;x<maxCount;x++){
listenArray[x]=0; //reset all to 0
}
do {
listenState = digitalRead(buzzIn); // listen for buzz release
now = millis();
if (!buttonState && listenState == HIGH){
buttonState = true;
start = millis();
delay(debounce);
}
if (buttonState && listenState == LOW){
buttonState = false;
listenArray[buzzIndex] = now-start; // record total time at HIGH
buzzIndex++;
start=now;
delay(debounce);
}
} while ((now-start < maxWait) && (buzzIndex < maxCount)); // continue until
// max input or time out
confirmAndUnlock(); // check input against code
}
void confirmAndUnlock(){
int x= 0;
boolean unlockArray[3] = {false,false,false};
for(x=0;x<(maxCount);x++){
if(listenArray[x] >= (codeArray[x] - fuzzyMillis) &&
listenArray[x] <= (codeArray[x] + fuzzyMillis)){
unlockArray[x]=true;
}
}
if(unlockArray[0] && unlockArray[1] && unlockArray[2]){
digitalWrite(unlockOut,HIGH); // set pin 12 HIGH to ground terminal 4 and unlock door
delay(1500);
digitalWrite(unlockOut,LOW); // reset
}
}
I tested the circuit by connecting a LED between the transistor’s emitter and ground, and then used the Buzzer terminal jumper wire to tap a signal directly from my 9v voltage source to simulate a buzzer-press. By linking through pin 13 I could see it was reading by the Arduino’s on-board LED, and upon successful unlock the LED connected to the transistor would light up – signifying a successful command to prompt the door to unlock.
Installation and Completion
By mounting the Arduino Micro on a small breadboard, I was able to fit the entire package inside the handset’s wall-mounted base. After a little live testing to confirm everything worked as intended without any detriment to regular functionality, I now have an easy way to open my door without a key.
My roommates and I are looking to put together a similar solution, also working with the VC-K. We are planning to connect an arduino to our LAN so that in the long run we will be able to trigger the door unlock from our phones. More of a learning project than a convenience really (otherwise, we’d go with your much simpler solution).
This page should be great reference material.
That’s awesome. Leave a comment or link if you write up anything about attaching to the LAN.
Looking to work on a project this weekend. Would you share schematic for this awesome project. Thanks
Sorry — all I made is the circuit diagram already included above, but that should have all the necessary info.
Will let you know if it get it to work for me. Can you confirm the following?
Input Pin (13) connects to Optocoupler Pin #?
Out Pin (12) connects to Optocoupler Pin #?
Will make sure to share your site with others.
Thanks
It depends on your optocoupler, but this is a fairly standard setup for a 6-pin variety: http://www.vishay.com/docs/83725/4n25.pdf. Basically you want the buzzer at Pin A (in the diagram) connected to ground at Pin C. When current is running through there it will permit current to flow between your 5V source at Pin B and Arduino Pin 13 at Pin C (as in my Fritzing diagram) or optionally Pin E.
I’m using a 6 pin. I have call signal from buzzer connected to E via a resistor not Pin A. I see it connected to E on your Diagram.
Arduino 5V Power conected to Breadboard + –
Jumper Cable from Breadboard + to Optocoupler 1/A
Jumper Cable from Breadboard – to Optocoupler 2/C
Jumper Cable from Optocoupler 5/C to Arduino Uno Input Pin 13
Does above mentioned seem right?
Connected LED where Door Release and Ground Cables would be plugged in.
Tried connecting to Call Signal Cable to 9v Battery but perhaps I’m either connections aren’t correct or I’m not sending signal proper timing per sketch.
It’s possible you or I rotated the whole this 180 degrees — as I said before, the buzzer signal should be connected to Pin A per the spec sheet I supplied. I don’t know your exact layout, but the buzzer should be connected to whatever pin of your optocoupler is input to the emitter. Pin E is an output.
What’s the sequence/timed series of presses to get automatically buzzed in?
Hi i have a quick question, I am using an Aurdino Uno instead of micro and since i am using digital input/output do i need to change pin 12 and re-allocate it to the pin i used which is pin 7 which goes to base of transistor ? Regards Cazzy
Thanks for posting this, I just started thinking about ways to improve our entry system and it was great to have this as a starting point. I’ll hopefully come back with a link to what I end up doing — I’m thinking more about web controlled than ‘secret knock’, but it might be easiest to start by replicating what you’ve detailed here!
Hi, I also just did the setup. I just a 4 pin octocopter (but looked a the diagramm to connect it the right pins) but all the other setup is the same. Still I does not open. Do I need to use this octocopter you used? Could you explain how the opening sequence is.
Also what transistor are you using?
Just wanted to explain that since I teach yoga at my apartment I wanted to switch this self-opening system on during class to not having to go back to the phone at all and to avoid the possible loud buzz when people would come late, and switch back off again at the end, thanks.
You could do the same by purchasing a $10 A\C remote kit from ebay, one that has options for momentary or latching. I wired the door buzz button in the apartment to the latching section of the receiver. I press a button on the remote and it latches and voila buzz. People standing in front of the building are amazed when I enter or if I have to let someone in while outside without having to move or get the keys out of my pocket.
It should be noted that I live on the first floor close to the lobby entrance. But the wiring in the buildings doorbell system should be able to handle antenna duty in most buildings.
I’m new at this and not a tech person. I’m would like to copy what you did for my apt intercom, which is a Lee Dan intercome Model IR-204 (4 wires). Could you provide a list of items/components I need to buy to build circuit and how do I go about programming the Arduino?
Great write up! I was trying to figure out a similar solution to my intercom the Airphone GT-1C which is a new model it seems.
I posted on Stackoverflow about it http://raspberrypi.stackexchange.com/questions/53940/control-apartment-buzzer but didn’t get any responses. I was looking for a specific pin that does the door release but couldn’t find anything.
Any guidance or suggestions would be appreciated! Thanks!
Any chance you figured out which pin the voice signal is coming in through? Going to tackle this shortly. Will report back