Reader small image

You're reading from  Arduino By Example

Product typeBook
Published inSep 2015
Reading LevelIntermediate
Publisher
ISBN-139781785289088
Edition1st Edition
Languages
Tools
Right arrow
Authors (2):
 Adith Jagadish Boloor
Adith Jagadish Boloor
author image
Adith Jagadish Boloor

Adith Jagadish Boloor was born in Mangalore, India. He grew up tinkering with toys and gadgets that kindled his interest in how things work. His admiration for science and technology, specifically in the fields of robotics, 3D printing, and smart systems, grew into a passion that he is working towards, nurturing it into a career. He completed his higher studies at Purdue University, USA and Shanghai Jiao Tong University, China and is working towards obtaining a masters degree in robotics. Adith has experience working on robots ranging from simple obstacle—avoiding robots built at home to complex humanoid robots such as the Darwin-OP in Purdue University's research lab. He has coauthored a research paper and has two patents on his name. He enjoys traveling and grabs every opportunity he can to explore the different parts of the world. He is also an international chess player.
Read more about Adith Jagadish Boloor

Adith Jagdish Boloor
Adith Jagdish Boloor
author image
Adith Jagdish Boloor

<p>Adith Jagadish Boloor was born in Mangalore, India. He grew up tinkering with toys and gadgets that kindled his interest in how things work. His admiration for science and technology, specifically in the fields of robotics, 3D printing, and smart systems, grew into a passion that he is working towards, nurturing it into a career. He completed his higher studies at Purdue University, USA and Shanghai Jiao Tong University, China and is working towards obtaining a masters degree in robotics.</p> <p>Adith has experience working on robots ranging from simple obstacle—avoiding robots built at home to complex humanoid robots such as the Darwin-OP in Purdue University's research lab. He has coauthored a research paper and has two patents on his name.</p> <p>He enjoys traveling and grabs every opportunity he can to explore the different parts of the world. He is also an international chess player.</p>
Read more about Adith Jagdish Boloor

View More author details
Right arrow

Chapter 6. Home Automation – Part 1

In the previous chapter, you learnt how to merge a wireless camera, a PIR sensor, the Internet, and some of the powerful software with an Arduino to make a high tech security alarm system for your home or office. This time, we will be working on the similar lines. Well, the title has already given it away; we will be creating a home automation system. Before you get into this chapter, take a moment to look back at what you have achieved. You are half way done!

This chapter is going to be really exciting. "Why?", you ask. You are going to control the lights, fans, and other electrical appliances, using your smart phone. In addition to this, we will also be implementing speech recognition! You can literally control your home using your words. Enough of the sales pitch; now, let's get down to business.

For this project, we are going to use a Wi-Fi Arduino shield connected to your home's Wi-Fi network in order to communicate with your smart phone or computer...

Prerequisites


This topic will cover what parts you need in order to create a good home automation system. Obtaining software will be explained as the chapter progresses.

The materials needed are as follows:

  • 1x Arduino UNO board or Arduino MEGA

  • 1x USB cable A to B (also known as the printer cable)

  • 1x CC3000 Wi-Fi shield

  • 1x 5V relay (Arduino compatible)

  • 1x Two-way switch replacement (for your switchboard)

  • 1x Regular type screwdriver

  • 1x Multimeter

  • 1x 9VDC 2A 2.1mm power adapter

  • 1x Wireless router (with accessible settings)

  • 1x Smart phone

  • 1x PC with a microphone

  • 10x Connecting wires

  • 1x 5V 4 Channel relay (optional: Arduino compatible)

  • 4x Two-way switch replacement (depending on the number of relays)

The softwares required are as follows:

  • Putty (terminal)

  • .cmd (iOS)

  • UDP TCP Server Free (Android)

  • BitVoicer (speech recognition)

Note

If you want to control your home with just your smart phone and not use the physical switches, then you do not require the 'two-way switch', but as you go through this chapter, you will...

Connecting the Wi-Fi module


In this case, the Wi-Fi module is the CC3000 shield. Shields are basically ready-to-go modules that can be directly attached to the Arduino with any extra wiring. This makes them quite convenient to use. In this section, you will learn about connecting the Arduino to your home Wi-Fi network and linking it to the Internet.

The CC3000 Arduino shield

