Thank You, Steve Jobs

My parents saved up Campbell’s Soup labels and gave them to my school. For whatever rationale, the school would get computers from Apple based on the number of soup labels collected. We got a lab of Apple II’s, then came along the IIe, IIgs, and finally the Macintosh. I spent most of my early time on the Apple IIe programming. This was a very significant time for me and planted the seeds for my future career in software. I was inspired to create and can’t think of an existence without his influence. While we mourn the loss of a great one, I wanted to say, “Thank you, Steve Jobs.”

“…the people who are crazy enough to think they can change the world, are the ones who do. Think Different.”

– Steve Jobs, 1955-2011

10 PRINT "STEVE JOBS"
20 GOTO 10

Automatic Thermostat Control Based on Location and Weather

The Pittsburgh Perl Workshop will be held at the Carnegie Mellon University on October 9-10, 2010. The PPW is a gathering of Perl programmers from around the world (and near Pittsburgh) to learn more and discuss the future of Perl.

At this year’s PPW, I will be giving a talk called, “Connecting the Internet of Things with Perl“ (visit pghpw.org for schedule info). I will also explain how to create an Internet of Things application using off-the-shelf Perl modules and web control technology by ioBridge.

As you may or may not know, Perl is a really powerful programming language that enables everything from fast prototyping of web applications to large-scale software platforms. What makes the language unique is the library of modules available to you. If you get a great new idea for a web app, you can get started quickly and find modules that others have written. In some cases, it’s literally copy-and-paste.

A big movement for the past few years is this concept of The Internet of Things. More things will be on the Internet than people in the next few years, so my talk is to highlight why Perl is still relevant after 20 years and needs to be apart of this emerging technology. Internet of Things applications involve connecting sensors and controllers to the web. Perl is perfect for parsing lots of data, pushing data into databases, and connecting services together, known as “mashups”.

My Internet of Things project, written in Perl, allows your current location and home weather conditions to control your home heating and cooling system.

Location Aware Home Automation using Google Latitude API and ioBridge API

I call it,  ”Location Aware Home Automation”. You don’t have to do anything to control your HVAC/Thermostat, it all happens based on where you are. If you are home, the thermostat regulates the inside temperature as normal. When you leave, systems turn off or enter power saving modes. When you get near your home, the heating/cooling system kicks back on so you have a comfortable temperature by the time you get back home. In order to pull off all of this passive and automatic functionality, I have mashed up several APIs from Google Latitude, WeatherBug, and ioBridge.

Using the API for Google Latitude, I track the location of my Android mobile phone. When I get near my home, I check the weather using Google Weather API, WeatherBug API, and my home temperature (via ioBridge) to see if I need to to use the air conditioner, the heater, or neither. If I do need to control the HVAC, I send the control commands using the ioBridge API that routes the commands to the IO-204 controller that’s hooked up to my thermostat.

This application is really just a beginning. Right after I got everything working, I started having a flood of ideas. I can see some real power here.

The ‘How To’ Portion of the Show

Google Latitude

You have to enable Google Latitude on your mobile phone and get your Badge ID. This ID represents your position in the world, your latitude and longitude. Visit the Google Latitude API site for more information.

Install the latest Geo::Google::Latitude Perl module from CPAN.org – this module completely abstracts the access to the Google Latitude API for you. All you have to do us pass your ID and the module returns the date, time, last known latitude and longitude (the values are in decimal degrees).

use Geo::Google::Latitude;
my $gl=Geo::Google::Latitude->new;
my $id="7832225593622256926";
my $badge=$gl->get($id);
my ($lat2, $lon2) = $badge->point->latlon;

Calculating how far you are away  from home

You have to figure out how far you are from home, you do this by doing some math. Oh wait, there’s a Perl module for that. Install Geo::Distance and all you have to do is tell it what latitude and longitude to compare and it spits out the distance.

use Geo::Distance;
my $geo = new Geo::Distance;
### Home Location
my $lon1 = "-79.76408";
my $lat1 = "39.980342";
### Calculated Distance
my $distance = $geo->distance( 'mile', $lon1, $lat1 =>; $lon2, $lat2 ); # Use 'meter' to calculate distance in meters

Getting the Weather

