The first thing we will tackle is the functionality of the ESP8266. We will look at the features and functions of the ESP8266, and learn about all the available GPIO pins and how we can use them to read and write digital signals.
The ESP8266 chip provides a self-contained, standalone Wi-Fi networking solution that allows you to host applications and to provide a Wi-Fi network that you can use to transfer data and instructions in your projects.
In normal use, the ESP8266 boots up directly from an external flash memory. It also has a cache that improves the performance of the system and reduces the amount of memory needed during operation.
The ESP8266 can also be used as a Wi-Fi adapter. In this case, the chip provides wireless Internet access to a microcontroller-based project through either the CPU AHB bridge or UART interface.
The on-board processing and storage capabilities of the ESP8266 enable easy integration with sensors and other devices via the GPIO pins. Moreover, the ESP8266 requires little to no external circuitry because of its on-chip integration, which includes power management converters and antenna switch balun. This makes it small and ideal for compact projects.
In addition to all those features, the ESP8266 has some sophisticated system-level features that include adaptive radio biasing for low-power operation, energy-efficient VoIP due to rapid sleep/wake switching, advanced signal processing and radio co-existence, and spur cancellation features that prevent cellular and Bluetooth interference.
The main features of the ESP8266 can be listed as:
To understand the ESP8266 pin configuration, we are going to look at the ESP-12 module. This is because it is the same module that is used on the Adafruit feather HUZZAH ESP8266 Wi-Fi board that we are using for our exercises, as explained in Chapter 1, Configuring the ESP8266. The following diagram shows the ESP-12 pin configuration:
The ESP-12 module pins are connected to a more breadboard-friendly pin configuration on the Adafruit ESP8266 board. The pin configuration of the Adafruit board is shown in the following diagram:
The pins on the Adafruit ESP8266 module can be grouped into several categories.
The serial pins are labelled RX (receive) and TX (transmit). Note that those pins can also be used for I2S communications. They are used for serial communication and boot loading. The RX pin is the input pin and is 5V compliant, since it has a level shifter. The TX pin is the output from the module and has a 3.3V logic. The two pins are connected to the CP2104 USB to serial converter and should be left disconnected unless you really want to use them.
The ESP8266 module comes with both I2C and SPI interfaces, which enable you to communicate with sensors, outputs, and devices that use these interfaces. Though this is done through bitbanging, it works just as well as it does on the Arduino.
Hypothetically, any GPIO pin on the ESP8266 can be used for I2C and SPI, but the current library for the Adafruit ESP8266 uses the following pins:
The Adafruit HUZZAH ESP8266 has nine GPIO pins that you can use. They are: 0, 2, 4, 5, 12, 13, 14, 15, and 16.
They all have a 3.3V logic level and are not 5V compatible. The maximum current that can be drawn from one pin is 12 mA. The pins are general purpose and can be used for input as well as output. Additional functions of the pins are explained following:
There is only one analog pin on the ESP8266 board. It is labelled ADC. The pin can read a maximum voltage of approximately 1.0V. If the voltage you want to read is higher than 1.0V, you have to use a voltage divider to convert it to a 0-1.0V range.
The ESP8266 module reads digital signals from inputs and writes digital signals to outputs via the GPIO pins. Since all the GPIO pins have a logic voltage of 3.3V, it is important to ensure that any input signal to the pins is between 0V and 3.3V.
The GPIO pins usually read or write two kinds of digital signal: 0s and 1s. 0s represents voltages between -0.3V and 0.825V, while 1s represents voltages between 2.475V and 3.3V. Therefore, whenever you read a digital pin that is connected to a voltage above 2.475V, you get a 1 (high signal), and when you read a pin that is connected to a voltage less than 0.875V, you get a 0 (low signal), and the same applies to outputs.
3.19.56.114