What is ESP8266

ESP8266

The ESP8266 from the manufacturer Espressif is a programmable WLAN SoC with UART and SPI interface. WIRELESS INTERNET ACCESSRadio modules with ESP8266 are available from € 3. The UART interface enables easy integration into microcontroller projects.

Specification [edit]

According to the manufacturer [1]. :

  • 802.11 b / g / n
  • Wi-Fi Direct (P2P), soft AP
  • Integrated TCP / IP protocol stack
  • Integrated TR switch, balun, LNA, power amplifier and matching network
  • Integrated PLLs, regulators, DCXO and power management units
  • + 19.5dBm output power in 802.11b mode
  • Power down leakage current of <20µA (at 2.5V, flash chip not included)
  • Integrated low power 32-bit CPU could be used as application processor
  • SDIO 1.1 / 2.0, SPI, UART
  • STBC, 1 × 1 MIMO, 2 × 1 MIMO
  • A-MPDU & A-MSDU aggregation & 0.4ms guard interval
  • Wake up and transmit packets in <2ms
  • Standby power consumption of <1.0mW (DTIM3)
  • VCC: 2.5 ... 3.6V (attention: inputs are NOT 5V TOLERANT!)

Farther:

Data throughput / performance [edit]

Post in the forum with tests: TCP: up to 7 Mbit / s
Post Espressif forum: UART loopback: 4.5 Mbps
Post Espressif forum: 300kbps send and receive in TCP passhrough mode
200-300k byte / s sending and receiving via TCP and UDP with C program and SDK 1.5.4 (at home with stefanus)

When using the AT firmware (v1.1.0.0 from SDK 1.5.4) with a serially connected microcontroller, the response to a short command (from the PC to the µC and back) typically takes 100-200ms.

Power / sleep modes [edit]

The power consumption of the ESP8266 depends on many factors, but it can be reduced significantly through clever programming.
So it is not necessary for the WIFI modem or the microcontroller to run continuously, e.g. to set a WLAN doorbell. In "deep sleep" the ESP8266 would only consume a few µA until it is reset via a timer and sends the message.
Stefanus measured 25µA: [1]

Detailed overview of the different modes and their power consumption by Espressif (out of date!)

WLAN modules with ESP8266 [edit]

There are around 11 variants from Chinese manufacturers. For example with PCB or ceramic antenna or with u.fl.

  • The firmware from SDK 0.9.1 supports up to four simultaneous TCP or UDP connections.
  • The firmware from SDK 1.5.4 supports up to five simultaneous TCP or UDP connections.

It can log into existing WLAN networks, but it can also be itself an access point with a DHCP server. The access point is compatible with Android (tested with 4.1.2).
However, the firmware does not include a router. Several computers that are connected to the module as an access point cannot establish a connection to one another. The feature is called AP isolation.

  1. Product description: [[2]]

Pin assignment of some ESP8266 modules [edit]

ESP8266-01 [edit]

  • Pinout - Large with PCB antenna

  • Pin assignment - small with ceramic antenna

source [2].

ESP8266-07 [edit]

Attention, with the ESP8266-07 module some are on the way with the labels of GPIO4 and GPIO5 switched !!.

ESP8266-12E [edit]

The ESP12E module is probably one of the most popular modules because of its many ports.

There is also a special adapter project for this module.

Possibilities of use and programming [edit]

Using a firmware [edit]

Various projects are involved in the development of firmware. You can "just" flash and use the firmware or you can actively participate in the development. There are, among others, the following projects:

  • AT commands: Firmware with which the module is addressed via UART.
  • Micropython: Firmware that enables Python scripts to run (tutorial)
  • NodeMCU: Firmware that enables Lua scripts to run (Github)
  • smartJS: Firmware that allows Javascript to run (Github)
  • Arduino core for ESP8266 WiFi chip: programming environment & firmware that enables the execution of C programs, in the style of the well-known Arduino platform. Github - inc. manual
  • ESP8266 Basic: Firmware that allows the execution of basic programs and editing via WLAN [3]
  • Sming: Easy to use framework, similar to Arduino, but with a simple Makefile per project and with Eclipse projects. (Github)
  • ESP-Lisp (BETA): A small fast lisp interpeter for a ESP8266 (Github)
  • ESP8266Forth: Forth for the ESP8266 NodeMCU Amica (Github)
  • Forthright: Forth for ESP-8266 (Github)
  • Punyforth: FORTH inspired programming language for the ESP8266 (Github)
  • ESP-LINK: Wifi-Serial Bridge w / REST & MQTT (Github)
  • ESPEasy: turn the ESP module into an easy multifunction sensor device for Home Automation solutions like FHEM. Configuration of the ESP Easy is entirely web based ([4])
