Wednesday, June 30, 2010

X10 RF & IR remote using Arduino



Goals:
  • Create a platform independent solution that makes it easy to interface with X10 hardware and that supports sending and receiving both standard and extended X10 messages.
  • Make a cheap alternative to the Marmitek CM15PRO Computer Interface with better functionality, performance and RF-range.
  • Incorporate X10 IR into the solution to make products like the Marmitek IRRF7243 or the XanuraHome IRIX35 interfaces redundant.
  • Base it on the Arduino platform using a single Arduino Duemilanove controller.
Challenges:
  • Writing interrupt triggered non-blocking PLC1, RF and IR libraries that can be run in parallel on one ATmega168 chip without using too much resources or getting in the way of each other.
  • Making RF and IR performance good enough to be able to receive BRIGHT and DIM commands and forward them to the PLC1 interface without getting choppy dimming.
  • Using one of the ATmega168 pin change interrupts. Separate interrupts are needed for PLC1, RF and IR. The Arduino Duemilanove only has two external interrupts, but it's possible to use three additional pin change interrupts. Check out chapter 11 in the ATmega168 datasheet for more information.
Limitations:
  • RF library (X10rf) only tested with 434MHz KR22 remotes. Timing min and max values (defined in X10rf.h) may need changes to make library work with other remotes.
  • IR library (X10ir) only tested with Logitech Harmony remotes. Timings defined in X10ir.h can be changed to make it work with other remotes using the same protocol.
Future Enhancements:
  • Support for the WiShield 2.0 by AsyncLabs.
  • Android and iPhone apps.
  • Bluetooth Support.
Download the code:
  • X10ex library – X10 message transmission and reception using a PLC interface. 
  • X10rf library – X10 message reception using a standard 434 or 315MHz RF receiver.
  • X10ir library – X10 message reception using a standard, low cost IR receiver.
  • X10 test sketch – Example code using above libraries, including X10 serial protocol that works with the X10.Net library and code for the Ethernet shield.
  • X10.Net library – X10.Net serial communication library with test application. Written in C#.
