Are you new to the ESP8266? Begin here! The ESP8266 is a Wi-Fi System on a Chip (SoC) produced by Espressif Systems. It's ideal for Internet of Things and home automation applications. This is a how-to tutorial for getting started with ESP8266 NodeMCU board.
Are you new to the ESP8266? You've come to the right spot. This guide will provide you with all of the information you need to get started with this incredible board. Discover what an ESP8266 is, what it is used for, how to choose an ESP8266 NodeMCU board, how to upload your first software, and much more.
Introduction to ESP8266 NodeMCU
What exactly is an ESP8266 NodeMCU? Espressif Systems developed the ESP8266, a low-cost Wi-Fi chip.
It may be used as a standalone device or as a UART-to-Wi-Fi adaptor to connect other microcontrollers to Wi-Fi networks. For example, you may add Wi-Fi capabilities to your board by connecting an ESP8266 to an Arduino. The most practical use is using it as a standalone device.
The ESP8266 allows you to control inputs and outputs in the same way as an Arduino does but with Wi-Fi capabilities. This means that you may host your projects online, which is ideal for home automation and Internet of Things applications. What is the popularity of the ESP8266? Specifically for the following reasons:
- Low-cost: Starting at $3 (or less), depending on the model, you may purchase ESP8266 boards.
- Low-power: When compared to other microcontrollers, the ESP8266 consumes relatively little power and can even fall into deep sleep mode to consume less power.
- Wi-Fi: To connect to the internet, the ESP8266 may create its own Wi-Fi network (access point) or connect to existing Wi-Fi networks (stations). This means that the ESP8266 can access web services to perform HTTP requests or save data to the cloud. It may also function as a web server, allowing you to manage and monitor your boards remotely and access them using a web browser.
- Compatible with the Arduino “programming language”: Those who are already familiar with programming the Arduino board were happy to know that the ESP8266 may be programmed in the Arduino way.
- Compatible with MicroPython: MicroPython firmware, a re-implementation of Python 3 targeted for microcontrollers and embedded systems, is available to program the ESP8266.
What can you do with an ESP8266?
Here is a short list of things you can do with an ESP8266:
- Build a web server to control outputs.
- Setting an Access Point for a Web Server.
- Post on Twitter.
- Send WhatsApp Messages.
- Send Email via SMTP Server.
- Door Status Monitor with Email Notifications.
- Wire an OLED Display.
- And much more.
ESP8266 Technical Data
Check the following list for more details about the ESP8266's specs:
- Processor: L106 32-bit RISC microprocessor core based on the Tensilica Diamond Standard 106Micro running at 80 or 160 MHz
- Memory:
- 32 KB instruction RAM
- 32 KB instruction cache RAM
- 80 KB user-data RAM
- 16 KB ETS system-data RAM
- External QSPI flash: up to 16 MB is supported (512 KB to 4 MB are typically included).
- IEEE 802.11 b/g/n Wi-Fi
- Integrated TR switch, balun, LNA, power amplifier, and matching network
- WEP or WPA/WPA2 authentication, or open networks
- 17 GPIO pins
- Serial Peripheral Interface Bus (SPI)
- I²C (software implementation)
- I²S interfaces with DMA (sharing pins with GPIO)
- UART on dedicated pins, plus a transmit-only UART, can be enabled on GPIO2.
- 10-bit ADC (successive approximation ADC)
Main Differences Between ESP8266 and ESP32
There is a successor of the ESP8266—the ESP32. The ESP32 is a dual-core device that integrates Wi-Fi and Bluetooth. We recommend starting with an ESP32 if you intend to use any of these boards. Don't worry if you already have an ESP8266. It has a huge community, works wonderfully, and does the job for most DIY IoT projects.
The following table shows the primary differences between the ESP8266 and ESP32 chips:
ESP8266 | ESP32 | |
MCU | Xtensa Single-core 32-bit L106 | Xtensa Dual-Core 32-bit LX6 with 600 DMIPS |
802.11 b/g/n Wi-Fi | HT20 | HT40 |
Bluetooth | X | Bluetooth 4.2 and BLE |
Typical Frequency | 80 MHz | 160 MHz |
SRAM | X | ✓ |
Flash | X | ✓ |
GPIO | 17 | 34 |
Hardware /Software PWM | None / 8 channels | None / 16 channels |
SPI/I2C/I2S/UART | 2/1/2/2 | 4/2/2/2 |
ADC | 10-bit | 12-bit |
CAN | X | ✓ |
Ethernet MAC Interface | X | ✓ |
Touch Sensor | X | ✓ |
Temperature Sensor | X | ✓(old versions) |
Hall effect sensor | X | ✓ |
Price | $ (3$ – $6) | $$ ($6 – $12) |
Where to buy | Best ESP8266 Wi-Fi Development Boards | ESP32 Development Boards Review and Comparison |
ESP8266 Versions
As shown in the picture below, there are many versions of the ESP8266 modules. The most popular versions are the ESP-01 and ESP-12E. With ESP-12E or ESP-12F chips, you may find a wide variety of development boards.
ESP8266 NodeMCU Development Boards
It is not easy or practical to use bare chips or modules. You should use ESP8266 NodeMCU development boards for learning, testing, and prototyping.
These include all of the electronics needed to apply power, upload code, have easy access to the GPIOs to connect sensors and actuators, a Wi-Fi signal antenna, and other useful features.
How to Choose an ESP8266 Development Board?
From different vendors, there are a wide variety of ESP8266 boards. While they all work similarly, some boards may be better suited for some projects than others. There are various factors you need to keep in mind while shopping for an ESP8266 development board:
- USB-to-UART interface and voltage regulator circuit. These two features are included on the majority of full-featured development boards. This is important so that you can easily connect the ESP8266 to your computer to upload code and power it.
- BOOT and RESET/EN buttons to put the board in flashing mode or reset (restart) the board.
- Pin configuration and the number of pins. To use the ESP8266 properly in your projects, you'll need access to the board pinout (a map that shows which pin corresponds to a particular GPIO and its features). As a result, be sure you have access to the board's pinout. Furthermore, some boards have more easily accessible GPIOs than others. Depending on the features of your project, you should keep them in mind.
- Size. There is a wide range of ESP8266 development boards available in a variety of sizes. Some boards benefit from a small form factor, which may be highly practical depending on the features of your project. Smaller boards, like the ESP-01, often have a small number of GPIOs.
- Antenna connector. Most boards come with an onboard antenna for the Wi-Fi signal. Some boards optionally come with an antenna to connect an external antenna. Adding an external antenna extends the range of your WiFi.
What is the best ESP8266 development board for beginners?
What you intend to perform will determine the ideal ESP8266 development board for your project. We recommend using the ESP8266-12E NodeMCU Kit if you're just getting started with ESP8266 NodeMCU board.
ESP8266-12E NodeMCU Kit
One of the most popular ESP8266 development boards is the ESP12-E NodeMCU Kit. It features 4MB of flash memory, access to 11 GPIO pins, and a single analog-to-digital converter (ADC) pin with a precision of 10 bits. Furthermore, the board has a voltage regulator, and you may power up the module using either the small USB socket or the Vin pin.
The process of uploading code to the board is just as easy as uploading code to the Arduino. There's no need for an FTDI programmer or extra circuitry since it has a USB-to-serial converter. Most boards come with either the CP2101 or CH340 chips.
It comes equipped with an onboard antenna for Wi-Fi signals as well as RST and FLASH buttons to reset the board and put it into flashing mode. There is an integrated blue LED connected to GPIO 2, which is quite practical for debugging.
This is the ESP8266 board model that we most often use in our Wi-Fi and IoT projects. It's great for beginners and very versatile. So, if this is your first time working with the ESP8266, we recommend the following module: NodeMCU ESP8266 12-E Kit
Other Popular ESP8266 Development Boards
The ESP-01 and the ESP8266 Wemos D1 mini are two more very popular ESP8266 boards.
While I do not recommend the ESP-01 for beginners, the ESP8266 Wemos D1 mini might be a good choice.
ESP-01
The ESP-01 is super small and fits in any enclosure, making it ideal for completed projects. However, it has a very restricted number of accessible GPIOs and no built-in voltage regulator, so you'll need to use a 3V3 power source or install a voltage regulator to reduce the input voltage to 3V3. Furthermore, it does not come with a USB-to-serial converter, which means you would need an FTDI programmer or a specific programmer board to upload code.
WeMos D1 Mini
The WeMos D1 Mini is a small device with 4 MB of flash memory, 11 GPIOs, and 1 ADC pin. For the D1 mini-board, the community has developed a wide variety of shields, allowing you to construct small and basic setups with little to no wiring. To connect additional peripherals, you just need to stack the shields. It comes with a built-in voltage regulator and USB-to-UART converter, making code upload easy. For these reasons, it might be a good choice for beginners.
There are several additional versions of various ESP8266 boards. Similarly, most boards work. Just make sure they are appropriate for your project's needs.
The primary differences between the ESP-01, ESP8266-12E NodeMCU Kit, and the WeMos D1 Mini may be seen in the following table:
ESP-01 | ESP-12E NodeMCU | WeMos D1 Mini | |
GPIOS | 4 (including TX and RX) | 11 | 11 |
ADC Pins | 1 | 1 | 1 |
Flash Memory | 1MB (upgraded version) | 4MB | 4MB |
Breadboard friendly | x | ✓ | ✓ |
USB to Serial Converter | x | ✓ | ✓ |
Size | 24.75mm x 14.5mm (0.97” x 0.57”) | 48.55mm x 25.6mm (1.91” x 1”) | 34.2mm x 25.6mm (1.35” x 1”) |
Price | $ | $$ | $$ |
Where to Buy? | ESP-01 | ESP-12E NodeMCU | WeMos D1 Mini |
ESP8266 NodeMCU Pinout
The ESP8266-12E NodeMCU Kit, the Wemos D1 Mini, and the ESP-01 are the most widely used ESP8266 NodeMCU development boards. We will show you the pinout for those boards. A pinout is similar to a map in that it shows which pin belongs to which GPIO as well as its features. This way, you'll know which GPIOs to use, whether you need SPI, I2C, ADC, or anything else.
If you obtain a different board, a quick Google search should help you find its pinout. We'll just take a quick look at the pinout here. We recommend reading the following article, which shows the ESP8266 pinout and how to use its GPIOs in detail: ESP8266 Pinout Guide: How should I use the GPIO pins?
Power Pins
Typically, all boards come with three power pins: 3V3, GND, and VIN. You may use these pins to power the board (if you're not powering the board using the USB port) or to acquire power for additional peripherals.
General Purpose Input Output Pins (GPIOs)
The GPIO number does not match the label on the board's silkscreen, which is an important point to notice about the ESP8266. D0, for example, corresponds to GPIO16, and D1 to GPIO5. When programming your boards using the Arduino IDE, you must use the GPIO number rather than the number on the silkscreen. This is true for the vast majority of ESP8266 boards.
The ESP8266 peripherals include:
- 17 GPIOs (usually not all GPIOs are accessible on the ESP8266 development boards).
- SPI
- I2C (implemented in software)
- I2S interfaces with DMA.
- UART
- 10-bit ADC
You must carefully choose the pins for your projects since different ESP8266 GPIOs have different features. Otherwise, you may end up with unexpected outcomes.
We recommend taking a look at our ESP8266 GPIO guide, which shows in great detail how to pick the ideal GPIOs for your project:
ESP-12E NodeMCU Kit Pinout
The following picture shows an overview of the ESP-12E NodeMCU Kit pinout:
WeMos D1 Mini Pinout
Here’s the Wemos D1 Mini pinout:
ESP8266-01 Pinout
Here’s the ESP-01 pinout.
How to Program the ESP8266?
There are several ways to program the ESP8266 using different programming languages, including Arduino C/C++ using the Arduino core for the ESP32, Micropython, LUA, and others.
Programming the ESP8266 using the “Arduino programming language” with the Arduino IDE or VS Code is our preferred method. We recommend getting started with the Arduino IDE for beginners.
We also offer several tutorials showing how to program the ESP866 using MicroPython. However, we'll be focusing on the Arduino IDE throughout this essay.
Programming ESP8266 with Arduino IDE
You will need an IDE to write your code to program your boards. We recommend using the Arduino IDE for beginners. While it is not the finest IDE, it works well and is simple and intuitive for beginners to use. You may find it useful to use VS Code with the PlatformIO extension instead after becoming familiar with Arduino IDE and starting to construct more complex projects.
Start using the Arduino IDE if you're just getting started with ESP8266 NodeMCU board. We recommend using the legacy version (1.8.19) with the ESP8266 at the time of writing this article. Although version 2 works well with Arduino, there are still some problems and features that are not yet supported for the ESP8266.
Installing Arduino IDE
You need Java installed on your computer to run the Arduino IDE. If not, proceed to the following website to download and install the latest version: http://java.com/download.
Downloading Arduino IDE
To download the Arduino IDE, visit the following URL:
The 2.0 version should not be installed. We recommend using the legacy version (1.8.19) with the ESP8266 at the time of writing this article. Although version 2 works well with Arduino, there are still some problems and features that are not yet supported for the ESP8266.
Scroll down until you find the legacy version section.
Choose your operating system and begin downloading the programme. We recommend downloading the “Windows ZIP file” for Windows.
Running Arduino IDE
Download and unzip the folder you just downloaded. Run the arduino.exe executable file (highlighted below).
The Arduino IDE window should open.
Installing the ESP8266 NodeMCU in Arduino IDE
You need to add support for the ESP8266 boards to program the ESP8266 NodeMCU using the Arduino IDE. Next, do the following:
1) Go to File > Preferences.
2) Enter the following into the “Additional Board Manager URLs” field:
https://arduino.esp8266.com/stable/package_esp8266com_index.json
See the figure below. Then, click the “OK” button.
Note: If you already know the ESP32 board URL, you may use a comma to separate the URLs as follows:
https://dl.espressif.com/dl/package_esp32_index.json,
http://arduino.esp8266.com/stable/package_esp8266com_index.json
3) Open the Boards Manager. Go to Tools > Board >Boards Manager…
4) Search for ESP8266 and install “ESP8266 by ESP8266 Community“.
That’s it. It will be installed after a few seconds.
After this, restart your Arduino IDE.
Then, go to Tools > Board and check that you have ESP8266 boards available.
Now, you’re ready to start programming your ESP8266 using Arduino IDE.
ESP8266 Examples
You will find multiple examples of the ESP8266 board in the Arduino IDE. To begin, ensure that an ESP8266 board is selected under Tools > Board. Simply go to File > Examples and check out the examples in the ESP8266 section after that.
Update the ESP8266 Core in Arduino IDE
It's a good idea to check whether you have the latest version of the ESP8266 board add-on installed now and again.
You just need to go to Tools > Board > Boards Manager, search for ESP8266, and check the installed version. If a more recent version is available, select it to install it.
Upload Code to the ESP8266 NodeMCU using Arduino IDE
We'll try a simple example from the Arduino IDE examples for the ESP8266 to show you how to upload code to your ESP8266 board.
First, make sure an ESP8266 is selected in Tools > Board. Select the NodeMCU 1.0 (ESP-12E Module) option if you're using the ESP8266-12E NodeMCU Kit, which is shown in the previous pictures. You may always select the Generic ESP8266 Module if you don't know what your board is.
Then, go to File > Examples > ESP8266WiFi > WiFiScan.
This will load a sketch that scans Wi-Fi networks within the range of your ESP8266 board.
Connect your ESP8266 development board to your computer using a USB cable.
Warning: A USB cable with data wires is required. Some USB cables from chargers or power banks are simply for power and do not transfer data; these will not work.
Now, follow the next steps to upload the code.
1) Select your ESP8266 board by going to Tools > Board and scrolling to the ESP8266 section. If you don't know what your board is, the Generic ESP8266 Module typically works fine for most boards.
2) Go to Tools > Port and select an available COM port. If the COM port is greyed out, it means you lack the required USB drivers. Before continuing, read the section on installing USB drivers.
3) Press the upload button.
The code should be successfully uploaded to the board after a few seconds.
Uploading Code to ESP-01
If you're using an ESP-01, you'll want to read this section to learn how to upload code to the board.
Because the ESP-01 lacks a built-in programmer, uploading code is more difficult. Obtaining an ESP-01 programmer is the simplest way to upload code to the ESP-01. The picture below shows an example of an ESP-01 programmer, one of several available online.
You just need to connect the ESP-01 to the module and the module to your computer to program the ESP8266, which is very practical.
Using an FTDI programmer is a different option. You'll need to connect the ESP-01 to the FTDI programmer in the manner shown below. Just connect your computer to the FTDI programmer.
The following table shows the connections between the ESP8266 and the FTDI programmer that you need to make.
ESP8266 | FTDI programmer |
RX | TX |
TX | RX |
CH_PD | 3.3V |
GPIO 0 | GND |
VCC | 3.3V |
GND | GND |
If you have a new FTDI Programmer, you will most likely need to install the FTDI drivers on your Windows PC. The official drivers may be found on this website. (If the COM port in your Arduino IDE is greyed out, it is most likely because the drivers are not installed).
Then, all you need to do is connect the FTDI programmer to your computer and upload the code to the ESP8266 by just clicking the upload button.
Demonstration
Open the Serial Monitor at a baud rate of 115200 to see whether the code is working as expected.
To restart the board and begin running the newly uploaded code, press the ESP8266 RST or EN button.
You should get a list of nearby wi-fi networks.
If you're using an ESP-01, disconnect GPIO 0 from GND after uploading the code to deactivate the programming mode. Then, for around one second, connect the RST pin to GND and then disconnect to reset the board.
Installing the ESP8266 NodeMCU USB Drivers
If the COM port in the Arduino IDE is greyed out after connecting the ESP8266 board to your computer, it means you don't have the required USB drivers installed on your computer.
The CP2101 or CH340 drivers are used by most ESP8266 boards. Examine the USB-to-UART converter on your board and install the corresponding drivers.
With a quick Google search, you'll easily find instructions. For example, “install CP2101 drivers on Windows“.
Conclusion
We hope you found our getting started guide useful. To help you get started, I think we've included all the required information. You learned about the ESP8266, how to choose an ESP8266 development board, and how to upload new code to the ESP8266 using the Arduino IDE.
If you like ESP8266, you may also like:
- Install ESP8266 SPIFFS Filesystem Uploader in Arduino IDE
- ESP8266 NodeMCU Static/Fixed IP Address – Working & Testing
- ESP8266 NodeMCU Web Server using SPIFFS (Beginner Guide)
- Install ESP8266 LittleFS Filesystem Uploader in Arduino IDE
We hope you find this tutorial useful. Thanks for reading.