Getting Started with ESP8266

In recent years, the Internet of Things (IoT) has become a hot topic in the tech industry. It has altered the way we work. Physical objects and the digital world are more intertwined than ever before.

With this in mind, in 2014, Espressif Systems released the incredibly tiny and inexpensive WiFi-enabled microcontroller – The ESP8266. It costs less than $3 and can monitor and control things from anywhere in the world, making it ideal for almost any IoT application.

Introducing ESP8266

The ESP8266 is a low-cost WiFi-enabled microcontroller, created and developed by Espressif Systems, a Shanghai-based Chinese company. The following features are the primary reasons why people like the ESP8266:

dualcore ico

Powerful Processor

The ESP8266 is equipped with a Tensilica Xtensa® 32-bit LX106 RISC microprocessor that operates at an adjustable clock frequency of 80 to 160 MHz and supports RTOS.

power ico

Ultra-Low Power Consumption

With its multiple power modes and dynamic power scaling, ESP8266 achieves ultra-low power consumption, making it ideal for use in mobile devices, wearable electronics and IoT applications.

wifi ico

Wi-Fi Capabilities

The ESP8266 incorporates an 802.11b/g/n HT40 Wi-Fi transceiver, allowing it to connect to a Wi-Fi network to access the internet (Station mode) or to create its own Wi-Fi wireless network (Soft access point mode) to which other devices can connect.

peripherals ico

Rich set of Peripherals

The ESP8266 includes a plethora of built-in peripherals such as ADCs, UART, SPI, I2C, I2S, PWM, and much more.

ways ico

Many Development Platforms

There are several development platforms available for programming the ESP8266. You can use the Arduino IDE, MicroPython, Espruino, Espressif SDK, or one of the platforms listed on WikiPedia.

lowcost ico

Low Cost

It is one of the cheap microcontrollers, with prices beginning at $3; this makes them accessible to a wide audience.

ESP8266 Development Boards

To get started with the ESP8266, you’ll need a good development board that includes all the extras. There are numerous varieties of development boards out there. While they all function similarly, some boards may be better suited to specific projects than others.

The following are just a few of the many different types of ESP8266 boards you can try out.

esp8266 nodemcu

ESP8266 NodeMCU

This is one of the most popular ESP8266 development boards. It has 4MB of flash memory, 11 GPIO pins, and one ADC pin with 10-bit resolution. This is what we use more often in our Wi-Fi and IoT projects. It is extremely versatile and perfect for beginners.

esp8266 wemos d1 mini

WeMos D1 Mini

Compared to the previous board, it has a smaller form factor and is more affordable, making it an excellent option for a more cost-efficient project. In addition, a variety of shields are available for the D1 mini board, allowing you to build small, simple setups with minimal wiring.

esp8266 esp01


This one is small and fits into any enclosure, making it ideal for finished projects. It has 1MB of flash memory and four GPIOs for controlling and connecting peripherals. If your projects require more peripherals, use one of the previous boards.

ESP8266 NodeMCU Hardware Overview

When it comes to ESP8266 development boards, the NodeMCU is by far the most widely used option. This is what we will use for our experiments. Don’t worry if you have a different board; the information on this page should still be useful.

Let’s take a deep dive into the hardware overview of the ESP8266 NodeMCU.

ESP-12E Module

This development board is equipped with the ESP-12E module, which contains the Tensilica Xtensa® 32-bit LX106 RISC that operates at an adjustable clock frequency of 80 to 160 MHz and supports RTOS.

ESP-12E Chip
  • Tensilica Xtensa® 32-bit LX106
  • 80 to 160 MHz Clock Freq.
  • 128kB internal RAM
  • 4MB external flash
  • 802.11b/g/n Wi-Fi transceiver
esp8266 nodemcu hardware specifications esp 12e chip

There’s also 128 KB RAM, and 4 MB of Flash memory (for program and data storage), which is sufficient to handle the long strings that make up web pages or JSON/XML data.

The ESP8266 incorporates an 802.11b/g/n HT40 Wi-Fi transceiver, allowing it to connect to a Wi-Fi network to access the internet (Station mode) or to create its own Wi-Fi wireless network (Soft access point mode) to which other devices can connect.


Because the ESP8266’s operating voltage range is 2.5V to 3.6V, the board includes an LDO voltage regulator to keep the voltage stable at 3.3V. It can reliably provide up to 600 mA, which should be sufficient even when the ESP8266 is drawing its maximum current (80 mA) during RF transmissions.

