Friday, September 26, 2014

Home Automation using C# and x10 Modules and Computer Interface

In this blog, the step 1 to step 5 shows you how to set up the home automation using X10 technologies (where to purchase and how to setup). The remaining step shows you how to control devices via X10 using C#.

Step 1: Purchase X10 Appliance Modules / Lamp Modules


The first step is to purchase X10 appliance module with optional lamp modules (purchase a lamp module only if you want to dim a lamp).

The x10 appliance modules allow one to control many different home appliances such as lamp, electric fan, fridge, etc, via a computer interface such as CM15Pro. The approach is not intrusive, in other words, there is no need to modify your home circuits or whatever. Simply plug the appliance module into any of the wall socket, then plug any devices (to be controlled) onto the socket on the appliance module. 

The lamp module is similar to the appliance module except it allows dimmable lamp attached to be dimmed via a computer interface such as CM15Pro. By the way, if the lamp you try to control is not dimmable (such as those cheap lamp sold at Japan Home shop), then don't bother to by a lamp module as non-dimmable lamp can be easily controlled by a appliance module (any way lamp module does not work well with non-dimmable lamp)

A computer interface control the appliance module or lamp module via either power line or radio frequency, the appliance module or lamp module in turns can then switch on or off the devices plugged into its socket. 

If you are staying in Singapore or some other common wealth countries which follow UK plug standard, you can purchase the appliances modules / lamp modules from UK Automation at http://www.uk-automation.co.uk/

For the appliance module, I would recommend AM12U (http://www.uk-automation.co.uk/products/Marmitek-X10-Appliance-Module-AM12U.html). The picture below shows the AM12U module:


For the lamp module, I LM12U (http://www.uk-automation.co.uk/products/Marmitek-X10-Lamp-Module-LM12U.html) will do. The picture below shows the LM12U module:
As each appliance module can control a single device, therefore, suppose you have 4 devices to control, you will need to buy 4 units of AM12U.

Step 2: Purchase the Computer Interface CM15Pro


Next is to purchase the computer interface CM15Pro (http://www.uk-automation.co.uk/products/Marmitek-X10-CM15Pro-Computer-Interface-with-Transceiver.html). The picture below shows the CM15Pro computer interface:


The CM15Pro computer interface comes with the power line USB connector which can be plugged into your computer. it also has the ActiveHomePro software which once installed, allows one to control the appliance modules from the ActiveHomePro.

Step 3: Set up CM15Pro and ActiveHomePro 


Step 3.1: Power up the CM15Pro via its power cable. 

Step 3.2: Disable your anti-virus software and install the ActiveHomePro, During the installation, when prompted, plug in the USB cable from the CM15Pro to your computer. Wait for the installation to complete.

Step 4: Set up appliance module.


For each appliance module, configure its address using the two dials in front of the module as shown in the figure below:


It is important that you set each module to a unit address such as "A1", "B3" (where "A" is the House and "1" is the Unit). 

Once configured, plug the device power plug into the module's socket, and then attach the module's plug to any socket at your house.

Step 5: Testing


Suppose you have set up two modules in step 4 with addresses "A1", "B3". On your computer, launch the ActiveHomePro, and then tries the user interface which allows you to switch "A1" ON and OFF. it should work as expected.


Step 6: Download ActiveHome SDK 


Download the ActiveHome SDK from http://tuicemen.com/downloads/ahsdk_install.exe 

Once downloaded, install the adsdk_install.exe

Step 7: Run C# sample codes in the SDK


The ActiveHome SDK comes with a set of C# sample codes which shows you how to turn ON/OFF a device connected to an appliance module. You may notice some error messages while building, if so simple delete the pfx key file which is not needed. Another error that you may encounter is the follow message:

ActiveHomeScriptLib.ActiveHomeClasscannot be embeddedUse the applicable interface instead

If you encounter the above error message, simply change the "Embed Interop Types" of the referenced Interop.ActiveHomeScriptLib.dll to "False" in your VC# project.

You should now compile and successfully run by controlling the "A1" and "B3" device ON or OFF.

Step 8: Write your own C# codes to control.


I have attached here a small sample project which shows user how to control the devices via C# as well as how to obtain the "ON/OFF" status of the devices using C#.
The sample code can be downloaded from : My Sample Codes

My Venture

Below is one of my applications which uses the above technique in its implementation:


Here is the one which remote control via iphone:

No comments:

Post a Comment