Tag Archives: x10

Getting your CM19a working on Linux (Raspberry Pi)

I recently acquired a Raspberry Pi, and my main project is to get X10 stuff working again in my house.

To that end, I purchased a CM19a. I’m going to chronicle the process of getting it working here, so that eventually this will be a helpful howto. At the moment, it’s just a collection of notes and frustration. If you know something I don’t know, *please* let me know.

First, plug in your CM19a to the USB port.

Run dmesg. You’ll see something like:

[ 11.236260] input: X10 Wireless Technology Inc USB Transceiver as /devices/platform/bcm2708_usb/usb1/1-1/1-1.3/input/input0
[ 11.436218] usb 1-1.3: Weird data, len=1 ff 00 ff 00 00 00 …
[ 11.447235] usbcore: registered new interface driver ati_remote
[ 11.584656] ati_remote: 2.2.1:ATI/X10 RF USB Remote Control

Also, when you run lsusb you’ll see:

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 0bc7:0002 X10 Wireless Technology, Inc. Firecracker Interface (ACPI-compliant)

And in /dev you’ll see:

rbowen@raspberrypi ~ $ ls -la /dev/usb*
crw——T 1 root root 189, 0 Jan 1 1970 /dev/usbdev1.1
crw——T 1 root root 189, 1 Jan 1 1970 /dev/usbdev1.2
crw——T 1 root root 189, 2 Jan 1 1970 /dev/usbdev1.3
crw——T 1 root root 189, 3 Jan 1 1970 /dev/usbdev1.4

So far, so good. Linux sees it.

[I’m not yet sure if this part is necessary. Still trying to figure that out.]

You’ll need to create /dev/ttyUSB* to go along with that. Paste this at the shell:

for i in 0 1 2 3 4; do
sudo mknod /dev/ttyUSB$i c 188 $i

Note: 1) This is a magical incantation. I don’t yet know what the args to mknod mean. 2) I did 0..4 because lsmod shows devices up to 4. If you have more, make more.

It appears that ‘heyu’, which I used with the serial device I used to have, doesn’t support the CM19a. Disappointing. But it looks like mochad does, so I’m trying that. Unfortunately, it appears that mochad doesn’t support extended status reporting (ie, the bit that tells you to what level a particular light is dimmed).

Get mochad. Build it and install it as per the instructions at https://sourceforge.net/apps/mediawiki/mochad/index.php?title=Main_Page..

At this point, it’s probably easiest to reboot the box, so that libusb gets loaded right, and mochad starts up correctly.

You should now be able to send commands to your device with netcat from anywhere on the network (or on the box itself)

echo ‘rf f2 off’ | nc raspberry 1099

Where, in this case, raspberry is the network address of my raspberry pi.

On the box where mochad is running, you can watch progress with:

nc localhost 1099

which will show the commands as they arrive:

01/02 21:51:12 Tx RF HouseUnit: F2 Func: Off

Now, the only problem is that my lights aren’t actually turning on or off. Perhaps a project for later this evening.

Update: I think maybe the RR501 I was sending to was defective? Not sure. Anyways, I swapped it out with a TM751 I also had sitting around, and now I can turn lights off and on. Next challenge, some kind of automation scripts that do more than one action at a time.

Update2: Seems maybe the CM19A has a range problem. I put the raspberry pi back in the network closet, and now stuff has stopped working.

Update3: No, that was an idiot problem – I had an argument misspelled in the shell script that was calling the X10 commands. Everything seems to be working now. However, for now, it’s all set up down in the living room, with rather more cables behind the stereo than I really care for.

Problems remaining to be solved: Why do /dev/ttyUSB* need to be recreated at each boot?

Update4: Having the perennial Linux problem where something works, and then stops working on reboot. Gah!

Update5: Using OpenRemote to create an Android app that is a remote control for my home’s lights. Very cool. However, I’m encountering a bug that was theoretically fixed two versions ago. Bummer. The remote controller establishes TCP connections to mochad and never releases them. Eventually, you can’t make any more connections and it just stops responding.

Update6: I’ve forked mochad on SourceForge and will be tinkering with stuff there for the moment. Right now I’m working on fixing the CGI stuff to be more generic. What’s in the main repo is hard-coded to talk to mmauka’s home setup, and obviously that doesn’t work for me. I’m not sure I want to develop a full CGI controller solution … but I might. We’ll see.