You can use a number of weather APIs to get weather data for your home location. All you need to know is where you live. The easiest to implement is Google Weather (Weather::Google), but the WeatherBug API has a lot more information you can use for other Internet of Things things you may do.

 use Weather::Google;
my $gw = new Weather::Google(15401); # Zipcode
my $current_outside = $gw->current->{temp_f}; #Use temp_c for Celsius

Connect to ioBridge

All you have to do to connect with ioBridge is to send command via the ioBridge Widget API. First you create the control widgets for your heating and cooling system. For mine, I can use relays. Others may need serial strings, which you can send as well. Once you have the widgets created, locate there widget ID’s and send them to the API.

use LWP::Simple;
my $Air_Conditioner_widgetID = "Gb2Q1FUKPmzZ"; ### Replace with your widget ID's
my $Heater_widgetID = "9c3WEGHKemnzJ";
my $Inside_Temp_widgetID = "D32SDghy98iOu";
my $ioBridgeAPI = "";
$ioBridgeAPI = "http://www.iobridge.com/widgets/static/id=" . $Inside_Temp_widgetID . "&value=1&format=text";
my $current_inside = get($ioBridgeAPI);
### Test if the heater or the air condition should be turned on
if ($current_outside >= 78 && $current_inside >= 72) {
$ioBridgeAPI = "http://www.iobridge.com/widgets/static/id=" . $Air_Conditioner_widgetID . "&value=1&format=text";
get($ioBridgeAPI);
}
elsif ($current_outside $ioBridgeAPI = "http://www.iobridge.com/widgets/static/id=" . $Heater_widgetID . "&value=1&format=text";
get("$ioBridgeAPI");
}

Putting it all together

Once you have the entire built all you have to do is call the app periodically using CRON Linux or Task Scheduler on Windows. Here is a TXT file of the Perl application with all of the parts tied together, probably will be easier to read and understand.

The hardware side uses the ioBridge IO-204 connected to the control lines of a thermostat or an HVAC control box. The lines switch at 12 volts, so I use relays trigger them. Other thermostats that I researched use serial lines which the IO-204 can tap into using RS-232.

It may seem like a lot of work, but just think about what is happening. Feeds from Google Latitude and WeatherBug are being processed and passed to your home network via the Internet. All of this is happening without your direct interaction – your things are working for you. I hope that you can see that is a start of some pretty amazing applications of technologies that will advance over time. A lot has changed in the past year, I can’t image what comes next.

If you get around to building a project like this, please drop me a line. I love this stuff.

Happy Birthday Jumpman, I mean, “Super Mario”

Today marks Super Mario’s 25th birthday, or the anniversary of the start of the best selling game franchise of all time. Designed by Shigeru Miyamoto, Mario and all of the spin-offs have sold over 240 million game copies.

Super Mario Evolution

Here’s something I learned recently. Super Mario was originally named Jumpman. Do you think the game would have been a big with the name Jumpan? Or should we ask what William Shakespeare asked, “What’s in a name?” Mario got the name because the orginal character looked like Mario Segali, a caretaker at the New York City office where the game was programmed. I read that on the Internets so I knows it to be true.

Mario was the first game that got me into video games, my gateway to Zelda, Final Fantasy, and Tecmo Football. I have a special place for Mario, the sound effects, and the music.

Here’s a list of some things that I learned from Mario:

  • Use your head at all times
  • Turtles should be jumped on or fire-balled although I love turtles
  • Stars make you invincible
  • Mushrooms make you taller
  • Donkey Kong hates barrels
  • If you play the game long enough, you get the girl in the end

Thanks Mario!

New Google Search: Instant Narcissism

If you use Google Search as a lot of people do, then you have noticed the new feature from Google. As you type you get instant search results. It is an interesting feature and I am not sure how much this will change my search patterns. I still want to hit the return button after I type in a search phrase.

For the vain, the new Google Search will allow you to “google” yourself instantly.

Hans Scharler Google Search Vain

Adding Images to EAGLE PCB Layouts

Over at Instructables, I created a tutorial on how to add custom graphics to EAGLE PCB layouts. EAGLE is a very popular layout tool for electronic circuit boards known as PCBs. The tool is powerful but some things are not obvious. We were working on a PCB layout and wanted to add our logo to the design. After spending the afternoon searching around, I finally decided to brute-force the process. I figured it out and now I can replicate the process of adding images to EAGLE. I thought that  I would share what I’ve learned so it will be easier for you.

