In the dynamic world of Internet of Things (IoT), the esp8266 pinout stands as a crucial building block. In this article, we will discuss the esp8266 pinout and why it is so critical to IoT development. From its GPIO pins to compatibility with popular platforms like Arduino IDE, we will delve into the numerous advantages and possibilities it presents to IoT enthusiasts, makers, and developers.

The Power of ESP8266

Espressif’s esp8266 is a low-cost, Wi-Fi enabled microcontroller that is renowned for its versatility and efficiency. With built-in Wi-Fi capabilities, this microcontroller is popular for IoT applications where wireless connectivity is paramount.

The Core of the Matter - Understanding the ESP8266 Pinout

The ESP8266 microcontroller module features a total of 32 pins, each with a function that contributes to its remarkable utility. Here, we'll break down these key specifications to provide a clear understanding of its pinout:

  1. Communication Interfaces: The ESP8266 supports a variety of communication protocols, including UART, SPI, and I2C, making it compatible with a wide range of sensors and devices.
  2. Digital and Analog Pins: Out of the 32 pins, there are 17 GPIO (General-Purpose Input/Output) pins, which can be used for both digital input and output operations.
  3. Voltage Range for Analog Inputs: If you're dealing with analog sensors, the ESP8266 has you covered with a voltage range of 0-1.0V for its single analog input pin, making it suitable for a variety of analog sensors.
  4. Maximum Current Output: The ESP8266 pins can source or sink up to 12mA individually and up to 72mA in total, so it's important to plan your connections accordingly to avoid overloading.
  5. Max Bitrate: When it comes to data transfer, the ESP8266 boasts an impressive maximum bitrate of up to 2 Mbps, ensuring speedy data exchange with other devices in your IoT ecosystem.

What are the Power Pins of ESP8266?

You can power ESP8266 directly via the USB connector (standard USB = 5V) or the Vin pin (5V to 10V). The regulator provides a maximum of 500mA.

These are the power pins of this microcontroller board:

| Pin Name | Description | | :=== | :=== | | Vin | Can be used to directly supply the NodeMCU/ESP8266 and its peripherals. Power delivered on VIN is regulated through the onboard regulator on the NodeMCU module – you can also supply 5V regulated to the VIN pin | | GND | Ground - reference voltage for voltage input | | 3V3 | Output of the onboard voltage regulator (AMS1117-3.3) and can be used to supply power to external components. | | VU* | On some models, this pin is not connected. But in Lolin's V3 model, this provides a 5V output provided directly by USB. |

GPIO Number Doesn’t Match the Label on the Board Silkscreen?

It's essential to realize that the GPIO labeling on the ESP8266 does not correspond directly to the silkscreen markings on the board. For instance, the pin marked as D0 is actually GPIO16, while the one labeled D1 is in fact GPIO5.

The table below outlines the relationship between the silkscreen labels on the board and the actual GPIO numbers, detailing the most suitable pins for your projects and highlighting those that require careful handling.

| Board Label | GPIO | As Input | as Output | Precaution | | :=== | :=== | :=== | :=== | :== | | D0 | GPIO16 | No Interrupt | Non- PWM or I2C | HIGH during boot, used to wake up from deep sleep mode | | D1 | GPIO5 | OK | OK | Usually used as SCL | | D2 | GPIO4 | OK | OK | Usually used as SDA | | D3 | GPIO0 | Pulled up | OK | Directly connected to the Flash button, boot will fail if pulled LOW | | D4 | GPIO2 | Pulled up | OK | HIGH during boot, connected to the onboard LED, boot will fail if pulled LOW | | D5 | GPIO14 | OK | OK | SPI (SCLK) | | D6 | GPIO12 | OK | OK | SPI (MISO) | | D7 | GPIO13 | OK | OK | SPI (MOSI) | | D8 | GPIO15 | Pulled to GND | OK | SPI (CS), boot fails if pulled HIGH | | RX | GPIO3 | OK | RX pin | HIGH during boot | | TX | GPIO1 | TX pin | OK | HIGH during boot, debug output at boot, boot will fail if pulled LOW | | A0 | ADC0 | Analog Input | Don't Use | |