The hardware you need:
  • Arduino Duemilanove board (ATmega328).
    Price: SparkFun ~$30, eBay ~$20
  • Marmitek XM10 Two-way PLC Interface2 or equivalent US version.
    Price: IntelliHome.be ~$50 (I live in Europe, X10 stuff is expensive)
  • 434MHz receiver module (I'm using one based on the Infineon TDA 5200 chip).
    Price: Similar product from SparkFun ~$5
  • IR Receiver (I'm using the Everlight IRM 3638N3).
    Price: Elfa.se ~$2, Similar product from SparkFun ~$2
Total Price: ~$77

The hardware it's replacing:
  • Marmitek CM15PRO Computer Interface.
    Price: ~$115
  • Marmitek IRRF7243 IR Mini Controller3 or XanuraHome IRIX35 Infrared Interface4.
    Price: ~$58 or ~$150 for the IRIX35
Total Price: ~$173 or ~$265

Harware used for testing:
  • X10 extended code capable two-way dimmers, appliance modules, etc.
  • Two Marmitek KR22 RF remotes (~$25 a piece).
  • Logitech Harmony 785 (using device Marmitek IR7243 to send X10 IR).
  • So far the library has been tested with the 50Hz European XM10 and the 60Hz North American PSCO5 PLC interfaces. Other models should work fine too. Thanks to the guy at http://brohogan.blogspot.com/ for testing the PSC05 :)
Credits:

I want to thank Jaime from Spain, for his contribution to getting me started with the Arduino Ethernet shield and for giving me useful information on the workings of the iPhone and Android platforms.

I also want to thank BroHogan for his excellent blog that inspired me to start my X10 project, and for his help on testing my libraries with North American PLC interfaces and 310MHz RF receivers.

If you want to know how to re-tune the 315Mhz RF receivers from Sparkfun to X10 compatible 310MHz receivers, check out BroHogans blog.

Resources:

1 PLC = Power Line Communication
2 The XM10 seems to have way better PLC signal strength compared to the CM15PRO.
3 In my opinion the IRRF7243 is not worth the money because of poor IR range and choppy dimming.
4 Never tested the IRIX35, but with a price of ~$150 I assume it’s a lot better than the IRRF7243.

30 comments :

  1. The US X10 RF frequency is 310MHz but sparkfun only has 315MHz RF receivers. Any idea where to find one?

    ReplyDelete
  2. Sorry, wish I could help you. I wasn't even aware that the X10 frequency in the US was 310MHz. I found a receiver module that looks suitable on www.wenshing.com.tw, but I don't know how to order one.

    ReplyDelete
  3. Hi! very good job. I write you because I'm know a little of iphone/android programming and I'm working to make some app for interacting with arduino and your libs. I have searched for your email but i don't find it. If you want, we can't talk about all of this.

    ReplyDelete
  4. Hi,

    At first, I thank you for sharing that good work. It is really inspired me to control my existing X10 devices independently as you did.

    But, I want to mbed instead of Arduino MCU. It has everything but much more. There are plenty of interrupts and built in PHY (LAN) for accessing over internet.

    Do you have any knowledge how to attach a transmitter module along to Receiver then we can control X10 devices by using X10 TM13 transciever module instead of XM10 (PLC)?

    Thanks,
    Sener

    ReplyDelete
  5. Hi Thoam,
    Great job!
    I was searching on internet for a while a project like yours.
    I would like to develope a Android app for control and for receive trigger from my x10 devices.
    In the beginning i though to control them by internet implementing one app that send comand to a rest webservice arduino.
    In your article you make reference to a arduino web server that implement the rest/jason protocol but from the photos that you post it seems that you use a rf module.
    I do not understend!
    I miss something.
    I would like to use arduino 2009 plus one ethrnet shield.
    What do you think about?
    Did you make a solution like this or you planned to do like this in the near future.
    Compliments again for your great job and for sharing jour efforts.

    Mirko Ugolini

    ReplyDelete
    Replies
    1. Your best bet is to use a raspberry pi (~$25 linux computer @ newark.com) as the server with a usb->serial connection ($5 on t-mart.com) you can connect a cm11a into that (~$15 on ebay) and a cm19a (~$15 on ebay) for rf signals. You could easily also hook up a usb ir reader/blaster (~$10 tmart.com) if you need ir too. Then you could use software like domogik, or domus.link with heyu, or mochad for controlling x10 security systems

      Delete
  6. @Mirko Ugolini

    I'm using the RF module to receive X10 commands from standard X10 remotes like the KR22. The web server code is written for the Arduino Ethernet shield, so using the hardware you are suggesting should work perfectly.

    I'm currently working on an Android app that uses my web server code and the Ethernet shield. I've been testing the app for quite a while now and will publish it soon.

    If you want to e-mail me directly, look for my e-mail address in the source code.

    -Thomas

    ReplyDelete
  7. @Sener

    Although it's possible to send X10 RF commands from the Arduino and repeating them using a device like the TM13 I wouldn't recommend it because the X10 signaling is quite slow. Putting another link in the chain will make it even slower. Dim/bright commands will suffer from this performance loss. Also, be aware that the X10 RF protocol doesn't support extended code, so preset dim commands, e.g., would not work.

    I don't think it should be very hard to rewrite my X10 libraries to work with the mbed. If you want to give it a try I'll assist you as much as I can.

    -Thomas

    ReplyDelete
  8. Your libraries are compelling, but is there some documentation on their usage? I tried to follow the code in the example but kept getting lost. Something regarding how to send an ON command vs an OFF command, receiving and displaying commands, that kind of thing.

    ReplyDelete
  9. Thomas,

    I'm having trouble compiling your code. I'm getting the following error;

    "X10_Ethernet.cpp: In function 'void processEthernetRequest()':
    X10_Ethernet:407: error: 'class X10ex' has no member named 'setModuleName'"

    I'm using an ATmega168. Can you help.

    Thanks.

    ReplyDelete
    Replies
    1. I know this is a bit late. But, to anyone else who has the same question: Unfortunately there is not enough memory on the ATmega168 to run the Ethernet sample code.
      If you're OK with serial only it will work fine with the ATmega168.

      Delete
  10. does it work with a CM11 instead of a CM15 ?

    ReplyDelete
    Replies
    1. It doesn't work with either. You need the XM10 or equivalent. The good news is that the XM10 is cheap compared to the CM11 and CM15 computer interfaces.

      Delete
  11. Hello,
    Great blog post. I hope to make one of these.
    I cannot find a receiver based on the Infineon TDA 5200. Will one of these do the job:
    http://www.sparkfun.com/products/10532

    Thanks,
    John

    ReplyDelete
    Replies
    1. Any receiver on the frequency used for the Marmitek remotes in your country should work fine.

      Delete
  12. You connect directly the pl zero crossing, pl receive, and pl transmit to digital pins on arduino?

    I'm trying to do this but I have some problems. I have the Marmitek XM10 and arduino uno.

    If you have a fritzing scheme... thanks a lot!

    ReplyDelete
    Replies
    1. I hope you got it working. Yes, I have everything connected directly to the Arduino digital pins. Not sure a Fritzing would be much clearer than the image on the top of the blog post.

      I recommend that people start with a simple setup, start with just the XM10 (no Ethernet Shield, RF or IR). And start with the X10 Serial sample sketch. Once that works, connect the next "device".

      Delete
  13. Hi
    I'm an newcomer to Arduino and am trying to interface an Arduino Uno with a Marmitek XM10 controller. I've spent days trying to get an X10 library that is compatible with 60HZ and I found everyone recommending this lib. I've noticed that the "#include WProgram.h" line won't compile on the 1.0 IDE, changing the line to "Arduino.h" seems to work but I'm not sure if that change is appropriate or if anything else needs to change. Initially I just want to switch a few appliances on and off so don't need any of the remote code Is there a simple sketch of using the x10ex lib just to switch lights on off etc.

    Many Thanks
    Eddie

    ReplyDelete
    Replies
    1. Hi Eddie.
      First, try to download the new versions of the library (published June 23.), that should fix the "WProgram.h" error and some other issues.
      Next, try experimenting with the phases and Hz settings in the X10ex library "constructor". By default these are set to 1 (no phase coupling/repeat) and 50Hz respectively.
      I'll make a "Simple" sketch without the RF and IR stuff soon, but I'm afraid it wont make much difference.

      Delete
    2. Simple sketch available here.

      Delete
  14. Thomas, why your library doesn't work with arduino mega 2560?
    The XM10 doesn't respond but with Arduio Uno works fine.

    ReplyDelete
    Replies
    1. I think you have to use other pins and interrupts with the Mega, have you tried that? And make sure to use the new libraries and samples I published June 23.
      If you can't figure it out, send me an e-mail. You can find my e-mail address in the license text of every source file.

      Delete
  15. My libraries and sample sketches have not been working well after the Arduino 1.0 upgrade, and not at all after the Arduino 1.01. I'm sorry to anyone who've had problems, but I just noticed these issues myself.

    As of revision 68 (23. June) everything should be working again.

    ReplyDelete
  16. Hi Thanks for the library and sketches. I am using the XM10U and am unsure about how to wire it up to the Arduino. Your diagram seems to be wired up differently to the arduino X10 documentation although there seems to be discussion on whether that is correct or not. Do you still have the 5k Ohm pull up resistor in place? Would it be possible for you to provide a simple wiring diagram without the RF and IR components?
    Thanks

    ReplyDelete
  17. Hi everybody,

    I am new comer in Arduino land, and very interested about this project. My goal is to allow a disable person to switch on/off lights and others from a PC, using the LAN.
    I have buyed an Arduino Mega260 and an ethernet shield. I get some trouble for cabling the Marmitek XM10 module to the Arduino: I have 4 wires (black, red, green, yellow) and don't fint how to plug them on the board.
    Any help would be very welcome.
    Thanks in advance.

    ReplyDelete
  18. This comment has been removed by the author.

    ReplyDelete
  19. Hello ,

    I made an Android App to use with this library
    X10Domuino on google play.Check Androidmodbus.com for more info

    Philip

    ReplyDelete
  20. This comment has been removed by the author.

    ReplyDelete
  21. Meanwhile, thank you so much, I'm rehearsing ...
    I saw that the library is not compatible with the 1.67 version ...

    ReplyDelete
  22. sadly the library doesnt seems to compile anymore

    ReplyDelete