Automate your lighting with X10

On Star Trek, the U.S.S. Enterprise reacts automatically to voice commands, movement in rooms, and potentially dangerous situations. Your home probably doesn't have an energy shield, but it does have lights, environmental controls, sprinklers, and movement throughout, and you can equip it to respond to events and automatically control these functions. For example, you can implement X10 technology, the most common home automation protocol, to set up a basic lighting-control system. You can apply the following home-automation instructions to other functions besides lighting.

X10 is a common home automation protocol that uses existing electrical wiring in your home to communicate with devices that you want to control. You can either write your own server software to control the X10 devices or purchase ready-made software from places such as http://www.smarthome.com.

X10 technology uses two codes (which you set by using two small dials on the device) to designate the address of the device. The address consists of a house code and a unit code. The house code is a letter from A to P. The unit code is a number from 1 to 15. The house code plus a unit code identifies a device so that it can communicate with a computer. For example, you can address a light switch as L5. From a computer, you can send commands such as on, off, and dim to control the state of the device. The manual that comes with the controller hardware you purchase describes the command protocol (the language for communication between the computer and the X10 device). Using the PowerLinc hardware controller as an example, I demonstrate how to control devices after I describe the various lighting controls you can implement.

After setting the device address, you need to choose one of three X10 lighting options. One approach is to use a basic receive-only X10 light switch, which is the least expensive type of X10 light switch because it has no transmission circuitry and therefore the switch can't communicate back to your controller. The downside of this type of product is that your home automation software won't be able to determine whether the state of the light has changed. If the computer doesn't know the current state of the device, it will report incorrect information.

Another option is a two-way X10 light switch, which typically includes a state indicator and sends out an X10 command when you press the switch. The X10 command makes both the computer and the light switch aware of the light switch's state. This type of light switch doesn't control power to the light; you use X10 lamp modules (that plug in to an available electrical socket near the lamp) for each light to control power, as Figure 1 shows. This approach is ideal for a room that has multiple floor lamps because you can set the X10 device addresses of all the lamp modules to the same house and unit codes. Then you can turn all the lamps on with the same command.

The third option is to use a two-way (for state communication) X10 light switch that replaces the original light switch and directly controls power to a light. This option is ideal for overhead or prewired lights because the physical wiring is already complete and you probably already have a physically wired light switch in place. As with the second approach, both the computer and the switch recognize state change. Figure 2 shows how the lighting system is connected to the fixtures.

After you wire the switches as Figure 1 and Figure 2 show, you need to implement a way for them to communicate with the computer. I use the PowerLinc X10 Interface, available at http://www.smarthome.com. The PowerLinc device uses ASCII bytes to communicate X10 protocol from your computer to a device, or from one device to another. The PowerLinc contains all hardware necessary to connect your computer to the power line (electrical wiring) of your home. It also contains all hardware to connect an X10 device (such as a thermostat control) to the power line. The PowerLinc module plugs into an available 120-volt, 60Hz electrical outlet and has an RJ-11 jack on the other end. You can plug the RJ-11 jack into any X10 controller that uses the TW523-style module (one of the original products used to communicate from a computer to an X10 device) or into a serial adapter for your computer.

Using an RS-232 serial adapter, plug the PowerLinc module into an available COM port on your computer, as Figure 3 shows. You can use your own custom-written software to control the module through the serial port (I discuss this option later), or you can purchase software, such as SmartLinc's HouseLinc, that performs X10 commands. Writing commands to the PowerLinc module is as simple as sending bytes of data to the serial port the PowerLinc is plugged into. You can find full PowerLinc information and command protocols at http://www.smarthome.com/1132.html.

Here's an example of using the computer and the PowerLinc module to turn on an X10 light switch with an address of L5. From your computer, issue the following sequence of commands (you can find explanations of the code at http://www.smarthome.com/1132.html):

  1. Send the 0x02 command to the PowerLinc. This specific PowerLinc command specifies that you're starting a command.


  2. The PowerLinc will respond successful with 0x06, or unsuccessful with 0x15.


  3. The PowerLinc will respond with 0x0d, the PowerLinc acknowledge command


  4. Send the 0x63 command (X10 command designation).


  5. Send the house code hexadecimal value (see http://www.smarthome.com/1132.html). In this example, I use 0x4b for house code L.


  6. Send the unit code hex value (see http://www.smarthome.com/1132.html). In this example, I use 0x42 for unit code 5.


  7. Send the on command hex value, 0x45.


  8. Send the repeat command, 0x41.


  9. The PowerLinc will respond with a series of bytes:
  • 0x58-transmission received
  • 0x4b-house code
  • 0x42-unit code
  • 0x31-sent once
  • 0x0d-carriage return acknowledge command
  • 0x58-transmission received
  • 0x4b-house code
  • 0x42-unit code
  • 0x45-function code "on"
  • 0x31-sent once
  • 0x0d-carriage return

One warning about using X10: When you use X10 products for lighting and other components, you might encounter a common problem-you can't control everything in your home with one system. The reason is that most homes are wired from a 220-volt source. Because most appliances use 110 volts, the main line is split into two legs. Your computer, which you'll use to control your smart home, will be on one 110-volt leg. It can communicate only with devices operating on the same leg. You can buy a device, such as the Leviton Signal Bridge, that you wire into your breaker box for the specific purpose of bridging X10 communication in your home. Or you could buy a device that doesn't require wiring, such as the SignaLinc Plug-In Phase Coupler. You simply plug this device into a 220-volt source, such as the outlet your dryer is plugged into. Then, you plug the 220-volt source (the dryer) into the SignaLinc product. This approach will let the source (the dryer) operate normally and will also bridge all X10 signals across the legs to all devices in your home.

By starting with one specific task-implementing X10 to control lighting-you can build the foundation of a complete smart home. You can expand on this basic principle to automate other home functions, such as temperature control. Your house might not be the U.S.S. Enterprise yet, but step by step, you can make it smarter.