Which GPIOs connected to the Flash Chip?

GPIO6 to GPIO11 are usually connected to the flash chip in ESP8266 boards. So, these pins are not recommended to use.

Which Pins are Used During Boot?

The ESP8266 can be prevented from booting if some pins are pulled LOW or HIGH. The following list shows the state of the following pins during BOOT:

| GPIO | During Boot Behaviour | | :=== | :=== | | GPIO16 | Pin is HIGH during boot | | GPIO0 | Boot will fail if pulled LOW | | GPIO2 | Pin is HIGH during boot, boot failure if pulled LOW | GPIO15 | Boot failure if pulled HIGH | | GPIO3 | Pin is HIGH during boot | | GPIO1 | Pin is HIGH during boot, boot failure if pulled LOW | | GPIO10 | Pin is HIGH during boot | | GPIO9 | Pin is HIGH during boot |

Which GPIOs are the safest to use to operate coil relays?

  • GPIO4
  • GPIO5

How Many Analog Inputs Does the ESP8266 Have?

ESP8266 only has one analog input, it's the ADC0 pin, usually labelled as A0 on the board.  If you're using the bare ESP8266 chip, the maximum input voltage range of this ADC0 is 0 to 1V, for development board like NodeMCU ESP8266 12-E, the voltage input range is 0 to 3.3V due to presence of internal voltage divider.

This ADC pin has a 10-bit resolution, which means you’ll get values between 0 and 1023.

Which GPIOs Can I Use for the I2C Interface?

Unlike other microcontrollers, the ESP8266 lacks dedicated hardware for I2C; however, I2C functionality can be implemented in software, allowing any GPIOs to be used for I2C purposes. Commonly, the following GPIOs are used as I2C pins:

  • GPIO5: SCL
  • GPIO4: SDA
#include <Wire.h>

// Initialize software I2C on ESP8266 using different pins
void setup() {
  Wire.begin(D2, D1); // D2 as SDA, D1 as SCL
}

void loop() {
  Wire.beginTransmission(0x3C); // Start I2C Transmission
  // ... send data or commands to an I2C device
  Wire.endTransmission(); // Stop I2C transmission
  delay(1000); // Wait for a second
}

ESP8266 SPI (Serial Peripheral Interface) Pins

The pins used as SPI in the ESP8266 are:

  • GPIO14: SCLK
  • GPIO15: CS
  • GPIO12: MISO
  • GPIO13: MOSI

Can I Use Any GPIO as Interrupt Pins?

The ESP8266 supports interrupts in any GPIO, except GPIO16.

Harnessing the Versatility of GPIO Pins in a Practical IoT Project

The GPIO pins on the esp8266 are the backbone of its versatility, allowing you to connect various components to create a wide array of IoT applications. To illustrate their practical utility, let's consider a simple project: building a weather monitoring station.

  1. GPIO0 - Connecting a Rain Sensor (digital input): By configuring the GPIO0 pin as a digital input, the microcontroller can detect when it's raining and log data accordingly. This information can be sent to a remote server, enabling users to access real-time rainfall data from their IoT device.
  2. GPIO4 & GPIO5 - OLED Display (I2C communication): Esp8266 can be used to establish I2C (Inter-Integrated Circuit) communication for an OLED display. GPIO4 would be used as the SDA (data), while GPIO would be used as the SCL (clock). This display can provide users with real-time weather information in a user-friendly format.
  3. GPIO1 - Connecting an Anemometer (digital input): By configuring the GPIO1 pin as a digital input, the esp8266 can record wind speed data.
  4. ADC0 - Interfacing with a Light Sensor (analog input): A0 can be configured as an analog input for interfacing with a light sensor to provide ambient light conditions. It can then, for example, it can be used to trigger the OLED display's backlight when it gets dark.

And with the many additional pinouts, our weather monitoring station can always be improved--add a temperature sensor to GPIO2, or a humidity sensor to GPIO3!

Compatibility with Arduino IDE

The esp8266 pinout is also perfect for developers who are already comfortable with the Arduino IDE, as they seamlessly integrate, making the esp8266 widely accessible.

