ESP8266 Home Automation Projects - Catalin Batrinu - E-Book

ESP8266 Home Automation Projects E-Book

Catalin Batrinu

0,0
27,59 €

oder
-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

The ESP8266 is a low-cost yet powerful Wi-Fi chip that is becoming more popular at an alarming rate, and people have adopted it to create interesting projects.
With this book, you will learn to create and program home automation projects using the ESP8266 Wi-Fi chip. You will learn how to build a thermostat to measure and adjust the temperature accordingly and how to build a security system using the ESP8266. Furthermore, you will design a complete home automation system from sensor to your own cloud. You will touch base on data monitoring, controlling appliances, and security aspects.
By the end of the book, you will understand how to completely control and monitor your home from the cloud and from a mobile application. You will be familiar with the capabilities of the ESP8266 and will have successfully designed a complete ready-to-sell home automated system.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Veröffentlichungsjahr: 2017

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



ESP8266 Home Automation Projects

 

 

 

 

 

 

 

 

 

 

Leverage the power of this tiny WiFi chip to build exciting smart home projects

 

 

 

 

 

 

 

 

 

 

Catalin Batrinu

 

 

 

 

 

 

BIRMINGHAM - MUMBAI

ESP8266 Home Automation Projects

Copyright © 2017 Packt Publishing

 

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

 

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

 

First published: November 2017

 

Production reference: 2091118

Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.

ISBN 978-1-78728-262-9

 

www.packtpub.com

Credits

Author

Catalin Batrinu

Project Coordinator

Kinjal Bari

Reviewer

Constantin Tambrea

Proofreader

Safis Editing

Acquisition Editor

Prachi Bisht

Indexer

Francy Puthiry

Content Development Editor

Eisha Dsouza

Graphics

Tania Dutta

Technical Editor

Naveenkumar Jain

Production Coordinator

Melwyn Dsa

Copy Editor

Safis Editing

About the Author

Catalin Batrinu graduated from the Politehnica University of Bucharest in Electronics, Telecommunications, and Information Technology. He has been working as a software developer in telecommunications for the past 16 years. He has worked with old protocols and the latest network protocols and technologies, so he has experienced all the recent transformations in the telecommunications industry. He has implemented many telecommunications protocols, from access adaptations and backbone switches to high-capacity, carrier-grade switches on various hardware platforms from Wintegra and Broadcom.

The Internet of Things came as a natural evolution for him and now he collaborates with different companies to construct the world of tomorrow, which will make our life more comfortable and secure. Using the ESP8266, he has prototyped devices such as irrigation controllers, smart sockets, window shutters, digital addressable lighting controls, and environment controls, all of them controlled directly from a mobile application via the cloud. An MQTT broker with bridging and a WebSockets server was even developed for the  ESP8266. Soon, these devices will be part of our daily lives, so we will all enjoy their functionality.

Don't forget to then keep an eye on his blog https://myesp8266.blogspot.com and on the new platform as a service that you will discover soon at https://iotcentral.eu.

About the Reviewer

Constantin Tambrea has been a senior software engineer at Luxoft Romania for more than 9 years, and has been involved in various projects in the telecommunications field. He holds master's and bachelor's degrees in Computer Science from University Politehnica in Bucharest. His main domains of interest are Java Enterprise applications and web development techniques, but recently he has become passionate about the Internet of Things domain, in which he is experimenting with a personal home automation project.

 

I would like to give thanks to Catalin Batrinu, my colleague, and friend, for introducing me to the IoT world and for encouraging me to review his work on this book.

www.PacktPub.com

For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.comand as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www.packtpub.com/mapt

Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.

Why subscribe?

Fully searchable across every book published by Packt

Copy and paste, print, and bookmark content

On demand and accessible via a web browser

Customer Feedback

Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https://www.amazon.com/dp/1787282627. If you'd like to join our team of regular reviewers, you can email us at [email protected]. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products!

Table of Contents

Title Page

Copyright

ESP8266 Home Automation Projects

Credits

About the Author

About the Reviewer

www.PacktPub.com

Why subscribe?

Customer Feedback

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Downloading the color images of this book

Errata

Piracy

Questions

Getting Started with the ESP8266

Starting with the ESP8266 chip

Installing Arduino IDE

Downloading the Arduino Software IDE

Configure Arduino IDE

Installing the ESP8266 SDK

How to install a library

Libraries from the Arduino's repository

Library is not in the repository

It is time for your first program

Seeing the result

Connecting ESP8266 to Wi-Fi

Getting data from the internet

Sending data to the internet

Summary

Building and Configuring Your Own MQTT Server

Message Queue Telemetry Transport

Quality of service

Security

Retain messages and last will

Basic terminology

Wildcards on topics

Introducing Mosquitto broker

ESP8266 and MQTT

Publishing data from the ESP8266

Receiving MQTT messages in the ESP8266

Securing Mosquitto

Summary

Building a Home Thermostat with the ESP8266

SPIFFS

SPIFFS objects

Directory object

File object

Temperature sensor

Summary

Control Appliances from the ESP8266

Using the WiFiManager library

Adding parameters to the WiFiManager setup page and saving them into the file

ESP8266 and Infrared communication

Hardware components

Software and libraries for this project

Summary

Using ESP8266 to Build a Security System

Passive infrared sensor

How PIRs work

Testing the PIR module

Connecting the PIR module to the internet

