Almost three years I published an article detailing how to remotely buzz yourself into an apartment building. In the time since, new technologies have made it even easier to interact with your home remotely. Below, I detail an updated remote door buzzer that works with mobile phones and even Apple Watches. Furthermore, the basic setup is extensible to lighting systems and any other action that can be controlled by a shell script.
Overview
The ultimate workflow is simple and is as follows:
- On your smartphone or Apple Watch, send a Yo to a custom-created recipient
- Your door buzzer will be activated
To achieve this, we’ll be using a custom-made circuit that electronically switches the door buzzer. To control the circuit remotely, we’ll be using a Raspberry Pi home server that will receive casually authenticated signals over the internet sent via the Yo app (https://dashboard.justyo.co/).
Required Gear
The following items will be used to create your phone-controlled door buzzer:
- Raspberry Pi — Any Raspberry Pi model should work, but I’m using the Raspberry Pi Model B+. You’ll also need an SD card (micro SD in the case of the B+ model) with at least a few gigs of space, and all gear necessary to set it up like an HDMI cable, keyboard, monitor, etc.
- Pi Cobbler Plus — This will allow you to attach the Raspberry Pi to a breadboard. Optionally you can plug your circuit board directly into the Raspberry Pi, but this is a good accessory to have around anyway.
- A small breadboard — this will do
- Small perf board — You may be able to build your circuit on your breadboard, but I’ve found that the optoisolator pins don’t generally fit in breadboard slots, and building a permanent circuit will be handy in the long-run
- 1 Channel Optoisolator (e.g., this)
- Small LED
- Short jumper wires
- A length speaker cable long enough to get from your Raspberry Pi to the buzzer — it helps to color-match your molding
Pi Setup
Step one is to setup a Raspberry Pi as a home web server. First, download a Raspbian OS image at https://www.raspberrypi.org/downloads/raspbian/. I’ll be using Raspbian Jessie Lite. Then, install that image to your SD card by following the instructions at https://www.raspberrypi.org/documentation/installation/installing-images/.
Once you’ve installed Raspbian to the SD card, you can put it in your Pi, connect the Pi to a monitor and keyboard, and then power it up to boot it for the first time. As your first act, I suggest updating the password for the `pi` user by using the `passwd` command. Next, I suggest updating the keyboard settings to reflect a US keyboard layout. Follow the instructions at https://raspberrypi.stackexchange.com/questions/1042/why-is-my-symbol-not-working to do so.
Finally, we’ll install the WiringPi library which will give you control of the Pi’s General Purpose I/O (GPIO) pins. Install it following these instructions: https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/
New Building, Same Buzzer Situation
We’ll be controlling an Aiphone VC-K model. 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.
Even though my current buzzer and my buzzer three years ago are the same, I’ve since been in other apartments with other systems in the intervening years, and their circuitry is very similar. Connecting one of the terminals to ground should unlock the door — you may just have to test with a small length of wire.
Circuit Board Design
We will now build the circuitry that will interact with the door buzzer. The GPIO controls will give us toggle-able voltage that we’ll use to drive an optoisolator. To the other side of the optoisolator we’ll connect terminals 3 and 4, such that terminal 4 will be connected to ground and unlock the door when the GPIO pin is powered.
Red – connect to pin 17 of the Pi
Black – connect to ground of the Pi
Blue – connect terminal 4 of the VC-K unit
Yellow – connect to terminal 3 (ground) of the VC-K unit
If you’re not using the Pi Cobbler, refer to this page for pin layout.
The LED will light up when the door buzzer is toggled on, which will help us debug this down the line.
Control Script
Now, we will create a bash script to control the GPIO pins. The following script will toggle power on pin 17; name it buzz.sh
.
#!/bin/bash
gpio mode 0 out
gpio write 0 1
sleep 2
gpio write 0 0
Running the Script Through the Internet
Now it’s time to allow you to run this script through the internet. To do so, we’ll setup a web server on your Pi, and create a PHP script that will run the shell script any time you request the page while passing correct URL variables.
To setup an Apache web server on your Pi, refer to the following instructions: https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md. Be sure to enable PHP as well.
Once the server is running, you might consider increasing its security with something like DenyHosts, which will limit failed access attempts.
By default, your web content will be in the directory /var/www/html
. Create a new directory /var/www/html/scripts
. We will deny access to this folder from the internet as follows:
Edit the file /etc/apache2/apache2.conf
(as root). Look for the section that looks like the chunk below, and then add a new section:
<Directory /var/www/html/scripts/>
Allow from None
Order allow,deny
</Directory>
Restart Apache to implement these changes: sudo /etc/init.d/apache2 restart
Next, we’ll expose your Raspberry Pi to the internet. In most home setups, you’ll just have to update your router configuration to forward port 80 to the Pi. Get the IP address of your Raspberry Pi on the local network with sudo hostname -I
. Review your router’s documentation to learn how to forward port 80 to the Pi.
To test your configuration, find your network’s public IP address (e.g., from your router’s admin page or a browser on another computer) and then go to that IP address on the internet, e.g., http://123.123.123.123
. You should see the default Apache page.
Connecting your Buzz Script with the Internet
Now that your Pi is on the internet, we just need to create a means to run buzz.sh via the web. First, put put buzz.sh
in /var/www/html/scripts
folder and make it executable — sudo chmod +x buzz.sh
Next, make a PHP page in /var/www/html/scripts/
folder called buzz.php
:
<html><body>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$output = shell_exec('/var/www/html/scripts/buzz.sh');
}
?>
</body></html>
Now that the page is in place, the buzzer should enable when you access this page on the internet. Go to http://<your-ip-address>/buzz.php
and watch the LED… it should light up for a few seconds if all is going well.
Finally, we’ll create a way to quickly access this page with the push of a button on your phone. To do so, we’ll use the Yo app. It’s a silly service, but one nice feature is that it allows you to create new Yo accounts that will perform some action when they receive Yos.
Go to https://dashboard.justyo.co/ and create a new account if you don’t already have one. From the dashboard, hit “+ Add Account”. Give your new secondary account a username. In the configuration, under “Callback”, specify the URL of your PHP script (i.e., http://<your-ip-address>/buzz.php
).
Now, download the Yo app to your phone and log-in as your main account. When you send a Yo to the secondary account you created, it will send a request to the Callback URL you specified, and unlock your door.
Now that you have Yo setup, you can increase the security of your system by specifying that the Yo must come from only certain Yo accounts to be authorized to open the door. For instance:
<html><body>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if($_GET['username'] == '<my primary yo account>'){
$output = shell_exec('/var/www/html/scripts/buzz.sh');
}
}
?>
</body></html>
It’s worth noting that Yo has an Apple Watch app that allows you to open your door from your watch.
Extending by Wifi
Finally, if for some reason your Pi web server is not near your door, you can place a second Wifi-enabled Pi nearer to the door that holds the buzz.sh script, and run that script across your intranet. For instance, the script below will use certificate authentication to run the script on the second Pi over SSH.
#!/bin/bash
ssh -i /var/www/.ssh/id_rsa -o StrictHostKeyChecking=no pi@<intranet IP of second Pi> '/home/pi/buzz.sh'
If All Goes Well
If all went well, you now have a smartphone-enabled remote door buzzer. Furthermore, this same setup can be used to run any script you may choose on the Raspberry Pi. Check back soon for ideas on lighting, and other modes of control.
This is so sweet. Love it.
Hi Jamie, thanks for the great guide. I have software engineering experience so setting up the Pi and web server was fairly trivial for me. I’m using this as a project to learn more about electricity and circuits however unfortunately this seems to be assumed knowledge in this article. I was hoping you could perhaps elaborate a bit more on the electronic side?
Some questions I have are:
1. What voltage and current did you detect with your multi-meter? I got 16V on terminal 4 and 300mA when connecting to ground. I think these are important for selecting the optoisolator you would need to use.
2. The optoisolator you linked (according to the datasheet) has a typical input voltage of 1.4V and can take 100mA (page 9). The Pi GPIO pins output 3.3V at a max of 16mA so I think you would need a resistor on your Pi based circuit. Is this correct or was left off the circuit diagram due to assumed electrical knowledge?
3. As for the intercom side of the optoisolator, the collector-emitter max voltage is 35V, well under our 12-16V which is great. However collector current states 80mA max (page 8). This confuses me because I recorded 300mA. I hope I’m reading the datasheet wrong. It would be great if you could clarify
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! (Sorry I posted this on the outdated guide)
This helped me with a little SMS-based project triggered the VC-K using a RPi + relay setup. Thanks.
Did you ever look into detecting whether someone rang the doorbell, do any of the VC-K pins hookup to detect that? I’d love for that to trigger a text so I know someone’s at the door.
Hey Jamie,
am in the proccess of finishing up your older project i have in my house the AIphone GH series is similar to yours but i wanted to know the sequence, knock and hang up wait half sec and knock again wait a sec hang up and knock again or just let it ring and do it 3 times?
am new to making commands on the arduino am good with electrocnics but the arduino is fairly new to me please get back to me when you can
Any idea how to get this going with Homebridge and Homekit to unlock the door with a button or a switch (that unlocks the door for say, 2 seconds)
Answered my own question. Install the homebridge-ssh plugin and added the following to my homebridge config.json file. This logs into my second Raspberry Pi Zero Wireless inside the VC-K phone unit:
“accessories”: [{
“accessory”: “SSH”,
“name”: “Unit Buzzer”,
“on”: “sh buzz.sh”,
“off”: “sh buzz.sh”,
“state”: “gpio aread 0”,
“on_value”: “1”,
“exact_match”: false,
“ssh”: {
“user”: “usernamegoeshere”,
“host”: “raspberrypihostname.local”,
“port”: 22,
“password”: “passwordgoeshere”
}
This creates a switch to operate the door buzzer with off and on – until such time as Apple adds support for “buttons”.