Introduction: Arduino-controlled Smart Home

This Instructable was written by PubNub Evangelist Ian Jennings. Ian's story walks through his process of building an Arduino-controlled smart home model from scratch.

--

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.

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.

The full code and technical walkthrough is available here.

Step 1: Project Overview

Step 2: How Will We Signal to the House?

Picture of How Will We Signal to the House?

That's where PubNub comes in. I used PubNub for all communication and messaging. PubNub is a Data Stream Network that enables you to signal (locally or remotely) Arduino actions in realtime. If you're not familiar with PubNub, you can read more about it here.

Step 3: IoT and Home Automation Go Hand in Hand

Picture of IoT and Home Automation Go Hand in Hand

I chose to build an IoT 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.

Step 4: Laser Cutting the Model House

Picture of Laser Cutting the Model House

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.

Step 5: Assembling the Model

Picture of Assembling the Model

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.

Step 6: Implementing PubNub for Connectivity

Picture of Implementing PubNub for Connectivity

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.

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.

Step 7: Prototype Shield

Picture of Prototype Shield

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.

Step 8: Internet Connectivity

Picture of Internet Connectivity

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?

Step 9: Wiring the Servos

Picture of Wiring the Servos

It turns out that I had wired the servos incorrectly. In fact, searching the Arduino forums led me to believe this is a common mistakes hobbyists make. The problem is when the servos need to bear load, they require more power. This explains why the problem was apparent when the house was fully wired, but not when the servos were rolling around on my desk.

Step 10: Arduino Board Limiters

Picture of Arduino Board Limiters

Arduino board has limiters in place that prevent you from drawing too much power through the board (and frying it). Every time the garage door opened, the servos were drawing all the current, not leaving enough for the Arduino and Ethernet shield to properly function.

I tested my theory with a few external power supplies. When I verified it fixed the problem, I wired in the battery pack you can see in the video.

Step 11: Wrapping Up

Picture of Wrapping Up

Working on this project was incredibly difficult yet also very fulfilling. I don’t have any formal electrical engineering experience, I’m a web developer by trade. I haven’t learned this much this fast since graduating college.

I was working extremely long days to meet the deadline. I would spend the entire morning just shopping for the right components, screws, glue, or paper. Then I would work, sometimes until 3 or 4am, getting everything together.

Thankfully Arduino makes things simple and I had a great network of people who helped me each step along the way. Alex, in particular was extremely helpful with electronics and another member of the space, Riley, spent on late Friday supplying me with every tool and component I needed during assembly like a surgeon’s assistant.

The IoT house is on display at the ground level office at 725 Folsom in San Francisco. It will also be displayed at upcoming IOT conferences which will be announced on our blog. If you would like me to give a talk about building IOT house at your conference, you can reach me at ian@pubnub.com.

This is an overview of the project as a whole. Stay tuned for future tutorials on the nitty gritty of building out the project.

Comments

Sudden_ (author)2017-05-30

The name PubNub sounds (and looks) a little too close to a certain popular adult entertainment website. You may want to consider changing the name.

Sudden_ (author)2017-05-30

Wow so many bot comments asking for you to email them. I bet they'll want to deposit money into your bank account for a Nigerian prince too.

RubineR (author)2017-04-04

HI,
I NEED YOUR HELP ON BLUETOOTH HC 05 CAUSE IM USING ARDUINO AND BLUETOOTH FOR MY SMART HOME...PLEASE EMAIL TO ME CAUSE I NEED SOME GUIDE ON DOING THE PROGRAM TQ...RUBINERX68@GMAIL.COM

MohammadA71 (author)2017-03-17

Sir,please send me the coding

mohammad.abdaljawwad@gmail.com

thank you so much

vinniep5 (author)2017-03-16

Sir my topic is smart home by using arduino and gsm module.. !!
I made door locking system and i want add lights,fan, coffee maker etc.. but i don't have any idea.. so plz help me.. and i need coding

vasan93 (author)2017-02-24

Hi bro . Good afternoon . The title I mentioned above do have any arduino coding . Because i need to learn basic coding house electrical appliances control by smartphone . My title is development of smart home system by smartphone

chaggy (author)2017-01-24

Sir,please send me the coding

med.iheb.chagour@gmail.com

thank you so much

SuparDuparr (author)2016-12-12

Sir is it possible if you make a smart home with arduino GSM module? And also to control the water system like faucet using servo motor?

jiajia.chen.923 (author)2016-09-12

Cool!

Can you please send me the codes to this project.

chenjengjia@gmail.com

https://www.codeproject.com/articles/855501/how-to-build-an-arduino-powered-smart-home

UsmarI (author)2016-09-16

great!!

sir, please send me the codes for this project

I'm doing some research for my project

usmarismmm@gmail.com

ianjennings (author)UsmarI2016-11-30

https://www.codeproject.com/articles/855501/how-to-build-an-arduino-powered-smart-home

HebaS5 (author)2016-10-11

Can you please send me the codes to this project

88.hiba@gmail.com

ianjennings (author)HebaS52016-11-30