For this instructable you will need an installed copy of EAGLE and a PCB Layout that you want to add some graphics to. I am using SparkFun’s FT232RL USB-to-Serial Breakout PCB (EAGLE Files) for example purposes.

Adding Custom Graphics to EAGLE PCB LayoutsMore DIY How To Projects

New Gig, Less Hotels

A few months ago, I decided to join ioBridge full-time. I will be leading the software development for a whole bunch of commercial products that license our technology. ioBridge will announce a few major developments in the coming weeks that made this transition possible. I am excited for the new challenges and look forward to working with a start-up company.

My first project with ioBridge was building a remote sensor network web interface on top of the Google Maps API. The sensor network allows for the real-time monitoring of tide levels. The project got written up on MIT’s Technology Review blog and the ioBridge Projects blog. You can demo the tide monitoring application at www.TideAlerts.com.

Change is not always easy. I had a great job and got to see all of the United States minus Alaska, Hawaii, and Idaho (yes, Idaho, I have flown all over you but never landed on you…). I got to design, maintain, pen test, and provide training for some of the largest networks in the US for utilities and telecommunications providers over a 10 year period. Yes, you can blame me the next time your call drops.

This also means I saw a lot of hotels and airports. I probably stayed at a Hampton Inn from 30 different states. I can’t tell you how many times I woke up to a USA Today being crammed under my door. For whatever reason on my first trip to a DSL testing company in Manchester, New Hampshire, I saved the room key. I know you are supposed to return them, but maybe in the excitement of it all, I kept it. This tradition continued with my next project in Lincoln, Nebraska and the next and the next. When I got home I would shove the room key in a box. I just dumped it out and could not believe it…Here’s a photo so you can see what I am saying…

IMG_0059

I don’t advocate stealing room keys, but this pile is  a quick snap shot of 1000’s of trips and projects and experiences. With the new gig, I will travel less and that might be good. I am looking forward to it and might even join a bowling league where I can actually make the games. I will keep you updated on the progress. It’s time to start-up (.com).

Mini Vox Robot Hacking

Yes, I went to Radio Shack today. And, yes, I will still call it Radio Shack. And, yes, sometimes you need a quick electronics fix. I get most of my stuff online these days.

Radio Shack had the Erector Spykee Mini Vox robot on sale for $10. The Mini Vox takes voice commands and makes the robot move, talk, dance, and even fire a “laser.” The box says, “Ages 7+” – I fit that category. The box also says, “Some assembly required.” It should have said, “Some de-assembly required.”

Mini Vox Voice Controlled Robot

While playing with the demo model at the store, I realized that I could reuse the voice commands to set inputs on a microcontroller.

The voice commands go something like this:

“Mini Vox”

Robot beeps

“Forward”

Robot moves forward

Here are all of the commands and their response:

  1. “Forward”DC motors get positive voltage
  2. “Backup”DC motors get negative voltage
  3. “Turn Left”One DC motor gets positive voltage and the other negative
  4. “Turn Right”One DC motor gets positive voltage and the other negative
  5. “Laser War”LEDs flash and RGB LED flashes different colors
  6. “Yo Man”Says “Yo Man” back at you and RGB LED flashes different colors
  7. “Electro Dance” – Makes sounds, LEDs flash, RGB LED flashes different colors, and DC motors pulse on and off
  8. “Destroy Target”Says, “This is my favorite,” makes sounds, flashes LEDs, and RGB LED flashes colors

When I got Mini Vox home, I ripped it apart. I was quite surprised how responsive the voice commands are and how many parts are inside this little robot. Most of the parts are reusable.

Here’s what you get for your $10 investment:

  • Orange LED (x2)
  • RGB LED
  • DC Motor (x2)
  • Motor Driver Circuit Boards (x2)
  • 8 ohm Speaker
  • Microphone
  • Slider Switch
  • Momentary Push Button
  • Lots of screws

Mini Vox Guts

The forward and the back up voice commands are the easiest to tap into. You can disconnect the DC motors and connect them to a digital input of a microcontroller and now you can use voice commands to set the state of 2 digital inputs and act on them.

If I come up with something clever, I will let you know. But, the first piece of my Iron Man suit has fallen into place.