Creating (compiling) a firmware [edit]

There are two options for creating an individual firmware:

  • Software Development Kit (SDK): Creating firmware using a GCC toolchain
  • Arduino IDE: Creating a firmware with an Arduino IDE

Projects that develop firmware for the ESP8266 (see previous section) use one of these two options.

Flash / update firmware [edit]

Typically, a compiled firmware is loaded onto a flash chip of an ESP8266 module via the UART bootloader of the ESP8266-SoC. The ESP8266-SoC then starts the firmware from there.

Flash download tool from the manufacturer
Python tool for flashing (by Fredrik Ahlberg)
Extension to Fredrik Ahlberg's tool
Flashing tool (by Christian Klippel)
Instructions, external
Instructions, forum

The manufacturer regularly publishes firmware updates as part of esp_iot_sdk. The firmware files are located in the bin directory. For example, the update is carried out for firmware 0.9.5 as follows:

python esptool.py --baud 9600 --port com6 write_flash 0x00000 boot_v1.2.bin 0x01000 at / user1.512.new.bin 0x3e000 blank.bin 0x7e000 blank.bin

Depending on the flash size, you have to compile the firmware from version 1.0.1 yourself. See discussion here and here.

Use without firmware [edit]

It is probably even possible to operate the ESP8266 as an SDIO WLAN module on a Raspberry Pi. The Linux driver of the ESP8089 is used for this. The ESP8266 then does not boot the firmware from the flash but via SDIO.

https://hackaday.io/project/8678-rpi-wifi

AT commands for firmware based on the SDK example "AT" [edit]

Setting the module as AP

Since we do not know which mode the module is currently in, we ask this with the command AT + CWMODE? from. The module answers with

AT + CWMODE? <\ R> <\ r> <\ n> + CWMODE: 1 <\ r> <\ n> <\ r> <\ n> OK <\ r> <\ n>

In this case the module is currently set in mode 1 (station). So we change the mode to 2 (AP) with the command AT + CWMODE = 2. After this command, the module must be reset so that the change becomes visible. We do this with the AT + RST command. The module restarts and the current consumption increases to approx. 80 mA. The module is now visible as a WLAN AP in the wireless LAN.

Now we still have to set that we want to have several connections at the same time, as well as start and set the TCP server. With the command AT + CIPMUX = 1 we tell the module that we want several connections. And with the command AT + CIPSERVER = 1.2526 we start the TCP server and let it run on port 2526. As soon as a client connects, the module sends 'Link' + LF + CR. When disconnecting from the client comes 'Unlink' + LF + CR.

From here we can connect to the module via a TCP socket on port 2526 and exchange data. Received data is displayed as follows. "Hello people" + LF + CR was broadcast.

<\r><\n> +IPD,0,11:Hallo Leute<\r><\n> OK<\r><\n>

+ IPD always comes, 0 is the first connection. If 2 devices have established a connection at the same time, a 1. 11 characters were received, then the data comes.

Proceed as follows to send data from the module to the client. First of all, we tell the module how much data we want to send to which connection. With the command AT + CIPSEND = 0.5 z. E.g. we tell the module we want to send 5 bytes to connection 0. After this command, the next 5 characters are passed directly to the connection. If there is no active connection, the module sends

AT + CIPSEND = 0.5 <\ r> <\ r> <\ n> link is not <\ r> <\ n>

otherwise comes

<\r><\n> >

and you can send data. After sending the data 'People' + LF + CR the module sends

