How to Turn Your House Lights On & Off Using the Internet

Jan 3, 2012 09:42 PM

Haven't you ever wanted to live in a futuristic home? I think that homes are headed towards an era where they will be controlled by our computers and smartphones. No longer will you have to find your keys to unlock your door, or wait until you get home to monitor your security, because X10 is here.

X10 allows powerline modules to communicate via the existing 120v AC wiring in your home. Simply plug or wire in an X10 compatible module into your AC supply and it can communicate with any other X10 device in your home, giving you remote control of virtually any light, appliance, or other contraptions that you may have invented. No special costly rewiring is necessary.

X10 has been around since the '70s, so it is a tried and true tested technology. Up to 256 different addresses are available so that means at least 256 different devices can potentially be controlled. X10 hasn't been implemented in homes yet for reasons that I do not know. It's a great technology, and can allow us to do an infinite number of automated tasks in our homes.

Today, Null Byte is going to take a hack at controlling our home lights via our computers with the X10 kit.

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 here for 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.

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.





if(isset($_GET['light'])) {

   if ($_GET['light'] == "on") {

      system("light.exe c1a1+");

   }

   if ($_GET['light'] == "off") {

      system("light.exe c1a1-");

   }

}

?>

On /

Off



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.

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, type ipconfig, 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 usually admin: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.

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. How easy!

Controlling your home via the internet and impressing your friends is well worth the price tag!

Be a Part of Null Byte!

Photo by Thomas Hawk 

Just updated your iPhone? You'll find new Apple Intelligence capabilities, sudoku puzzles, Camera Control enhancements, volume control limits, layered Voice Memo recordings, and other useful features. Find out what's new and changed on your iPhone with the iOS 18.2 update.

Comments

No Comments Exist

Be the first, drop a comment!