Build

How I Built an Arduino Controlled House Model (Part 1)

4 min read Michael Carroll on Nov 25, 2014

This is the first part of a two part series documenting how I built an Internet of Things model house powered by PubNub. Read Part Two here.

Back in September, our founder Stephen and I were talking about ways to make it easier to demonstrate how PubNub could power the Internet of Things. Conference attendees often ask if we are a “hub,” a bluetooth device, etc. In reality, we’re a data stream network; a service similar to a CDN that provides a simple and reliable way for IOT devices to talk to each other.

Inside the Arduino Internet of Things Model Home from PubNub on Vimeo.

I decided instead of telling people people what PubNub is, we should show them. If I handed you a mobile phone and told you to press a button and then a garage door opened, you would understand that the phone sent a message to the garage door.

How did it send the message? That’s PubNub.

Arduino Controlled House

So I built the garage door, and a front door, and some lights, and a house, and a mobile app, and I recorded every minute of it. You can check out that video below:

I chose a house because the Internet of Things and home automation go hand in hand. In this case, the house is a single IoT device that represents any number of devices.

I started by looking for a suitable “house.” Originally the idea was the have the house fold down so it could be packed and shipped around to conferences. This lead me to believe laser cutting was the best option, because the “snap fit” ability is not only sturdy, but portable.

I eventually stumbled upon this CAD file of a house from “The Simpsons.” It was extremely well designed and only $15. I took a 2 hour lesson here at ATX Hackerspace and learned how to use the laser cutter. A couple days later my roommate came home with some extra Eucaboard.

I wasted half of the board because Corel Draw determines scaling settings when each file is opened. Apparently I cut all 4 laser files at different scales, so none of the pieces fit together! Once I figured this out I had a clean cut; the opening shot in the video.

From there I needed to glue the smaller parts like the windows and chimney. No need to set these up on the road.

It turns out gorilla glue is extremely messy because it expands over time. This created a bunch of huge solid glue globs that completely ruined the aesthetics of the house. I used a dremel to cut away at the excess glue. It took me a while but I definitely leveled up my dremel skills.

Then I started prototyping. I used an Arduino Uno Rev 3 and an ethernet shield to get up and running fast. I started with a breadboard, LEDs, and used electrical tape to test mounting the servos.

Hooking Up PubNub

Everything checked out so I started to hook it up to PubNub. We have drivers for Arduino which made it really easy.

I used a Seed Studio Ethernet Shield v2 to provide an internet connection to the IOT house. I didn’t have an Ethernet port around, so I was using my Macbook’s Internet Sharing setting to share the WiFi network connection to the Arduino. There were some slight modifications I needed to make for the SS v2 drivers to work with our v1 library (a full post about this fix coming later).

I opted to use a key value syntax to process messages. As you can see in the video, it was as simple as “garage:0” or “lightLeft:1” to close the garage and turn the left light on.

When I verified that this worked correctly I soldered everything into a separate board that could be mounted inside the house.

Looking back now, this board should have been a “prototype shield” for Arduino but at the time I thought it would be so simple that it wouldn’t require an entire shield. This was a mistake, and there are now 7 extra wires that would have been unnecessary with a shield.

I built a simple UI in a CodePen to publish PubNub messages on the same channel the house was listening to. I then mounted the LEDs in the house, drilled mounts for the servos and connected them to doors, and mounted the circuit board and the Arduino + Ethernet shield to the house.

It worked!…

About half of the time.

There was something really strange about the behavior. I would have a great connection to PubNub and everything would work… then suddenly it was completely broken. I noticed that something was amuck, and I suspected it was the internet connection.

I dug down into the network, spending many hours looking at WireShark for hints and configuring the WiFi network.

I tried things like assigning an IP address to the Arduino, making sure the MAC address was correct, and even ordering a second Ethernet shield from a different manufacturer and switching from driver-supported USB to native Thunderbolt sharing. Eventually I was able to isolate the problem.

Whenever I opened the garage door, the ethernet shield would reset. I laughed, in what other situation could opening your garage door possibly destroy your internet connection?

Find the conclusion to our epic IOT house story on the PubNub blog here!

0