Wiring your Doorbell to the Internet |
|
Just in case you're bored and need something to do, why not make your doorbell
internet accessible!
The html interface for the doorbell as I have it right now is a simple cgi script which shows the last 10 lines of a log file. Being directly connected to the internet at all times makes this whole process easier. To get from doorbell to logfile has several stages. To emulate my setup, you will need at least 1 linux machine with a joystick port, a doorbell (duh), and some way to electronically access the doorbell (access to the chime is usually sufficient). Chances are good that your doorbell chime is different than mine, so I leave you to figure out your own. I will show you how I mangled mine. There are 3 contacts, all wired together in the chime. One wire goes from the front door, and one wire connects to the chime (more than likely). I disconnected the wire to the front door and attached it to the current contact of a relay. The other contact of the relay then attached to the contact on the chime, completing the circut. Now, when the doorbell is pressed, it flips the relay switch. This MIGHT disable the chime on the doorbell if it can't get enough current. You will see later why this might not be a bad thing, but if you want to hear the chime ring, you will either need a relay that uses less current or figure it out some other way. Don't ask me, I'm not an electrician. :) The joystick port on the linux box is used to detect when the relay gets switched. What we do is emulate a button being pressed, and detecting the buttonpress. On the joystick port, leads 2 and 4 connect button #0 on joystick #0, which is exactly what we want. You also want to cross leads 1, 3, and 6. 1 is +5V and 3 and 6 are resistance inputs to detect the position of the X and Y coordinates of the stick. We don't care about the stick, but if we don't show some type of input, then the driver will think the joystick isn't there. Crossing those 3 leads will emulate a joystick at <0,0>, and makes the driver happy. Once you have the relay properly hooked up to the joystick port, you now need a way to read the data. This is probably a good time to test that your wiring is correct. An easy way to do this is to get a test program for dos and hook up to the joystick port on that machine and test it. If you're able to toggle the button #0 bit when the doorbell is rung, then so far, so good. :) If you don't plan to use linux to read the joystick port, then the rest of this document won't be of much use to you. Accessing the joystick is pretty easy through a single bios call, and writing a program under dos to do so is pretty simple. Under linux, you first have to have a joystick driver loaded in the kernel. If the kernel doesn't have it compiled in straight, then you can load the module in after you boot the system with no problem. You also have to make sure that there's a /dev/js0 device present. The js.c program will test the status of the joystick just like the dos test program did. If you're able to detect a change in the button #0 bit when you ring the doorbell, then you're still in business. The dos test program, the linux joystick driver, and the linux test programs discussed can be found here. I've written 2 programs, a client and a server program for the doorbell. The client program detects a doorbell ring and notifies the server about it. The server program then logs the event and performs any other actions you may see fit (Like playing a wav file....this is why disconnecting the chime might make sense :). The client/server runs over tcp/ip and may reside on different machines. They may also reside on the same machine. I chose to dedicate a machine to constantly poll the doorbell to see when it rings. Since the joystick port doesn't use interrupts, if you aren't watching the switch when it happens, you'll miss it. Therefore I decided to dedicate a machine to it. A 486 with 8 megs of ram and a 100 meg harddisk, which is more than ample to run linux, can be purchased for $30.00 used, which is what I paid for mine. Since you don't require a monitor for this project (other than for setting it up), its a cheap enough option to just dedicate a computer to the task. I also plan to use the same computer for reading other devices as I add them. However, there's no reason you shouldn't be able to share the machine with other tasks as well, and running both server and client on the same machine works great. The advantage of running the server from a different machine is that you could, for example, while you are at work, set up the server program there so you will know when someone rings your doorbell at home. Excellent for knowing when someone comes by your house when nobody's there. Better yet, if there's an excessive number of doorbell rings in a short period of time, someone might be having a party (wink wink. :) The server program also does not have to be run on linux. You can program a server program on any computer that supports tcp/ip. The server can also execute any scripts. Setting up a webcam looking at your porch, and doing a capture and save everytime someone rings the doorbell will give you a visual log of everyone that visits you, including when you're not home. Of course, none of this is complete until you post it on the internet for all to see. :)
|