Book Image

ESP8266 Internet of Things Cookbook

By : Marco Schwartz
Book Image

ESP8266 Internet of Things Cookbook

By: Marco Schwartz

Overview of this book

The ESP8266 Wi-Fi Module is a self contained System on Chip (SOC) with an integrated TCP/IP protocol stack and can give any microcontroller access to your Wi-Fi network. It is capable of either hosting an application or offloading all Wi-Fi networking functions from another application processor. This book contains practical recipes that will help you master all ESP8266 functionalities. You will start by configuring and customizing the chip in line with your requirements. Then you will focus on core topics such as on-board processing, sensors, GPIOs, programming, networking, integration with external components, and so on. We will also teach you how to leverage Arduino using the ESP8266 and you'll learn about its libraries, file system, OTA updates, and so on. The book also provide recipes on web servers, testing, connecting with the cloud, and troubleshooting techniques. Programming aspects include MicroPython and how to leverage it to get started with the ESP8266. Towards the end, we will use these concepts and create an interesting project (IOT). By the end of the book, readers will be proficient enough to use the ESP8266 board efficiently.
Table of Contents (15 chapters)
ESP8266 Internet of Things Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
Index

Required additional components


To demonstrate how the ESP8266 works, we will use some additional components. These components will help us learn how to read sensor inputs and control actuators using GPIO pins. Through this you can post sensor data to the Internet and control actuators from Internet resources, such as websites.

Required components

The components we will use include:

  • Sensors:

    • DHT11

    • Photocell

    • Soil humidity

  • Actuators:

    • Relay

    • Power switch tail kit

    • Water pump

  • Breadboard

  • Jumper wires

  • Micro USB cable

Sensors

Let's discuss the three sensors that we will be using.

DHT11

The DHT11 is a digital temperature and humidity sensor. It uses a thermistor and capacitive humidity sensor to monitor the humidity and temperature of the surrounding air, and produces a digital signal on the data pin. A digital pin on the ESP8266 can be used to read the data from the sensor data pin.

Note

The DHT11 sensor is not very precise, but it is perfect for experimenting, which we'll be doing in this book.

Photocell

A photocell is a light sensor that changes its resistance depending on the amount of incident light it is exposed to. They can be used in a voltage divider setup to detect the amount of light in the surroundings. In a setup where the photocell is used in the VCC side of the voltage divider, the output of the voltage divider goes high when the light is bright and low when the light is dim. The output of the voltage divider is connected to an analog input pin and the voltage readings can be read:

Soil humidity sensor

The soil humidity sensor is used for measuring the amount of moisture in soil and other similar materials. It has two large exposed pads that act as a variable resistor. If there is more moisture in the soil, the resistance between the pads drops, leading to a higher output signal. The output signal is connected to an analog pin from where its value is read.

Note

This sensor is mainly used for demonstration purposes, but it is perfect for the projects we'll do in this book.

Actuators

Let's discuss the actuators.

Relays

A relay is a switch that is operated electrically. It uses electromagnetism to switch large loads using small voltages. It consists of three parts: a coil, spring, and contacts. When the coil is energized by a high signal from a digital pin on the ESP8266, it attracts the contacts, forcing them closed. This completes the circuit and turns on the connected load. When the signal on the digital pin goes low, the coil is no longer energized and the spring pulls the contacts apart. This opens the circuit and turns off the connected load:

Power switch tail kit

A power switch tail kit is a device that is used to control standard wall outlet devices with microcontrollers. It is already packaged to prevent you from having to mess around with high voltage wiring. Using it, you can control appliances in your home using the ESP8266:

Water pump

A water pump is used to increase the pressure of fluids in a pipe. It uses a DC motor to rotate a fan and create a vacuum that sucks up the fluid. The sucked fluid is then forced to move by the fan, creating a vacuum again that sucks up the fluid behind it. This in effect moves the fluid from one place to another:

Breadboard

A breadboard is used to temporarily connect components without soldering. This makes it an ideal prototyping accessory that comes in handy when building circuits:

Jumper wires

Jumper wires are flexible wires that are used to connect different parts of a circuit on a breadboard:

Micro USB cable

A micro USB cable will be used to connect the Adafruit ESP8266 board to the computer:

See also

Having understood the components that you are going to use with Adafruit ESP8266, you can now proceed to the next step and learn how to upload sketches to your ESP8266.