Using the Arduino IDE with the esp8266 offers several benefits:

  1. Familiar Environment: If you're already accustomed to the Arduino IDE, transitioning to the esp8266 becomes a breeze. You can leverage your existing knowledge and libraries to accelerate your IoT projects.
  2. Large Community Support: The Arduino community is vast, and you can tap into a wealth of resources, tutorials, and forums to get help when needed.
  3. Extensive Library Support: Arduino IDE compatibility means access to a vast library of pre-written code, which can significantly reduce development time.
  4. Cross-Platform Compatibility: Develop on one platform and easily migrate your code to different boards, such as the esp32, without significant modifications.

Wemos D1 Mini - A Popular Esp8266 Development Board

A topview of Wemos D1 mini microcontroller board
Check out this template for Wemos D1 mini.

When it comes to practical application, the Wemos D1 Mini, built around the esp8266, is a favorite among developers. Its compact size, affordability, and extensive support from the maker community have made it a go-to choice for IoT projects.

Here are some reasons why the Wemos D1 Mini is an excellent choice:

  1. Compact Form Factor: The small size of the Wemos D1 Mini makes it ideal for projects with limited space requirements.
  2. Easy to Use: The board comes with built-in USB-to-serial conversion, eliminating the need for external programmers.
  3. Abundant Shields and Accessories: The Wemos ecosystem offers a wide range of shields and accessories, making it easy to expand your project's capabilities.
  4. Built-in Wi-Fi: Just like the esp8266, the Wemos D1 Mini has built-in Wi-Fi support, making it an ideal choice for connected IoT applications.

Conclusion

In the evolving landscape of IoT, the esp8266 pinout is highly versatile. Its GPIO pins, compatibility with Arduino IDE, I2C capabilities, and integration into popular development boards like the Wemos D1 Mini provide a robust foundation for your IoT projects. However, if you're looking for something more, then check out its sibling, the esp32. The esp32 retains the flexibility of the esp8266 pinout while offering more processing power, built-in Bluetooth, and dual-core processing. This opens up new opportunities for more complex and feature-rich IoT applications.

If this sounds interesting to you and you'd like to request a demo or learn more, please contact sales.

Contact Sales
Profile avatar of the blog author

Jharwin Barrozo

Jharwin is an electronics engineer mainly focused on satellites. He built his own ground station using Flux to monitor RF activities on the International Space Station. Find him on Flux @jharwinbarrozo

Go 10x faster from idea to PCB
Flux is an all-in-one EDA. Use re-usable blocks, scripting, and a library you don’t have to manage to dramatically reduce the time it takes to go from idea to prototype.
Illustration of sub-layout. Several groups of parts and traces hover above a layout.
Illustration of sub-layout. Several groups of parts and traces hover above a layout.
Flux is a better way to build PCBs
Go 10x faster from idea to PCB by reducing busy work, never starting from scratch, and keeping your team in sync. All from the browser.
Screenshot of the Flux app showing a PCB in 3D mode with collaborative cursors, a comment thread pinned on the canvas, and live pricing and availability for a part on the board.
Flux is a better way to build PCBs
Go 10x faster from idea to PCB by reducing busy work, never starting from scratch, and keeping your team in sync. All from the browser.
Screenshot of the Flux app showing a PCB in 3D mode with collaborative cursors, a comment thread pinned on the canvas, and live pricing and availability for a part on the board.
Flux is a better way to build PCBs
Go 10x faster from idea to PCB by reducing busy work, never starting from scratch, and keeping your team in sync. All from the browser.
Screenshot of the Flux app showing a PCB in 3D mode with collaborative cursors, a comment thread pinned on the canvas, and live pricing and availability for a part on the board.
Flux for Enterprise
Learn how Fortune 500s are revolutionizing hardware design at scale with AI.
Flux for Enterprise
Join leading Fortune 500s and over 300k hardware engineers revolutionizing the way they build PCBs with AI
Flux for Enterprise
Join leading Fortune 500s and over 300k hardware engineers revolutionizing the way they build PCBs with AI