Power Requirement
  • Operating Voltage: 2.5V to 3.6V
  • On-board 3.3V 600mA regulator
  • 80mA Operating Current
  • 20 µA during Sleep Mode
esp8266 nodemcu hardware specifications power supply

The output of the 3.3V regulator is broken out to the header pin labeled 3V3. This pin can be used to power external circuitry.

The ESP8266 NodeMCU is typically powered by the on-board MicroB USB connector. Alternatively, if you have a regulated 5V power supply, you can use the VIN pin to power the ESP8266 and its peripherals directly.

Peripherals and I/O

The ESP8266 NodeMCU has a total of 17 GPIO pins that are broken out to pin headers. These pins can be assigned a variety of peripheral duties, including:

  • 1 ADC channel – 1 channel of 10-bit precision SAR ADC
  • 2 UART interface – 2 UART interfaces with with support for flow control
  • 4 PWM outputs – 4 PWM pins to control things like motor speed or LED brightness.
  • SPI and I2C interface – Two SPI and one I2C interfaces for connecting various sensors and peripherals.
  • I2S interface – One I2S interface for adding sound to your project.
Multiplexed I/Os
  • 1 ADC channels
  • 2 UART interfaces
  • 4 PWM outputs
  • SPI, I2C & I2S interface
esp8266 nodemcu hardware specifications multiplexed gpio pins

Thanks to the ESP8266’s pin multiplexing feature, which allows multiple peripherals to share a single GPIO pin. For example, a single GPIO pin can perform functions such as I2C, I2S, UART, PWM, and IR Remote Control, etc.

On-board Switches & LED Indicator

There are two buttons on the ESP8266 NodeMCU. The Reset button, labeled RST, is used to reset the ESP8266 chip. The other button is the FLASH button, which is used to upgrade firmware.

Switches & Indicators
  • RST – Reset the ESP8266 chip
  • FLASH – Download new programs
  • Blue LED – User Programmable
esp8266 nodemcu hardware specifications reset flash buttons led indicators

The board also includes a user-programmable LED that is connected to the D0 pin.

Serial Communication

The board includes Silicon Labs‘ CP2102 USB-to-UART Bridge Controller, which converts USB signals to serial and allows you to program the ESP8266 chip.

Serial Communication
  • CP2102 USB-to-UART converter
  • 4.5 Mbps communication speed
  • Flow Control support
esp8266 nodemcu hardware specifications cp2102 usb to ttl converter

ESP8266 NodeMCU Pinout

The ESP8266 NodeMCU has 30 pins in total. For convenience, pins with similar functionality are grouped together. The pinout is as follows:

esp8266 pinout nodemcu

Power Pins There are four power pins, one VIN and three 3.3V. The VIN pin can be used to directly power the ESP8266 and its peripherals, if you have a regulated 5V power supply. The 3.3V pin is the output from the on-board voltage regulator; you can get up to 600mA from it.

GND is the ground pin.

GPIO Pins The ESP8266 NodeMCU has 17 GPIO pins that can be assigned different functions by programming the appropriate registers. Each GPIO pin can be configured with internal pull-up or pull-down, or set to high impedance. When configured as an input, it can also be set to edge-trigger or level-trigger to generate CPU interrupts.

ADC Channel The ESP8266 includes a 10-bit precision SAR ADC. ADC can be used to perform two measurements: testing the power supply voltage of the VDD3P3 pin and testing the input voltage of the TOUT pin. They cannot, however, be implemented concurrently.

SPI Pins ESP8266 has two SPIs (SPI, and HSPI) in slave and master modes. These SPIs also support the general-purpose SPI features listed below:

  • 4 timing modes of the SPI format transfer
  • Up to 80 MHz and the divided clocks of 80 MHz
  • Up to 64-Byte FIFO

I2C Pins The ESP8266 doesn’t have hardware I2C pins, but it can be done by “bitbanging.” It works quite well, and the ESP8266 is fast enough to match “Arduino level” speed. By default, GPIO4 (SDA) and GPIO5 (SCL) are used as I2C pins to make it easier for people using existing Arduino code, libraries, and sketches. However, you can use any other two GPIO pins as I2C pins by calling wire.begin(SDA, SCL) in the Arduino IDE.

UART Pins The ESP8266 has two UART interfaces, UART0 and UART2, that support asynchronous communication (RS232 and RS485) at up to 4.5 Mbps. UART0 (TXD0, RXD0, RST0, and CTS0 pins) is used for communication, whereas UART1 (TXD1 pin) only features a data transmit signal and is typically used for printing logs.

