Posted: March 2nd, 2010 | Author: Rob Lynch | Filed under: Computers, Tech, What I'm Doing | Tags: cron, diy, laptop, lego, liux, ubuntu, webcam | No Comments »
Lego Digital Picture Frame
The guts of an old laptop
Ubuntu 9.10 Karmic Koala (linux distro)
Screenlets (widget software)
A handful of cron jobs
Motion (motion detection software)
a USB Webcam
and a bucket of Legos makes a…
Lego Internet Thingy!
It displays the time, local weather, news, twitter and latest emails via Screenlets.
The Motion software uses the webcam to look for movement or changes in lighting allowing the screen to shut off when not home or asleep.
A daily alarm is scheduled via crontab which shuffles through my iTunes library music to wake me up in the morning. If Motion detects movement the music stops.
Posted: January 3rd, 2010 | Author: Rob Lynch | Filed under: Computers, General, Scripts, Tech, Web, What I'm Doing | Tags: apache, automation, cm17a, hak.5, lighting, mysql, php, remote control, sql, x10, xp | 2 Comments »
I recently got my hands on an X10 Firecracker Kit to control my appliances and lighting remotely in conjunction with automating certain daily routines such as turning on an air purifier, air conditioner or a space heater.
Below is simplistic approach I took to setting up a basic wireless remote system that is accessible via the net. It’s a result of a few hours work and is fully functional, but is far from complete Anyone looking to do this should have an intermediate understanding of how Windows, Apache, PHP and SQL work. I based the foundation of this system off of a project featured 4 years ago on Hak.5: How to control your lights from an internet enabled cell phone (Episode Video) (Project Wiki). I augmented the project by incorporating a mysql database for keeping track of appliance status and swapped out the undocumented, executable that talked to the firecracker with one that actually explained the syntax. In part two I’ll take on the automation aspect of the project.
What to use:
What to do:
1. Setup and configure the Firecracker as recommended by X10. Hook up the COM port module, install, configure and test with X10 software to confirm everything is working out of the box.
2. Stop the x10 Device Network Service (x10nets) and set the service status to disabled or manual to free up the COM port.
3. Download Adam Brigs’ CMA17 Protocol and attempt to turn on/off devices with it from the command line. The syntax is very simple and allows for multiple devices to react within one call. For example to turn on appliance 1 on channel A using COM 1 you would type: cm17a 1 a1on
4. Install and configure Wamp server adjusting the httpd.conf to your liking to allow access to the server from other IPs. If allowing access via the web as a minimum set up basic authentication with .htaccess.
5. Using phpMyAdmin in Wamp create a database called “x10″ and be sure to create a user with sufficient privileges to read/write or add a password to the root account.
6. Insert a table called appliance_status (download sql table structure and example records)
7. Modify or add records to appliance_status.
uid = unique identifier
appliance_id = x10 receiver id number and frequency
status = If device is on of off (bool 0 = off 1 = on)
last updated = last request sent to server (self updating current timestamp)
appliance_name = friendly appliance name
8. Copy code to x10.php and place in www directory. Be sure to adjust the first set of variables values as necessary ($cm17a, $comport,$ dbhost,$dbuser,$dbpass).
<title>X10 iPhone Remote</title>
<meta name=”viewport” content=”width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;” />
<link rel=”apple-touch-icon” href=”/iphone.png” />
<link media=”only screen and (max-device-width: 480px)” href=”/iphone.css” type= “text/css” rel=”stylesheet” />
$comport = ’1′;
$cm17a = ‘c:\wamp\www\cm17a’;
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (‘Error Connecting to mysql’);
$dbname = ‘x10′;
system($cm17a . ‘ ‘ . $comport . ‘ ‘ . $_GET['App'] . $_GET['ChangeStatus']);
if($_GET['ChangeStatus'] == ‘On’)
$updatesql = “update appliance_status set status = ” . $UpdateStatus .” where appliance_id = ‘” . $_GET['App'] . “’”;
$get_apps = mysql_query(“SELECT * FROM appliance_status”);
while($row = mysql_fetch_array($get_apps))
$aID = $row['appliance_id'];
$aName = $row['appliance_name'];
if ($row['status'] == ’0′)
$aDate = $row['last_updated'];
echo ‘<tr><td><font size=”10px” face=”geneva, arial, san serif”>’ . $aName . ‘</font></td><td><a href=”?ChangeStatus=’ . $aChange . ‘&App=’ . $aID . ‘” ><img src = “/’ . $aChange . ‘.jpg” width =”75? border = “0? </a></td></tr>’;
9. Add on and off jpegs to www directory (download buttons.zip)
10. If all is well you should be able to navigate to the x10.php and turn on and off your appliances till the cows come home. Enjoy.
Posted: November 30th, 2009 | Author: Rob Lynch | Filed under: General, What I'm Doing | Tags: diy, iphone, lego | No Comments »
While home for Thanksgiving my mom dug out ton of Legos from under the eves for me. I took a container of them back to Boston in hopes of putting them to good use.
My first of hopefully many Lego doodads: The iPhone Dock
Lego iPhone Dock