jonathan
beluch

 

Posted on February 13, 2011.

Although I built this project in the spring of 2008, I am just getting around to writing about it now.

The Problem

My apartment would be hot as hell when I got home from work. I had a window AC but couldn’t leave it on a timer because I didn’t get home the same time every night. So like any self respecting geek, I soldered the AC remote control to my computer so I could control it via Twitter.

This project is almost 3 years old now, and at the time I didn’t have a smartphone. The easiest method of remote control was SMS. There are plenty of cool projects using an extra cellphone for direct GSM interaction. However, twitter seemed the easiest way to connect my SMS messages with my computer.

To turn on/off the AC remotely, I would send a twitter direct message to an account created specifically for this project. A script running on a computer in my apartment would check every minute for new direct messages. The script checked for direct messages matching ac on or ac off from either my twitter handle or my roommate’s. If a valid message was matched, the script would trigger a relay connected to the parallel port of my computer. The relay would then close the circuit via the power button on the AC remote control. This effectively pressed the power button on the AC remote, turning the AC on or off.

Hardware

Remote Control

Since I didn’t want to deal with the wiring directly in my AC, I decided to utilize the remote that came with my AC. If you look closely in the first picture below, you can see very thin gold lines in a maze-like pattern. The power button pads are in the top left of the remote.

Since I left the batteries in the remote, I simply had to touch a wire across these two pads (closing the circuit) to simulate pressing the power button. So I used a normally open relay and soldered either end to each pad on the remote circuit board for the power button. When sufficient current runs through the relay coil, the switch closes and the power button is pressed.

Parallel Port

Now I needed a way to switch current on/off through the relay’s coil. A very simple way of controlling a circuit via a computer is the good old parallel port. Out of the 25 pins on a parallel port, there are 8 pins devoted to data transfer. It is fairly simple to flip one of these pins high/low programmatically (how simple depends on the operating system.).

The epanorama archives were essential in helping me learn about the parallel port. I ended up using this circuit diagram for my project. It involves a few resistors, a diode, an NPN transistor and a 9 volt battery. The diode is to quell current spikes from the relay which might otherwise damage the parallel port (and therefore the motherboard). The 9 volt battery ensures there is large enough current to effectively switch the relay. The transistor is used to enable the small current of the parallel port to control when the relay is flipped, utilizing the extra power of the 9 volt.

When the software decides to turn on the AC, it flips the data pin on the parallel port which closes the relay. This effectively holds down the power button on the remote. Then a split second later, the parallel port pin is flipped back, reopening the relay. The quick on/off is effectively a button press. If the button is pressed indefinitely it would drain the batteries in the remote.

Software

Before my free software/Linux renaissance, I actually used to own computers that ran Windows XP. The easiest way to begin writing data to the parallel port was to use the pre-compiled portcontrol.exe application, found on the epanorama site (I don’t want to hotlink to the .zip file, so search the page for WinPortControlAjax.zip). I wrote the rest of the wrapper script in PHP (before my python days).

The PHP script registers itself and runs as a windows service. This enables it to run continuously, checking for updates every minute or so. The script downloads any new direct messages for my applications twitter handle (@app580). If the messages are from me or my roommate, and they match ac on or ac off, the script flips the parallel port briefly, triggering the power button on the AC remote.

I’m in the process of getting the ancient PHP code off my old hard drive, and then I will post it to github. It’s pretty ugly code, but it makes me realize how far I’ve come since then. Plus, the whole point of hacking is to get something that works—and it did!

Photos

Here’s a picture of the completed case. I could barely fit everything into the box, only got 2 out of 4 screws in without fear of breaking one of the soldered connections. A parallel cable would then be connected from the box to the back of my PC.

Notice the painstakingly intricate cutout for the IR LED.

The lid removed, remote on top.

Here’s everything in one shot, unpacked from the project box. There are 2 wires coming from the D-Sub connector, one for the data pin, one for ground. The relay is the big blue component.

In the top right I used two 440k resistors in parallel to achieve an effective resistance of 220K called for in the schematic earlier in the diagram.

Shot of the soldered connections on the back of the board, in case you are actually trying to trace the circuit :).

Pictures of the wires coming from the relay and soldered to the remote control.

That’s all for now! This post has been more of a project overview rather than a step by step how-to. If you have any questions, feel free to send me an email.