Upodate7: MisterHouse (http://misterhouse.sourceforge.net/) appears to still be active, so perhaps I’ll play with that some, too.

Raspberry Pi, episode 1

I got a Raspberry Pi for Christmas. I’ve been meaning to get one for some time, because I wanted to play with home automation (x10) stuff again. So here we go.

I’d rather not mess with getting usb/serial stuff working again. That was a pain. So I’m going to get a CM19a instead and see if I can get that working.

Should be fun.

So far, I have the Rasberry Pi booted, and I’ve got some basic stuff installed on it. It’s running Debian 6 (Raspbian) and I’ve got a 4G card in it, which, so far, looks like it’s going to be plenty.


The photographer just left. He was here for about an hour, and took several hundred photos. He said that of that they might use 2 or 3 in the article. But he said he’d send me all the photos.

Shadow hammed it up and got into a bunch of the photos. 🙂

Home automation and the New York Times

A year or so ago, I installed a bunch of X10 stuff. I believe I blogged about it at the time.

Well, someone told someone else, who told someone else. And now the New York Times is doing a story on home automation and X10. They asked me a bunch of questions via email, and I thought that was the end of it.

This evening, someone called me to set up an appointment for a photographer to come over to take photos of me with my X10 gear, and they’re running a story about my stuff in Thursday’s New York Times. Pretty cool, hmm?

Home automation – more details

The home automation stuff that I’m doing is mostly X10. There are a few exceptions.

In the garage, laundry, and walk-in closet, I’m using hardware-store-variety motion sensor light switches. They are cheaper than X10 controllers, and are sufficient to the task. That is, I want a light on when I’m there, and not when I’m not. These switches cost anywhere from $10 to $30, and look like this. They work via some unspecified IR sensing, and are very reliable, and very fast.

Everything else is X10. Mostly, it is controlled from my Linux box, so in answer to the earlier question of whether it can be controlled from Linux, YES. There are actually several X10 controller apps for Linux.

You need a X10 transceiver, which plugs into your serial port. There are also USB ones, but I got the impression that they are very new, perhaps not very reliable, and having started using Linux in 1996, I’m always rather frightened of hardware support on Linux.

I am using a command-line app called heyu (pronounced “Hey! You!”). So I run “heyu turn c4 on” and my bedroom light comes on. Or you can alias them, in the configuration file, so that you can say “heyu dim livingroom 11” and it will dim the living room lights by 50%. Yes, it’s a scale of 1-22. I can’t imagine why.

In the bathroom, I have a motion sensor. These send an RF signal to an RF receiver which is plugged in to a wall socket and relays the message. (X10 transmits over the power lines, in case you missed that part.) So when I come into the bathroom, it sends a message to the x10 server, which notices it and runs a script:


# What time is it? 
$h = sprintf  '%02d', (localtime(time))[2];
$m = sprintf  '%02d', (localtime(time))[1];
$t = $h . $m;

# Is it already on?
$on = `/usr/local/bin/heyu dimlevel b2`;
exit unless $on < 20;

# Dim between 21:30pm and 6:30am
# Unless it's already on, that is
if (($t > 2130) || ($t < 630)) {
    `/usr/local/bin/heyu bright b2 8`
} else {
    `/usr/local/bin/heyu bright b2 22`

In other words, if it’s before 6:30 am, or after 9:30 pm, just turn the lights on a little bit. Otherwise, turn them on all the way.

Similarly, another script gets called when the sensor doesn’t detect motion for n seconds (60 by default).

One problem with X10 is that it is slow. When I walk into the bathroom, it can take up to 2 seconds for everything to get done and the lights to actually come on. This takes some getting used to. 2 seconds doesn’t seem like a long time, but it *feels* like a long time when you’re standing in the dark.

As for the remote controls – when I ordered my X10 stuff, it came with a universal remote, and one of the things on it is X10. So I can send an on or off, or dim or bright, to any device in a single house code.

The addressing scheme is simple. There are house codes A through P, and in each one there are 16 addresses. So each item in the house gets an address like F2 or C12. This gives a lot of room for devices. However, most transmitters (such as the remote control) can only transmit to a single house code. So you have to plan your addressing carefully.

Anyways, if you want to know more, I recommend buying stuff from PIGS Electronics rather than from X10.com. Better prices, and the website is much much easier to use.

And I recommend the O’Reilly book for good ideas. The implementation is so simple, that the book is really just good for ideas, not really for the implementation details. Also, since almost all of the implementation details are for software that I’m not using, that part of it is not useful to me at all. It assumes you’ll be using Windows or Mac as your controlling computer.

Home automation

On the home automation front, I now have the following working.

When I walk into my bathroom, it turns on the light. However, if it is earlier than 6:30am, or later than 9:30 pm, the lights turn on at half intensity. Kinda nifty.

The laundry room and walk-in closet have cheaper Lowes-variety motion sensor lights, since in there I always either want the light on or off, and I want it to go off as soon as I leave.

The living room light turns on and off (and dims and brightens) by buttons on the television remote control.

And my halloween lights (orange christmas lights) turn on and off every time someone visits this website, or directly accesses http://wooga.drbacchus.com/x.cgi. Sure, this last isn’t very practical, but it makes me giggle.

Oh, yeah, and I have a little key-fob-style remote control by my bed that lets me turn on or off any of the lights in the room.

Next, I’m saving up for the x10 thermostat – slightly more practical, and very high geek factor. However, I think I’ve probably spent enough on this particular geeky hobby, at least until I get another royalty check. 😉


Every 4 or 5 years, I discover X-10, and I think, gee, wouldn’t that be SO AMAZINGLY COOL. And then I decide that the pricetag is way too high, and I get over it.

I have crossed the invisible line.

This started when, at OSCon, I saw a book. Smart Home Hacks. Now, none of the stuff that they talk about in there is really a surprise to me, but it sparked some ideas about what *I* want to do. More details on that to follow, I’m sure. And, I was somewhat surprised at how the prices had dropped since the last time I looked at it.

Then, today on the way home, I stopped into Radio Shack, and discovered that I could get a “Home Automation Starter Kit” there for just a few bucks. And … I did.

I’ve started small. I got one of the X-10 timer units. It will turn the fish tank light on and off on schedule, for the moment. And it will also be my alarm clock, buzzing at a particular time in the morning, and turning on my room lights 15 minutes later, in case I fail to get up fast enough.

I’ve also ordered the serial-port based X-10 thingy, which will allow me to do X-10 stuff from Linux, automating stuff via cron, or perhaps (and here’s where some cooler stuff happens) via my website. That’s right, I’m doing the ultra-cheesy thing where you can turn my christmas tree on and off from my website. But I’m going to be slightly more creative than that. I hope. Time will tell. More details as they appear.

But there are a boatload of more practical things that I really want to do, and X-10 seems to be the way to do them. The big problem is the large (but smaller than it used to be) per-switch price tag. But I’ll do this gradually.