This shield is a relatively new means of communication for Arduino. The CC3000 chip is made by Texas Instruments, with the goal to simplify internet connectivity for projects such as the one we are going to make in this and the following chapter.

Connecting the shield to the Arduino is probably the simplest task in this entire book. Make sure the male header pins of the shield align with the female header pins of the Arduino board (UNO or MEGA), and then gently mount them together. You will have something like this:

If you would like to know more about how the chip works, you should refer to this page (at http://www.ti.com...

Using relays to control appliances


Here, we learn what relays are and how they can be used to control everyday electrical/electronic appliances. Also, to make them useful, we will connect them to the Arduino and create a Blink.ino program, except this time it will be your lamp that will be turning on and off.

Understanding the basics of the relay

A relay is basically an electrical device, usually consisting of an electromagnet, which is activated by a passing of current in one circuit to open or close another circuit. You could think of it as a switch that requires current to turn on or off.

Why can't we simply connect a pin of the Arduino to the switchboard, and switch the fan on or off like we do with an LED? Well, an Arduino can output only 2-5V, whereas the fan or any other appliance in your house uses around 200-250V that comes from the electricity grid. This number is different depending on where you are from. Also, we cannot simply connect the Arduino to the switch of the fan because...

Communicating through a terminal


There is one more dilemma that we have to solve in order to have complete control over the electronic appliance. If we create a digital ON and OFF switch that when set to ON sends a turn ON signal to the relay, the problem is that if the physical switch is already ON, the ON signal of the digital switch will end up actually turning OFF the appliance.

"If the appliance is already ON, why would I send a turn ON signal?" Okay, think about this. Both the switch and the relay are ON, but the bulb would actually be off if you look at the two-way switch and the relay image previously shown. Now, if you want to turn ON the bulb through the relay, you actually have to send an OFF signal.

Pretty confusing, isn't it? To solve this, we will use a flag or a status variable that stores the current state of the relay. This will help us solve logical issues such as the one stated before.

Make sure your router is working as expected. Then, plug in the Arduino into the USB port...

Summary


We will be ending this chapter with that. There is a lot more to do, which will be discussed in part 2—the next chapter. What have we learned in this chapter? We have learned a lot about relays, from how they work to how to work with them. We also took considerable time to fully gauge how the relay functions in conjunction with a simple and two-way switch. We also understood why a two-way switch is better for control. We also programmed the Arduino to control a light's switch and built a circuit to achieve the same, with the help of an electrician (or not). Finally, we took it one step higher by adding a communication layer (via terminal).

The next thing on the to-do list is to create a communication layer that allows communication through a smart phone (without a terminal) and also using speech recognition. To spread our wings a little, we will also learn to program more than one appliance, which means only one thing – more relays!

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Arduino By Example
Published in: Sep 2015Publisher: ISBN-13: 9781785289088
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Adith Jagadish Boloor

Adith Jagadish Boloor was born in Mangalore, India. He grew up tinkering with toys and gadgets that kindled his interest in how things work. His admiration for science and technology, specifically in the fields of robotics, 3D printing, and smart systems, grew into a passion that he is working towards, nurturing it into a career. He completed his higher studies at Purdue University, USA and Shanghai Jiao Tong University, China and is working towards obtaining a masters degree in robotics. Adith has experience working on robots ranging from simple obstacle—avoiding robots built at home to complex humanoid robots such as the Darwin-OP in Purdue University's research lab. He has coauthored a research paper and has two patents on his name. He enjoys traveling and grabs every opportunity he can to explore the different parts of the world. He is also an international chess player.
Read more about Adith Jagadish Boloor

author image
Adith Jagdish Boloor

<p>Adith Jagadish Boloor was born in Mangalore, India. He grew up tinkering with toys and gadgets that kindled his interest in how things work. His admiration for science and technology, specifically in the fields of robotics, 3D printing, and smart systems, grew into a passion that he is working towards, nurturing it into a career. He completed his higher studies at Purdue University, USA and Shanghai Jiao Tong University, China and is working towards obtaining a masters degree in robotics.</p> <p>Adith has experience working on robots ranging from simple obstacle—avoiding robots built at home to complex humanoid robots such as the Darwin-OP in Purdue University's research lab. He has coauthored a research paper and has two patents on his name.</p> <p>He enjoys traveling and grabs every opportunity he can to explore the different parts of the world. He is also an international chess player.</p>
Read more about Adith Jagdish Boloor