Reader small image

You're reading from  Raspberry Pi 3 Home Automation Projects

Product typeBook
Published inNov 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781783283873
Edition1st Edition
Languages
Right arrow
Authors (2):
Shantanu Bhadoria
Shantanu Bhadoria
author image
Shantanu Bhadoria

Shantanu Bhadoria is an avid traveler and the author of several popular open source projects in Perl, Python, Golang, and Node.js, including many IoT projects. When in Singapore, he works on paging and building control systems for skyscrapers and large campuses in Singapore, Hong Kong, and Macau. He has authored and contributed to public projects dealing with control over gyroscopes, accelerometers, magnetometers, altimeters, PWM generators, and other sensors and controllers, as well as sensor fusion algorithms such as Kalman filters. Shantanu's work in IoT and other fields can be accessed on his GitHub account with the name shantanubhadoria. He is also the author of Device::SMBus, a popular Perl library used to control devices over the I2C bus.
Read more about Shantanu Bhadoria

Ruben Oliva Ramos
Ruben Oliva Ramos
author image
Ruben Oliva Ramos

Ruben Oliva Ramos is a computer systems engineer from Tecnologico de Leon Institute, with a master's degree in computer and electronic systems engineering and a specialization in teleinformatics and networking from the University of Salle Bajio in Leon, Guanajuato, Mexico. He has more than 5 years of experience of developing web applications to control and monitor devices connected with Arduino and Raspberry Pi, using web frameworks and cloud services to build the Internet of Things applications. He is a mechatronics teacher at the University of Salle Bajio and teaches students of the master's degree in design and engineering of mechatronics systems. Ruben also works at Centro de Bachillerato Tecnologico Industrial 225 teaching subjects such as electronics, robotics and control, automation, and microcontrollers. He is a consultant and developer for projects in areas such as monitoring systems and datalogger data using technologies (such as Android, iOS, HTML5, and ASP.NET), databases (such as SQlite, MongoDB, and MySQL), web servers, hardware programming, and control and monitor systems for data acquisition and programming.
Read more about Ruben Oliva Ramos

View More author details
Right arrow

Building Netflix's The Switch for the Living Room

On the one day off that we want to rest and be relaxed at home, everything in our house needs to be controlled without standing up or moving something else with our hands. In this case, we are in our living room or any place at home and everything is going on and moving manually, but sometimes, people like to be comfortable, for example, turning on the lights, watering the plants in the garden, opening the garage door, if a person is in front of the door house, we want to know who is ringing the doorbell, send or calling for a service, or sending an SMS to open the door; just with one click, we can do many actions, save our lives, help people have a better mood.

In this chapter, we will build a smart button that can do things automatically for a home automation system. This can be used at home to control our electrical devices...

Setting up the Particle Photon

In this section, we will the board Particle Photon, that is the base and is the main brain of this interesting project. It's based on the Arduino IDE programming software and in the following sections we will learn the architecture and the main parts to configure it for our real application. One of the most important features it has, is the connectivity with Wi-Fi. This is one of the most important points to consider, so we can configure the board as a Wi-Fi Device. We will see more details next.

Getting started

To ready our board, we need to know some important notes about the Particle Photon.

The main brain is a microcontroller and it's inside the board. It works as an Arduino board...

Hardware and software requirements

To build this project, we need the following materials:

  • Particle Photon
  • Momentary Arcade button
  • 5 mm IR LED 940 nm
  • Transistor NPN (BC547)
  • 3.7 volts 1000 mAh LiPo battery
  • LiPo battery charger
  • 4.7K Ohm resistor
  • Philips Hue lamp with a wireless bridge

Hardware configuration

In the following figure, we have the connections made with the Particle Photon, with the push button, and the IR infrared LED connected with the transistor:

The architecture of the home automation system

In the following figure, we show the elements that integrate the home automation system:

  • First, we have the Particle Photon that sends the signal when the button is pressed via the infrarred sensor connected to the board.
  • The TV sensor (IR receiver sensor) receives the coded signal and turns on the TV and enables the Netflix system
  • All the systems are connected to a home Wi-Fi network (Particle Photon and bulbs are also connected to the network)
  • Also, when the button is pressed, the lights will be on or off
  • The control of the system is based on the Particle Photon through the infrared sensor when the button is pressed
  • All the devices connected to the system can be controlled from the main board, and the main software is created according to the devices and services we want to execute or send data
...

Reading IR signals

In this section, we will explain how code signals are sent to the TV; the following code is made for a TV recommended for Netflix that has a button to enable Netflix; in this case, you can use any remote control. In this project, we will use a Philips TV in order to do that, we can start turning on your TV and start Netflix in one swift motion, you'll need to send the same IR signal as the Netflix button on your TV remote. If you're not using a TV with a Netflix button or if you have an older TV, this may involve pressing more than one button, and you'll need to adjust accordingly.

We will get the IR signals to read them. We used an IR receiver and an Arduino.

Sensor IR receiver

We need to...

Programming the button

We're are programming a Netflix TV remote control, and we see the code for testing the sending signals from the Particle Photon to the TV.

