Book Image

ESP8266 Home Automation Projects

By : Catalin Batrinu, Constantin Tambrea
Book Image

ESP8266 Home Automation Projects

By: Catalin Batrinu, Constantin Tambrea

Overview of this book

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.
Table of Contents (16 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
3
Building a Home Thermostat with the ESP8266
5
Using ESP8266 to Build a Security System
Index

WebSockets


WebSockets is a communication protocol, providing full-duplex messages, streaming on top of a Transport Control Protocol (TCP). It is standardized by the W3 organizations and it is present on all major browsers (Internet Explorer must be at version 11+). WebSockets enables the communication between a browser and a server and between our module and a server. Through the server, the data from the ESP8266 can arrive in a browser. Another big advantage for WebSockets is the bidirectional communication without creating a new request. Every communication is done on the opened TCP connection.

Protocol details

A WebSocket connection starts as an HTTP connection with the request to upgrade to a websocket protocol.

In this case, the client is sending:

GET /chat HTTP/1.1Host: server.example.comUpgrade: websocketConnection: UpgradeSec-WebSocket-Key: t3JJHjbGL5EzHkh8GBMXGw==Sec-WebSocket-Protocol: chat, superchatSec-WebSocket-Version: 13Origin: http://example.com

And if the server is websocket...