How to Turn Your House Lights On/Off using Smartphone

What You Need

  • The X10 FireCracker (for communication to the computer) and the TM751 receiver (for the power jack). You can purchase the kit from the X10 website for $24.99.
  • An Apache web server with PHP installed. You can find a tutorial herefor setting up Apache on both Linux and Windows.
  • Light.exe, a program that sends signals over the com. port. Once the signals are received, it then reads and adjusts the light connected to it accordingly. It even has support for dimming lights.

Step 1 Create a Web Interface

After you connect the X10 equipment and have everything installed, with a light connected, we need to create a webpage to host on our server that sends signals over the com. port.

  1. Open up a text editor.
  2. Paste this HTML and PHP code into it.

<html>
<body>
<?php

if(isset($_GET[‘light’])) {
   if ($_GET[‘light’] == “on”) {
      system(“light.exe c1a1+”);
   }
   if ($_GET[‘light’] == “off”) {
      system(“light.exe c1a1-“);
   }
}
?>

<a href=”index.php?light=on”>On</a> /
<a href=”index.php?light=off”>Off</a>

</body>
</html>

3.  Save the document as index.php. Make sure you save it as type “all files”, or you will end up with double file extensions. Throw the index.php file and light.exe into your Apache directory.

Step 2 Enable Port Forwarding

We need to forward the port that Apache runs on so that we can access this webpage from an external network (unless you do not desire to run it away from home).

  1. Click Start. In the search, type cmd and hit Enter. In the prompt, typeipconfig, and it will list your default gateway and IP address. Take note of both.
  2. Go to the router configuration page. The default address is 192.168.1.1. Type that in your browser address bar, or the one you got from the previous step.
  3. Type in your Username and Password for the router. Default is usuallyadmin:password.
  4. Click Port Forwarding somewhere on the page—all of them look different. Here is how mine looked:Mastering Security, Part 2: How to Create a Home VPN Tunnel
  5. For me, I needed to click Port Forwarding on the router page. Set the host to your computer’s IP address that we previously noted, and the port to 80.
  6. Go to What Is My IP Address and write down your IP. This IP is the address that we need to access the site and control the lights.

Step 3 Test the Page

Open up your new webpage and simple click the link that says on to turn the lights on, and off for off.

Source:null-byte.wonderhowto.com

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s