The ESP8266 PIR security code

Summary

Securing Your Data

Enabling encryption on mosquitto

Installing the openssl package

Generating your own certificates

Securing a connection between ESP8266 and an MQTT broker

Working offline

Saving data on the SD card

Summary

Real-Time Communication

WebSockets

Protocol details

Streaming data from ESP8266

ADXL345 accelerometer

Connection to the ESP8266

ESP8266 code

Backend code

Public web page

Summary

Adding a Mobile Application to Your Smart Home

Installing Docker and using containers

Getting the development image

Docker images

Setting up the local broker

ESP8266 code specifications

Summary

Preface

Since the first house was built, man has made a conscious effort to improve it, to make it more comfortable and safe. Home automation or domotics has been around since decades in terms of lighting and simple appliance control and only recently has technology caught up for the idea of the interconnected world, allowing full control of your home from anywhere, to become a reality.

ESP8266 is a low-priced chip that allows you to build home automation system effectively. This book will demonstrate a few easy-to-implement home automation projects ranging from controlling a relay, to reading all kinds of parameters such as temperature, humidity, light, or presence. It also allows you to send the values from your ESP8266 modules to your private cloud. More than that, you will design and build a secure cloud and a mobile application that can bring comfort and safety at your fingertips. By the end of this book, you will be capable of building your own interconnected devices for better living.

There are many choices available in the market and you can choose your own ESP8266 module based on your project needs. Some of the widely accepted home automation projects are building a portable environmental monitor, wireless remote LCD, Air Gesture AC Dimmer/Switch, Wi-Fi Smart Garage Door, IoT Air Freshener, and internet-enabled smoke alarm.

Home automation is definitely here to stay as it continues to fill the needs of consumers who are looking for better ways to access information and control the home environment. With home automation, you can control your device the way you want.

What this book covers

Chapter 1, Getting Started with the ESP8266, covers the basics of the ESP8266 Wi-Fi chip, including how to choose a module, and how to configure the ESP8266 chip. You will learn how to configure the ESP8266 board, so it can be used for the rest of the book. You will know how to choose the right ESP8266 module as there are many choices available on the market. After that, you will learn the basics of the ESP8266 Wi-Fi chip, and learn how to read data from a sensor connected to the chip.

Chapter 2, Building and Configuring Your Own MQTT Server, speaks about building and configuring an MQTT server to be used with the ESP8266. The chapter will instruct you on how to get, compile, install, and configure an MQTT server to be used in the chapters as a central MQTT gateway.

Chapter 3, Building a Home Thermostat with the ESP8266, covers how to build a home thermostat using the ESP8266. You will learn how to measure the temperature in your home using a thermostat, how to display this temperature on a screen, and also how to adjust the temperature according to your wishes.

Chapter 4, Control Appliances from the ESP8266, shows how to control home appliances that are often present in a house, such as lamps, LEDs, and other appliances. You will learn how to control several home appliances using only the ESP8266 Wi-Fi chip. Thanks to the Wi-Fi connectivity of the chip, you will be able to control all the appliances remotely.

Chapter 5, Using ESP8266 to Build a Security System, covers how to build a complete security system based on the ESP8266. You will learn how to connect to your ESP8266 module's elements that are necessary to a security system, such as motion detectors, cameras, and alarms. You will then be able to build a complete security system based on these elements.

Chapter 6,Securing Your Data, This chapter is about adding SSL to secure communication between the ESP8266 modules and broker. You will learn to encrypt the packets in order to secure the data and make sure that your communication remains private.

Chapter 7,Real-Time communication, there are some use cases where you need to see data retrieved from the sensors in real time, to log the values in a database or to show them on a nice graph.

Chapter 8, Adding a Mobile Application to Your Smart Home, to complete the journey in the smart home world and have your house in control from your phone, you will create an Android mobile application.

What you need for this book

In order to start working with ESP8266, you will need a series of software and hardware components. The ESP8266 chip and its module, sensors like ADXL345, temperature sensors, PIR sensors, and cables, soldering tools. In every chapter, I've tried to make a good picture and provide the good description.

For the software, we would require PC with Windows and VirtualBox installed. For application Arduino IDE with at least 1.5.3 SDK version for the ESP8266, Lubuntu Linux 16.04 installed in Virtual Box, Docker installed in Virtual Box, InfluxDB and Grafana installed in Virtual Box.

Who this book is for

This book is for people who want to build connections and inexpensive home automation projects using the ESP8266 Wi-Fi chip, and to completely automate their homes. A basic understanding of the board would be an added advantage.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The following is thesetup()function to connect to the Wi-Fi network."

A block of code is set as follows:

#include <ESP8266WiFi.h>

#include <JsonListener.h>

#include "WundergroundClient.h"

Any command-line input or output is written as follows:

sudo openssl rsa -in ca.crt -out newca.pem

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Click onSign in to network."

Warnings or important notes appear in a box like this.
Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

Log in or register to our website using your e-mail address and password.

Hover the mouse pointer on the

SUPPORT

tab at the top.

Click on

Code Downloads & Errata

.

Enter the name of the book in the

Search

box.

Select the book for which you're looking to download the code files.

Choose from the drop-down menu where you purchased this book from.

Click on

Code Download

.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for Windows

Zipeg / iZip / UnRarX for Mac

7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/ESP8226_Home_Automation_Projects. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/ESP8226HomeAutomationProjects_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.