Testing the code for remote control for a Netflix TV

In the following sketch, we show an example of programming the button:

//Before using, make sure you get your IR timings and add your hue bridge IP/dev username in the appropriate places.

//To keep it as simple as possible, this does not contain any code for the optional LEDs on the case. We light up our indicators and logo after the button is pressed.

TCPClient client;

#define PIN_IR A0
#define PIN D0
#define NUM_PULSES 68

//specific to your TV
int pulse_widths[NUM_PULSES][2] = {
{62116, 8860}, {4360, 540}, {520...

Assembling the electronics

Now we will look at the hardware part; this is to help us build our circuit. First, we need to do this in a breadboard and then solder the materials.

The circuit to be built

This the final circuit of the project, and it can be used to put it; first in a breadboard and then to be used as a prototype:

The final circuit

In the following figure, we can see the circuit that can be soldered according to the project:

The circuit layout

...

Controlling smart lights

In this section, we will describe the important steps to follow in order to configure the devices to control the lights with the button.

Getting started

In the following steps, we will look at how to configure our bridge device to receive commands and set up the lights to control them.

In the following sections, we will look at the steps to configure the bridge device and the API for the connected devices in order to connect them to the network; this information can be found at https://developers.meethue.com/documentation.

Step 1

First we need...

Sending notifications with IFTTT

The Particle channel on IFTTT will let you connect your devices to other powerful channels. You can now easily send and receive tweets, SMS, check the weather, respond to price changes, monitor astronauts, and much, much more. This page is a reference for you to use as you get your Particle Recipes set up.

Parts of an IFTTT

The following are the parts of IFTTT:

  • Triggers: Trigger can be as conceptually simple as "Is x greater than 5?" or "Did I get the new e-mail?"
  • Actions: Actions are what IFTTT does when the answer to your trigger question is yes! When set up, you can have IFTTT email you, post for you, save information to Dropbox, and many other useful functions.
  • Recipes...

Future ideas for projects

For future projects and when talking about IoT projects, in this section, we will show how we can develop an automatic system. To implement this, we will see the following diagram:

According to the following architecture, we will explain the steps that the system will perform and how it can be integrated into future ideas and projects using wireless devices and can be applied to real situations:

  • The main brain of the system is still the Particle Photon; it connects to a wireless network.
  • It connects to an access point built with an ESP8266, and it can be implemented with this feature. Some of the commercial products have a wireless module inside; in this case, we can develop our own device in order to connect other devices with a small device.
  • The device nodes are configured as clients; in their pins, we configure and install a relay module, as shown...

Summary

In this chapter, we built an interesting project for a home automation system that can be implemented at home. In the first part, we talked about the Particle Photon, how to set up the board, and some important characteristics of Particle Photon.

Then, we connected the board to its framework and looked at an example. After that, we created a project to have control over electrical devices or other devices at home. We created a smart button that can send notifications and have control over the things at home. The first part of the project was to decode the signals that we sent to the TV; for that, we used an Arduino UNO to decode. For the last part, we made a proposal to use, with the same architecture of the system, some devices such as ESP8266 to send and control our devices in a local network.

In the next chapter, we will build an interesting project using a smart camera...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Raspberry Pi 3 Home Automation Projects
Published in: Nov 2017Publisher: PacktISBN-13: 9781783283873
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
Shantanu Bhadoria

Shantanu Bhadoria is an avid traveler and the author of several popular open source projects in Perl, Python, Golang, and Node.js, including many IoT projects. When in Singapore, he works on paging and building control systems for skyscrapers and large campuses in Singapore, Hong Kong, and Macau. He has authored and contributed to public projects dealing with control over gyroscopes, accelerometers, magnetometers, altimeters, PWM generators, and other sensors and controllers, as well as sensor fusion algorithms such as Kalman filters. Shantanu's work in IoT and other fields can be accessed on his GitHub account with the name shantanubhadoria. He is also the author of Device::SMBus, a popular Perl library used to control devices over the I2C bus.
Read more about Shantanu Bhadoria

author image
Ruben Oliva Ramos

Ruben Oliva Ramos is a computer systems engineer from Tecnologico de Leon Institute, with a master's degree in computer and electronic systems engineering and a specialization in teleinformatics and networking from the University of Salle Bajio in Leon, Guanajuato, Mexico. He has more than 5 years of experience of developing web applications to control and monitor devices connected with Arduino and Raspberry Pi, using web frameworks and cloud services to build the Internet of Things applications. He is a mechatronics teacher at the University of Salle Bajio and teaches students of the master's degree in design and engineering of mechatronics systems. Ruben also works at Centro de Bachillerato Tecnologico Industrial 225 teaching subjects such as electronics, robotics and control, automation, and microcontrollers. He is a consultant and developer for projects in areas such as monitoring systems and datalogger data using technologies (such as Android, iOS, HTML5, and ASP.NET), databases (such as SQlite, MongoDB, and MySQL), web servers, hardware programming, and control and monitor systems for data acquisition and programming.
Read more about Ruben Oliva Ramos