https://www.codeproject.com/articles/855501/how-to-build-an-arduino-powered-smart-home

JayN39 (author)2016-09-16

The best ever!! i want to make it for my thesis :)
Can you please send me the codes for this project. thanks!
jaylordnikkogonzales01@gmail.com

HebaS5 (author)JayN392016-10-11

Can you please send me the codes to this project

88.hiba@gmail.com

ianjennings (author)HebaS52016-11-30

https://www.codeproject.com/articles/855501/how-to-build-an-arduino-powered-smart-home

ianjennings (author)JayN392016-11-30

https://www.codeproject.com/articles/855501/how-to-build-an-arduino-powered-smart-home

EyadS1 (author)2016-10-21

that's awesome ! can you send me the codes please. thanks !
eyadishfk@gmail.com

ianjennings (author)EyadS12016-11-30

https://www.codeproject.com/articles/855501/how-to-build-an-arduino-powered-smart-home

IrfanT5 (author)2016-10-25

Hi,

Could you pls send the codes and the documentation of the project , its irfanmedia@gmail.com

I would appreciate if you can send me all the details.

thx.

Irfan.

ianjennings (author)IrfanT52016-11-30

https://www.codeproject.com/articles/855501/how-to-build-an-arduino-powered-smart-home

Mineyayla20 (author)2016-10-28

Could you please send me the codes to this project ?
mineyayla20@gmail.com

ianjennings (author)Mineyayla202016-11-30

https://www.codeproject.com/articles/855501/how-to-build-an-arduino-powered-smart-home

Aijeleths (author)2016-10-30

Wow! pubnub is Great for IOT!

could you please send me the platform, codes and instructions on how to get this up and running?

shaharaijeleth@gmail.com

ianjennings (author)Aijeleths2016-11-30

https://www.codeproject.com/articles/855501/how-to-build-an-arduino-powered-smart-home

SalvatoreC20 (author)2016-10-30

Hi,i'm a newbie of arduino. Can you please send me the platform,codes and any instructions? my email is salvatoreciaramitaro12@gmail.com

ianjennings (author)SalvatoreC202016-11-30

https://www.codeproject.com/articles/855501/how-to-build-an-arduino-powered-smart-home

deffaf1 (author)2016-10-30

could you please send me the platform, codes and instructions on how to get this up and running?

deffaf.ibrahim@gmail.com

ianjennings (author)deffaf12016-11-30

https://www.codeproject.com/articles/855501/how-to-build-an-arduino-powered-smart-home

kubixdesign (author)2016-11-12

awsome project !! i want to make it for my thesis :)

Can you please send me the codes for this project. thanks!

dhaou_jawher@hotmail.com

ianjennings (author)kubixdesign2016-11-30

https://www.codeproject.com/articles/855501/how-to-build-an-arduino-powered-smart-home

John SethS (author)2016-11-12

Please send me the codes. salazarjohnseth@gmail.com

ianjennings (author)John SethS2016-11-30

https://www.codeproject.com/articles/855501/how-to-build-an-arduino-powered-smart-home

ianjennings (author)2016-11-30

There is a detailed walkthrough available at codeproject:

https://www.codeproject.com/articles/855501/how-to-build-an-arduino-powered-smart-home

Asher the Engineer (author)2016-09-10

Great Job!!

Can you please send me the codes to this project.

asher.nizamani@gmail.com

jodramirez (author)2016-08-21

Please send me the code for this project

jodi.ramirez@edinaschools.org

HaHa777 (author)2016-08-11

please send me code for this project

thansoehein@gmail.com

anooooos (author)2016-08-11

Very good

TarekM2 made it! (author)2016-07-17

my G.T

sobos (author)TarekM22016-07-18

good jop

SamanN4 (author)2016-06-25

pls send me the code for this project

nazeri.sami@gmail.com

BrunoM126 (author)2016-05-03

pls send me the code for this project

ricardo.tarijon@gmail.com

thanks :)

Thememo (author)2016-04-30

pls send me the code for this project

mzerenoglu@gmail.com

thanks :)

hameed_94 (author)2016-04-29

Hello! Can you email the coding and other documentation for this project? Thank you so much!

hameed123.1234@gmail.com

UğurT5 (author)2016-04-26

Can you email the coding and other documentation for this Project ? Thank you so much...

tutal2002@gmail.com

SoumayaG (author)UğurT52016-04-29

can i know if you ever got that coding ?

Meredith YuhanX (author)2016-04-14

Hello! Can you email the coding and other documentation for this project? Thank you so much!

yuhan8@uw.edu

medofadel100 (author)2016-03-21

Please send me the coding for this project.

medofadel100@gmail.com

AzrulR2 (author)2016-03-16

hye can you email the coding and other documentation for this project? thanks

azrul5090@gmail.com

About This Instructable

81,610views

670favorites

Bio: Most of us are lucky if we can even afford to buy the latest techno-gadget. But Williamsburg-based hacker Ian Jennings is actually the one inventing ... More »
More by ianjennings:Realtime Temperature Sensor and DashboardArduino-controlled Smart Home
Add instructable to: