User Tools

Site Tools


Sidebar

Modtronix.com
Sitemap

tutorials:wireless:esp:esp8266:esp8266_additional_information

Esperissif ESP8266

Espressif are the manufacturers of the ESP8266 chip. They have a whole lot of information and software located on their site. The most useful seem to be:

ESP8266 Modules

There are many ESP8266 based modules available. To be able to use and flash a module, it is required to know some of it's specs, like the size of FLASH for example. The most popular ESP modules at the time of writing this(September 2016) are the ones manufactured by “AI-Thinkers”, the WeMos modules and the NodeMCU.

For an overview of popular modules, see:

ESP-01 to ESP-11

These are the older modules, and we do not stock or sell them. For details see this and this page.

ESP-12E

This is a very popular module with onboard antenna and 4MByte of flash.

ESP-12F

Seems the same as the ESP-12E, but with an improved 4 layer PCB and better wireless performance.

NodeMCU V1.0

This is currently(September 2016) the latest, official version of the popular NodeMCU. It uses the ESP-12E, and has 4MBytes of Flash. See GitHub page for details.

WeMos D1 R2

This is currently(September 2016) the latest version of the popular ESP board from WeMos, with and Arduino Uno format. It uses the ESP-12F, and has 4MBytes of Flash. See this page for details.

Common Firmware

There is a lot of firmware available for the ESP8266 modules. It can be very hard knowing what firmware your ESP8266 module has, specially for beginners. The most popular and free firmware currently seems to be:

  • NodeMCU firmware with Lua Intepreter
  • Arduino
  • AI Thinkers firmware
  • Espressif firmware

It is very confusing what firmware the AI Thinker modules have loaded on them by default. It seems to be a AT Command based firmware, but which firmware, and where to find it is very hard to determine.

NodeMCU Lua Firmware

See Using with NodeMCU Lua Firmware section below for details.
On power up, this firmware will output some information at 76800 baud rate. After that it seems to switch to to 115200(maybe 9600)

Arduino core for ESP8266

See Using with Arduino section below for details.
This enables the ESP modules to be used with the Arduino API and Arduino IDE! It makes it very simple and easy to use.

Espressif firmware

Espressif are the manufacturers of the ESP8266 chip. They have various firmware(SDK) versions on their site. To restore the default AT Command firmware on a ESP8266 module, we recommend using Espressif AT Firmware. See Using with Espressif Firmware section below for details.

AI Thinkers firmware

The most popular ESP modules are the ones manufactured by “AI-Thinkers”. They are supplied with the standard(and basic) AI Thinkers firmware. This firmware supports a wide range of AT commands. On power up, the “AI Thinker” firmware will output some information at 76800 baud rate. After that it seems to switch to to 115200(maybe 9600), which can be used for AT commands.

It is very confusing trying to find the actual firmware used on the AI Thinker modules. We would flashing the module with the Espressif Firmware.

Some useful links with additional information about the AI Thinker firmware and AT Commands can be found here:

AT Commands

The AI Thinker and Espressif firmware seem to share the same AT Commands.

The AT Command Instruction set documentation and examples can be downloaded from Espressif's website here. At the time of writing this, these were the current documents:

To send AT Command, you first have to connect to your ESP8266 module with a serial terminal(via USB cable). Also note that the ESP8266 expects <CR><LF> or “Carriage Return and Line Feed” at the end of each command, but just<CR> seems to work too. If AT Commands are not working, check configuration your your serial terminal. To test if all is working, you can send the following simple command. It will request the firmware version:

AT+GMR

This should reply with the firmware version.
To really test the WiFi radio on the module, we can request a list of all WiFi Access Points. To do this, first set mode to STA(Client):

AT+CWMODE=1

Next, request list of access points:

AT+CWLAP

After a couple of seconds, it should return with list of all access points.

Using YAT serial terminal

YAT is a very nice serial terminal that allows you to configure predefined commands, it can be downloaded here. The image on the right(click to enlarge) shows YAT with predefined commands for getting firmware version(AT+GMR), setting mode(AT+CWMODE=1), and requesting list of access points(AT+CWLAP). All commands can be executed by clicking on the configurable buttons.
You can download the YAT file from our site here. After downloading it:

  • Open it in YAT, from “File” → “Open” menu
  • Change COM port for your system via “Terminal” → “Settings” menu.

Additional Flashing information

Some useful links with additional information about the AT Commands can be found here:

Using with NodeMCU Lua Firmware

The official NodeMCU firmware contains the Lua Interpreter. Lua is an interactive programming language which allows you to experiment and build simple working programs without a lot of effort. If you are not familiar with Lua, you will find that it is not hard to learn, at least for the simple tasks needed to get started.

Flashing Module

The official NodeMCU site does NOT supply pre built(compiled) firmware. You have to build a custom version using their online compiler. BUT, we have made it easy for you by providing a pre built firmware for the hardware we sell.

Flashing with our pre built Firmware

We provide a pre built version of the official NodeMCU firware with following modules:
file, gpio, http, i2c, net, node, ow, pwm, spi, tmr, uart, wifi
It can be downloaded here. After downloading the firmware, the module can be programmed using one of the following 2 methods:

Flashing with custom Firmware

If you do not want to use our pre built firmware, you can build you own firmware as described on this page.
After obtaining your custom firmware, the module can be programmed using one of the following 2 methods:

Additional Flashing information

Some useful links with additional information how to flash the NodeMCU can be found here:

Flashing with NodeMCU Flasher

The module is programmed with 2 files:

  • The Firmware
  • A file containing default initialization data

The initialization data is some times required when the new firmware is not compatible with the old firmware that was present on the board. To program your NodeMCU, follow these simple steps:

  • Download default initialization data from here
  • Download the NodeMCU Flasher app used to program the NodeMCU:
  • Connect your NodeMCU board to a PC via USB. Ensure you have correct drivers installed, and it is recognized on PC. See USB Driver section below for details.
  • Put NodeMCU in Firmware upgrade mode. This is done by pressing and holding the “FLASH” button, and pressing and releasing the “RST” button. Release the “Flash” button.
  • Start the NodeMCU Flasher app. It should detect the NodeMCU, and display it's serial port
  • Click on “Config” tab, and select the “initialization data” downloaded above, and your firmware. Ensure the offset for the “initialization data” is 0x3FC000, and 0x00000 for the firmware!
  • Click on “Operation” tab of NodeMCU Flasher app, and click “Flash” button. It will start programming board
  • After about 1 minute it should finish, and display a green tick and full progress bar
  • Reset the NodeMCU. The first time after reset it will take about 90 seconds to format the file system. It is a good idea to connect it to a serial terminal when resetting it. This way you will get status information. The following is displayed after resetting for the first time:
    • Formatting file system. Please wait…
  • After about 90 seconds, it will finish formatting, and print status information for the build.

Flashing with esptool

In stead of using the “NodeMCU Flasher” app, the esptool python script can also be used. It supports Windows, Mac and Linux. The module is programmed with 2 files:

  • The Firmware
  • A file containing default initialization data

The initialization data is some times required when the new firmware is not compatible with the old firmware that was present on the board.

To program your NodeMCU, follow these simple steps:
1) Download default initialization data from here
2) Ensure you have Python 2.7 or later installed
3) Ensure you have PySerial Library installed. On Windows grab the pyserial-2.7.win32.exe installer and run it to install the library.
4) Install esptool in python (can use pip, simply execute “pip.exe install esptool”)
5) Run esptool.py python script, see this page for help. For example, on our system the NodeMCU USB com port was created on COM26, so the following command worked:

"python esptool.py --port COM26 write_flash -fm dio -fs 32m 0x00000 firmware.bin 0x3fc000 esp_init_data_default.bin"

Where “firmware.bin” is your firmware, and “esp_init_data_default.bin” is the initialization data downloaded above.

Additional information can be found:

Using NodeMCU Lua

After flashing the NodeMCU with the Lua based firmware, you can communicate with it using a serial port terminal like PuTTY, HyperTerminal, CoolTerm, TeraTerm or other. Configure serial terminal with following settings:
BAUD Rate 115200, 1 Stop Bit, No Parity, No Hardware flow control

  • Connect NodeMCU to PC via USB
  • Start serial terminal with settings given above (See device manager to get port number)
  • After resetting NodeMCU, it should print a message and “ >” command prompt
  • You can now enter Lua commands. For example, to get the ChipID, enter following Lua command “node.chipid()”. The board should reply with the Chip ID.

Information about available commands for NodeMCU Lua interpreter can be found here:

LuaLoader

LuaLoader is a very useful program that can be used to communicate with a NodeMCU programmed with the official NodeMCU Lua firmware. The latest version can be downloaded here.
See |this page for a quick start guide. See the blink LED example described below to do a basic test using LuaLoader

The LED is connected to 0(GPIO16). So, to blink the LED using LuaLoader:

  • In GPIO section, select “0 GPIO16”, “Output” and “Floating”.
  • Click on “Set” button. This should execute the following command “gpio.mode(0,gpio.OUTPUT)”, which will set port 0 to an output.
  • Now we can click on “0” and “1” buttons to turn system LED on and off. This will execute the following commands:
    • gpio.write(0,gpio.LOW) to turn the LED on
    • gpio.write(0,gpio.HIGHT) to turn the LED off

Additional Information

Some useful links with additional information can be found here:

Using with Arduino

Since Arduino IDE 1.6.4, it is possible adding the ESP8266 Board Package to the IDE. For details, see documentation on official GitHub page. The basic steps for adding support to the IDE are:

  • Start Arduino and open Preferences window.
  • Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas.
  • Open Boards Manager from Tools > Board menu and install esp8266 platform
  • Select your ESP8266 board from Tools > Board menu after installation(For example “NodeMCU 1.0”)
  • If your ESP8266 board has an USB port (NodeMCU, WeMOS…), plug it into your computer, and note in the Arduino IDE which port was added in the “Tools”–>“Port” menu. This is the port for your board. Select it.
  • You are now ready to write and upload sketched to your ESP8266 board.

The best place to ask questions related to this core is ESP8266 community forum: http://www.esp8266.com/arduino.

After adding ESP8266 support to the IDE, we can now load an example program, and program the NodeMCU board.

LED Flash Example

This simple example just flashes the LED. After install ESP8266 package, it is available via “File”–>“Examples”–>“ESP8266”–>“Blink” menu in IDE.

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
                                    // but actually the LED is on; this is because 
                                    // it is acive low on the ESP-01)
  delay(1000);                      // Wait for a second
  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  delay(2000);                      // Wait for two seconds (to demonstrate the active low LED)
}

Web Server Example

This is a very simple Web Server example supplied with the ESP8266 package. To load it, select the “HelloServer” example from the “File” → “Examples” → “ESP8266WebServer” menu in IDE.

Additional Information

Some useful links with additional information can be found here:

Using with Espressif Firmware

Espressif are the manufacturers of the ESP8266 chip. They have various firmware(SDK) versions on their site.

The default firmware programmed on ESP8266 modules you buy seem to be the AT Command based firmware, which is tagged with “[AT Release]” at the page given in the previous link. The latest AT Command firmware at the time of writing this seems to be ESP8266_AT_v1.1 Release (this is also contained in the larger “ESP8266_NONOS_SDK_Vxxx” SDK Release).

To program the AT Command firmware onto a standard ESP8266 Module with 4MByte(32MBit) flash, follow these steps:

  • Download the “Flash Download Tool” from Espressif's site (or here). We used V3.4.1. If you just need the 4 bin files, we put them in a zip file for your convenience.
  • Connect target ESP8266 module to PC via USB (put in firmware mode if required)
  • Select the 4 bin files as given in “README.md” file in “AT_bin” folder of SDK download. For 32MBit Flash device, it states:
    • eagle.flash.bin at 0x00000
    • eagle.irom0text.bin at 0x10000
    • blank.bin at 0x3fe000
    • esp_init_data_default.bin at 0x3fc000
  • Click “START”. Target will be flashed
  • After successful flashing, module will briefly output some status information at 76800 BAUD. After that, it switches to 115200 BAUD.
  • AT Commands can now be used with the Module. For example, to check the firmware version, you need to type AT+GMR, ENTER and <CTRL + J>. The module should reply with it's version and other information.

Espressif SDK Details

Following is some information regarding available SDK's and firmware on Espressif's site.

RTOS and Non-OS

There are 2 main categories(as described here):

  • Non-OS SDK: Not based on an operating system. It supports the compilation of IOT_Demo and AT commands.
  • RTOS SDK: Is based on FreeRTOS multi-tasking OS.

Boot Mode and Non-Boot Mode

These again seem to be available in FOTA(Boot Mode) and Non-FOTA(Non Boot Mode) versions:

  • Boot Mode: This seems to also be called “Non FOTA(firmware over the air). After connected to AP, ESP8266 can upgrade the AT firmware through WiFi by command “AT+CIUPDATE”.
  • Non-Boot Mode: This seems to also be called “FOTA(firmware over the air). ESP8266 can not upgrade the AT firmware through WiFi.

AT Command Firmware

So, to simply program a ESP8266 module with the default “AT Command” based firmware they are shipped with, seems like we have to download one of these two SDKs from the SDK section on the ESP8266 forum:

Flashing Firmware

This section describes how to flash an ESP8266 based module with an USB serial port. Like the NodeMCU or WeMost D1 boards. It assumes you already have the firmware bin file, which we will refer to as firmware.bin.

Flashing using NodeMCU Flasher app

To program your NodeMCU, follow these simple steps:

  • Download the NodeMCU Flasher app used to program the NodeMCU:
  • Connect your NodeMCU board to a PC via USB. Ensure you have correct drivers installed, and it is recognized on PC. See USB Driver section below for details.
  • Put the module in Firmware upgrade mode. This is not required for all modules. For the NodeMCU this is done by pressing and holding the “FLASH” button, pressing and releasing the “RST” button, and then releasing the “Flash” button.
  • Start the NodeMCU Flasher app. It should detect the module, and display it's serial port
  • Click on “Config” tab, and select your firmware
  • Click on “Operation” tab of NodeMCU Flasher app, and click “Flash” button. It will start programming board
  • After about 1 minute it should finish, and display a green tick and full progress bar
  • Reset the module.
  • It is a good idea to connect a serial terminal when resetting. Most modules with output status information after resetting.

Flashing using Python esptool script

In stead of using the “NodeMCU Flasher” app, the esptool python script can also be used. It supports Windows, Mac and Linux.

  • Ensure you have Python 2.7 or later installed
  • Ensure you have PySerial Library installed. On Windows grab the pyserial-2.7.win32.exe installer and run it to install the library.
  • Install esptool in python (can use pip, simply execute “pip.exe install esptool”)
  • Run esptool.py python script, see this page for help.
  • For example, on our system the ESP8266 Module's USB com port was created COM26, so the following command was used:

“python esptool.py –port COM26 write_flash -fm dio -fs 32m 0x00000 nodemcu-flash.bin”

Additional information can be found

Some useful links with additional information can be found here:

Trouble Shooting

Check USB Drivers are installed correctly

Ensure the CP2102 USB driver is installed correctly. The driver should be located here. If not, google it.

After flashing LED flashes and modules writes garbage on serial port

This can happen if programming the ESP8266 module with firmware that is not compatible with old firmware that was installed on the module. To fix it, first program default initialization data, and then your firmware. See Program with NodeMCU Flasher and Program using esptool sections above.

Module always writes garbage out on serial port after reset

When you connect most ESP8266 Modules with USB to your PC, it will create a virtual com port. You can use a serial terminal(like CoolTerm, PuTTY, YAT…) to send and receive data to and from the module. In it's default state, most modules will output what seems like garbage to the serial terminal (connected to PC via USB). This is however status information sent at 76800 BAUD. Most serial terminals do not support this BAUD rate. The only one we could find for Windows to support 76800 was PuTTY. To view this data, use PuTTY serial terminal, and configure it for 76800 BAUD, 1 Stop Bit and no parity.

tutorials/wireless/esp/esp8266/esp8266_additional_information.txt · Last modified: 2017/01/04 01:08 by modtronix