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

Choosing an ESP8266 board


The ESP8266 module is a self-contained System On Chip (SOC), which features an integrated TCP/IP protocol stack that allows you to add Wi-Fi capability to your projects. The module is usually mounted on circuit boards that break out the pins of the ESP8266 chip, making it easy for you to program the chip and to interface with input and output devices.

ESP8266 boards come in different forms, depending on the company that manufactures them. All the boards use Espressif's ESP8266 chip as the main controller, but they have different additional components and different pin configurations, giving each board unique additional features.

Therefore, before embarking on your IoT project, take some time to compare and contrast the different types of ESP8266 boards that are available. This way, you will be able to select the board that has features best suited for your project.

Available options

The simple ESP8266-01 module is the most basic ESP8266 board available on the market. It has eight pins, which include four General Purpose Input/Output (GPIO) pins, serial communication TX and RX pins, an enable pin and power pins, and VCC and GND. Since it only has four GPIO pins, you can only connect three inputs or outputs to it.

The 8-pin header on the ESP8266-01 module has a 2.0 mm spacing that is not compatible with breadboards. Therefore, you have to look for another way to connect the ESP8266-01 module to your setup when prototyping. You can use female to male jumper wires to do that:

The ESP8266-07 is an improved version of the ESP8266-01 module. It has 16 pins, which consist of nine GPIO pins, serial communication TX and RX pins, a reset pin, an enable pin and power pins, and VCC and GND. One of the GPIO pins can be used as an analog input pin. The board also comes with a UFL. connector that you can use to plug an external antenna in case you need to boost Wi-Fi signal.

Since the ESP8266 has more GPIO pins, you can have more inputs and outputs in your project. Moreover, it supports both SPI and I2C interfaces, which can come in handy if you want to use sensors or actuators that communicate using any of those protocols. Programming the board requires the use of an external FTDI breakout board based on USB to serial converters, such as the FT232RL chip.

The pads/pinholes of the ESP8266-07 have a 2.0 mm spacing, which is not breadboard- friendly. To solve this, you have to acquire a plate holder that breaks out the ESP8266-07 pins to a breadboard-compatible pin configuration, with 2.54 mm spacing between the pins. This will make prototyping easier.

This board has to be powered from a 3.3V, which is the operating voltage for the ESP8266 chip:

The Olimex ESP8266 module is a breadboard-compatible board that features the ESP8266 chip. As with the ESP8266-07 board, it has SPI, I2C, serial UART, and GPIO interface pins. In addition to that, it also comes with a Secure Digital Input/Output (SDIO) interface, which is ideal for communication with an SD card. This adds six extra pins to the configuration, bringing the total to 22 pins.

Since the board does not have an on-board USB to serial converter, you have to program it using an FTDI breakout board or a similar USB to serial board/cable. Moreover, it has to be powered from a 3.3V source, which is the recommended voltage for the ESP8266 chip:

The Sparkfun ESP8266 Thing is a development board for the ESP8266 Wi-Fi SOC. It has 20 pins that are breadboard-friendly, which makes prototyping easy. It features SPI, I2C, serial UART, and GPIO interface pins, enabling it to be interfaced with many input and output devices. There are eight GPIO pins, including the I2C interface pins.

The board has a 3.3V voltage regulator, which allows it to be powered from sources that provide more than 3.3V. It can be powered using a micro USB cable or Li-Po battery. The USB cable also charges the attached Li-Po battery, thanks to the Li-Po battery charging circuit on the board.

Programming has to be done via an external FTDI board:

The Adafruit Huzzah ESP8266 is a fully standalone ESP8266 board. It has a built-in USB to serial interface that eliminates the need for using an external FTDI breakout board to program it. Moreover, it has an integrated battery charging circuit that charges any connected Li-Po battery when the USB cable is connected. There is also a 3.3V voltage regulator on the board that allows the board to be powered with more than 3.3V.

Though there are 28 breadboard friendly pins on the board, only 22 are useable. Ten of those pins are GPIO pins and they can also be used for SPI as well as I2C interfacing. One of the GPIO pins is an analog pin:

What to choose?

All the ESP8266 boards will add Wi-Fi connectivity to your project. However, some of them lack important features and are difficult to work with. So the best option would be to use the module that has the most features and is easy to work with. The Adafruit ESP8266 fits the bill.

The Adafruit ESP8266 is completely standalone and easy to power, program, and configure due to its on-board features. Moreover, it offers many input/output pins that will enable you to add more features to your projects. It is affordable and small enough to fit in projects with limited space.

There's more…

Wi-Fi isn't the only technology that we can use to connect our projects to the Internet. There are other options such as Ethernet and 3G/LTE. There are shields and breakout boards that can be used to add these features to open source projects. You can explore these other options and see which works for you.

See also

Now that we have chosen the board to use in our project, you can proceed to the next step, which is understanding all the components we will use with Adafruit ESP8266 in this book.