~ PWM Pins Pulse width modulation (PWM) output can be implemented programmatically on all GPIO pins from GPIO0 to GPIO15. On the ESP8266, the PWM signal has a 10-bit resolution, and the PWM frequency range is adjustable between 1000 μs and 10000 μs, i.e., between 100 Hz and 1 kHz.

SDIO Pins The ESP8266 has one slave SDIO (Secure Digital Input/Output Interface) for connecting SD cards. SDIO v1.1 (4-bit, 25 MHz) and SDIO v2.0 (4-bit, 50 MHz) are supported.

Control Pins are used to control the ESP8266. These pins are the EN pin, the RST pin, the FLASH pin, and the WAKE pin.

  • The EN (also known as CH_PD or Chip Power Down) pin is used to enable the ESP8266. When pulled HIGH, the chip is enabled; when pulled LOW, the chip operates at low power.
  • The RST pin is the reset pin and it is normally held high. It can be used to reset the ESP8266 system by momentarily pulling it low. It is equivalent to pressing the on-board RST button.
  • The FLASH pin is used by the ESP8266 to determine when to boot into the bootloader. If the pin is held low during power-up it will start bootloading! It is equivalent to pressing the on-board FLASH button.
  • The WAKE pin is used to wake the ESP8266 from deep sleep.

ESP8266 Development Platforms

There are several development platforms available for programming the ESP8266.

You can go with Espruino (JavaScript SDK and firmware closely emulating Node.js), Mongoose OS (an operating system for IoT devices that is recommended by Espressif Systems and Google Cloud IoT), MicroPython (implementation of Python 3 for microcontrollers), an SDK provided by Espressif, or one of the platforms listed on WiKiPedia.

Fortunately, the amazing ESP8266 community recently took the IDE selection a step further by creating an Arduino add-on. If you’re just getting started with the ESP8266, we recommend starting with this environment, which we’ll cover in this tutorial. For more information, visit the ESP8266 Arduino GitHub repository.

Installing the ESP8266 Core

The first step in installing the ESP8266 Arduino core is to have the latest Arduino IDE (Arduino 1.8.5 or higher) installed on your computer. If you haven’t already, we recommend that you do so right away.

Latest Arduino IDE

Then, launch the Arduino IDE and navigate to File > Preferences.

arduino ide preferences

Fill in the “Additional Board Manager URLs” field with the following.

Then, click the “OK” button.

arduino ide esp8266 json url

Now navigate to Tools > Board > Boards Manager…

arduino ide boards manager

Filter your search by entering ‘esp8266‘. Look for ESP8266 by ESP8266 Community. Click on that entry, and then choose Install.

arduino ide esp8266 package

After installing, restart your Arduino IDE and navigate to Tools > Board to ensure you have ESP8266 boards available.

arduino ide boards manager esp8266 option

Now select your board in the Tools > Board menu (in our case, it’s the NodeMCU 1.0 (ESP-12E Module)). If you are unsure which board you have, select the Generic ESP8266 Module.

arduino ide boards manager esp8266 boards

Finally, connect the ESP8266 NodeMCU to your computer and select the Port (if the COM port does not appear in your Arduino IDE, you will need to install the CP210x USB to UART Bridge VCP Drivers):

arduino ide esp8266 port selection

That’s it! You can now begin writing code for your ESP8266 in the Arduino IDE.

You should make sure you always have the most recent version of the ESP8266 Arduino core installed.

Simply navigate to Tools > Board > Boards Manager, search for ESP8266, and verify the version you have installed. If a newer version is available, you should install it.

ESP8266 Example Sketches

The ESP8266 Arduino core includes several example sketches. To access the example sketches, navigate to File > Examples > ESP8266.

You will see a selection of example sketches. You can choose any of them to load the sketch into your IDE and start experimenting with it.

arduino ide esp8266 package examples

To ensure that everything is properly configured, we’ll upload the most basic sketch of all – Blink!

Navigate to File > Examples > ESP8266, and open the Blink sketch.

esp8266 blink sketch

This sketch uses the on-board LED that most ESP8266 development boards have. This LED is typically connected to digital pin D0, and its number may vary from board to board.


Failing to select the appropriate board, COM port, and Upload speed may result in the espcomm_upload_mem error during the upload of new sketches.

void setup() {
	pinMode(D0, OUTPUT);

void loop() {
	digitalWrite(D0, HIGH);
	digitalWrite(D0, LOW);

When the code is uploaded, the LED will begin to blink. To get your ESP8266 to run the sketch, you may need to press the RST button.

ESP8266 NodeMCU Blink Sketch Working Arduino IDE