People <\ r> <\ r> <\ n> busy <\ r> <\ n> <\ r> <\ n> busy <\ r> <\ n> <\ r> <\ n> SEND OK < \ r> <\ n>

Setting the module as a station

Software Development Kit (SDK) [edit]

With the SDK you can program your own applications and change the examples "AT" and "IoT" in the SDK. The SDK is provided by the manufacturer (as of October 25, 2014). A virtual machine with a gcc set up for compilation is available for the SDK. In particular, the gcc that is now available is based on a community development.

SDK0.9.2 + Linux virtual machine with gcc set up

Alternative link for the virtual machine + instructions / HOWTO for setup and compilation

There is also a community version GitHub which has not been further developed for two years.

Note [edit]

The SDK is used to program the microcontroller, which is located directly on the ESP8266 SoC chip. This is not to be confused with programming instructions for UART control of the ESP8266-SoC (mostly with AT firmware) with another microcontroller.

Checklist for problems with the module / compiler / SDK [edit]

Please consider the following checklist when asking for help with your problem.

If there are problems with the AT firmware / UART control with the microcontroller

  1. What do you use for the power supply?
    (Name very briefly so that conclusions can be drawn about voltage and current strength)
  2. Which firmware version are you using and where did you get it from?
  3. Which microcontroller do you use?
  4. Which baud rate do you use?
  5. Does the module "see" the AP, does the PC "see" the module?
  6. Does a Connect work?
  7. Which AT command sequence do you use and what does the module answer?

If you have problems with the SDK / compiler

  1. Are you using the latest, official VM?
    (This is designed for the latest SDK)
  2. Are you using the latest official SDK? Which version do you use?
    (Bug fixes and extensions are added regularly)
  3. Can you compile, flash and run the SDK examples (IoT, AT) according to the official instructions?

Links [edit]

ESP8266 entry on en.wikipedia.org
ESP8266 Community Forum
ESP8266 Github with wiki and source code examples
Hackaday posts on ESP8266
ESP8266 side of the manufacturer
ESP8266 forum of the manufacturer
ESP8266 and NodeMCU - tutorial with color display and temperature sensor

Posts in the mikrocontroller.net forum

Bulk orders in the mikrocontroller.net forum

Universal I2C control using WLAN-TCP / IP and web interface with ESP8266
Lots of projects and information about the ESP8266
Project I / O interface module with WLAN (Stefan Frings)
Documentation for the ESP8266 with Arduino code examples (Stefan Frings)

Edit documents]

Kolban's book on the ESP8266 Highly recommended!
Instructions / HOWTO for the setup of the virtual machine (SDK) and for compiling
Translated data sheet
AT Instructions Set (English) and instructions for operation on an Arduino (including code)
Description of the AT commands with examples
Espressif AT Instruction Set (Chinese)
ESP8266 Specifications (Chinese)
NodeMCU documentation
Building an IoT Node for less than 15 $ (Paper, Kindle via Amazon)

Edit data]

SDK0.9.2 + Linux virtual machine with gcc set up
Alternative link for the virtual machine
Files (Xplorer + SDK + PDF + etc.)
Config tool

Sources of supply [edit]

Official Espressif sales channel (sample purchase)
aliexpress.com ~ € 2
banggood.com ~ € 3.50
Ebay from 3 € including shipping, unit price: ESP-01/02/03/04/05
(Search term: ESP8266, item location option: "Worldwide")
(10 pieces from 27 EUR including shipping; search term: 10pcs ESP8266)
from 3.20 € including shipping, unit price: ESP-07/08/09/11
electrodragon.com ~ 3.50 € (plus shipping)
IT-WNS.de (ESP-01/02/03/06/07 / 12E) € 3.99 each (plus shipping)
seeedstudio.com ~ 5.50 €
In-Circuit.de ESP-ADC-DIL module with ESP8266EX 9.90 € unit price
watterott.com from ~ 4 € (plus shipping)
www.ramser-elektro.at ESP12F with 16mBit Flash ~ 4.90 € (free shipping from 35 €)
www.pollin.de ESP8266 Wi-Fi module ~ € 3.95 (shipping costs within Germany € 4.95)

Other [edit]

References Edit]

- from axhieb