SBoyle.com

 

[Note: This page is from an old version of my site. Very old. I was going through my referer log the other day and noticed a link from automatedhome.co.uk. I check it out, and there is a dead link to this key rack project. So I resurrected the link because I'm such a good net citizen, and I realized that I don't have any information on my current site about this project. I don't use the key rack anymore but it was a neat idea, and very satisfying. There were two version of the key rack which I've combined onto a single page. When you're done you might want to check out the current site. -Shawn]

The Key Rack

 

This was one of my first [certainly my first successful] automation project. The basic problem was that I wanted HV to know who was home, and who wasn't. It wasn't enough to just know if anyone was home or not -- HV had to know who.

The other problem that I had was that I wanted it to be as intuitive as possible. I could have mounted a "Stick-A-Switch" by the door and assigned everyone a button. Press "On" when you enter, press "Off" when you leave. But that would have required teaching people how to use it. [I've learned that if you make things intuitive enough that people [read: non-HA enthusiasts] can figure them out on their own, it greatly increases the likelihood that they'll actually use it.] Plus, you then have to worry about people pressing the wrong buttons, not pressing any buttons, and just generally messing up your perfect idea. 

So I started thinking about something related to entering and leaving a house, and something that everybody was already "trained" to use. The only thing I could think of was a key rack. Great! The next step was how to build, or modify, a key rack so that HV could know what keys were/weren't there and thus know who was/wasn't home. At first I was thinking along the lines of lever switches, and electrical connections made by the metal key ring. But then someone suggested to me that I use headphone plugs from Radioshack. Their idea was to use different sizes to guarantee that people plug them into the correct jack. I liked the idea but thought that a 1/4" headphone plug was too big to carry around on a key chain, and I didn't think that one of those sub-mini plugs, plugged into a jack, would support the weight of a full key chain.

So I came up with the following idea:
Use three miniplugs and just wire them each differently. I wired one tip-body, one ring-body, and one ring-tip. The picture below is of one of my key fobs wired ring-body.

I just thread that little loop sticking out of the bottom onto my key chain.

So now I had the fobs. All that was left was to wire up the key rack. I used a project box from Radioshack, some LEDs and some 1/8" stereo jacks. That wire running out of the left side of the box is 8 conductor "Telephone Station Wire." Which turned out to be just enough conductors. I connected the ground of one the HV input ports to the body of the first jack, the body of the second jack, and the ring of the third jack. Then I connected one input terminal to the ring of the first jack, another to the tip of the second jack, and another to the tip of the third jack. Then I wired the LEDs -- one common wire and the other three to three output ports. 

Now when I plug the the fob wired body-ring into the first jack that loop of wire completes the circuit and the HV port goes low. The event associated with that port going low turns the corresponding LED on after .6 seconds and executes that person's entering macro. If they're the first person home, then HV runs an additional macro. If someone pulls the keys out of the jack, then the opposite happens and HV runs their leaving macro. And again, if they're the last one to leave and additional macro is run.

If someone plugs their fob into the wrong jack then the circuit won't be completed and the LED won't light. Bad user!

If you only needed to track two sets of keys then you could wire it so that the user could plug their fob into either jack and HV would know who they were. 

Problems with the Key Rack

Because of the way that the stereo plugs and sockets are designed, if you plug a fob into the wrong socket, it will complete the circuit momentarily while it's being pushed in. But once it's all the way in it won't short the circuit. To get around this I had to build in a delay. When one of the input ports goes low HV waits for .6 seconds and then checks the input again. If it's still low then HV executes the appropriate macro(s). I have this same sort of setup for the port going high [someone pulling their keys out].

I've mentioned before that I live in an apartment. So when I go to do my laundry I have to take my keys but I don't want HV to run my leaving macro because I'll be back in a minute. What I did was to make a "Universal Key Fob," one that has every conductor shorted to each other. This fob will activate any jack. So I just plug this in to one of the other jacks, remove my keys and HV leaves everything on.

I also found that if the loop of wire on the key fob is solid copper it breaks sooner. I went through two fobs in 6 months when I used solid copper. The new fob that I made uses stranded copper wire for the loop.

 

The Analog Key Rack

[Picture to come]

As soon at I posted the details on the old key rack I got some great feedback from the HV e-mail list. The suggestion was to take advantage of the analog input port on the HV expansion board. Basically the sockets for the key fobs [and the extra button] are wired in parallel. When you insert a fob, or push the button, a unique resistor is added to the circuit. This affects the voltage HV sees at the input port. HV translates this voltage to a value from 0-255 and then runs a macro that performs different actions based on that value. There are several benefits to this approach. 

1. The identity of each user is contained entirely within the fob. It no longer relies on a correct combination of fob and socket. This means that a user can plug their keys into any socket and HV can still know who they are. 

2. It reduces the number of HV inputs used from three [or however many sets of keys you want to track] to one. 

3. It's easier to add new sets of keys to the system.

The first thing I had to do was redesign the key rack. I added a button to give the key rack more functionality, I reduced the number of sockets from three to two, and I added an extra "Status" led [the red one]. 

Fob Construction

 

The new key fobs have one major change -- in the place of just a plain wire shorting tip and body there is a resistor. The value of the resistor is what makes each fob unique. I also got tired of the loop of 18 gauge wire breaking, so the new ones use a piece of picture frame wire.

Operation

A periodic event set to run Every Loop reads the analog input port 5 into variable Temp Keyrack Value. If the variable is different from variable Keyrack Value HV executes the Keyrack Actions macro.

When I insert my keys the Keyrack Actions macro sets the flag Shawn Home and runs the Check Occupancy macro.

So, I walk into an empty apartment and plug my keys into either socket. The left LED comes on [Port C-7] and HV executes my Entering Apt macro. If I pull the keys out, HV turns the LED off and executes the Leaving Apt macro. If I want to leave for just a minute [check the mail, get the laundry...] I push the button on the key rack. HV loads the Keyrack Exception timer with five seconds and the red LED begins to flash. If the keys are removed before this timer runs out HV will change the status of the Shawn Home flag but won't run any macros.

Problems

I haven't run into any operational problems yet, but I did have a little problem when I was setting this up. Even with an open circuit the input port still read above zero. And when I connected a resistor to it the value of the input port would slowly climb to a point and then it would bounce between two values. Someone on the HV e-mail list suggested adding a ~100ohm resistor between the input port and ground. I did this and it works perfectly. An open circuit reads as zero, the value climbs almost instantly, and it's rock solid.

To the new site.