15

members

Easy Basics: Project 021b How to update firmware - ESP8266 ESP-01 WI FI module

of Acoptex.com in UNO

Basics: Project 021b

Project name: How to update firmware - ESP8266 ESP-01 WI FI module

Tags: ESP, ESP8266, WI FI module, ESP-01, V090, update firmware, Ai Thinker, AI-Cloud, SOC, GPIO, General Purpose Input Output, System On a Chip, Nodemcu flasher, IOT, internet of things, FTDI232, FTDI 232, USB to TTL, ESP-01 programmer, Flash tools, Nodemcu firmware, Ai Thinker firmware, Espressif firmware, how to use DTR pin ESP8266, PN25F08, ESP8266 AT-command firmware

In this project, you need these parts :

1.Arduino Uno R3 (you can also use the other version of Arduino)

2. ESP8266 ESP-01 WI FI module 1pc

3.Arduino IDE ( you can download it from here  )

4.Jumper cables F-M, F-F, M-M

5. Breadboard 1 pc

6. USB to TTL serial converter 1 pc

7. USB mini cable 1 pc (optional)

8. Momentary switch (button) 2 pcs

9. Any voltage regulator LD1117V33, AMS1117 3.3 V or 78R33 (to get 3.3V) or  1 pc

or or 

10. Logical level converter 1 pc (can be resistors - voltage divider)

General

We will learn how to update the firmware in ESP8266 ESP-01 WI FI module.

Understanding the USB to TTL converter

You can read more about them here.

Understanding the ESP8266 WI FI module

The ESP8266 WiFi Module is a self contained SOC (System On a Chip) with integrated TCP/IP protocol stack that can give any microcontroller access to your WiFi network.

The ESP8266 WiFi Module is capable of either hosting an application or offloading all Wi-Fi networking functions from another application processor.

Each ESP8266 WiFi Module comes pre-programmed with an AT command set firmware, meaning, you can simply hook this up to your Arduino board and get about as much WiFi-ability as a WiFi Shield offers.

The ESP8266 WiFi Module is an extremely cost effective board. This module has a powerful enough on-board processing and storage capability that allows it to be integrated with the sensors and other application specific devices through its GPIOs (General Purpose Input Output) with minimal development up-front and minimal loading during runtime. Its high degree of on-chip integration allows for minimal external circuitry, including the front-end module, is designed to occupy minimal PCB area. The ESP8266 supports APSD for VoIP applications and Bluetooth co-existance interfaces, it contains a self-calibrated RF allowing it to work under all operating conditions, and requires no external RF parts.

In short, the ESP8266 module is a TTL "Serial to Wireless Internet" device, a small microprocessor with built in wi-fi. It is faster than most Arduino boards and has more memory than most Arduino boards and has less pins than an Arduino board.

The ESP8266 comes in a wide variety of versions (as shown in the figure below).

See the module list here.
ESP8266 AI THINKER IC (chip)

Specification:

  • 802.11 b/g/n
  • Built-in Tensilica L106 ultra-low-power 32-bit micro MCU, clocked at 80 MHz and 160 MHz, supporting RTOS
  • Built-in 10bit high precision ADC
  • Built-in TCP/IP stack
  • Built-in TR switch, balun, LNA, power amplifier and matching network
  • Built-in PLL, voltage regulator, and power management components, +20dBm output power in 802.11b mode
  • A-MPDU, A-MSDU aggregation and 0.4s guard interval
  • WiFi @ 2.4GHz, supports WPA/WPA2 security mode
  • Support AT remote upgrade and cloud OTA upgrade
  • Support STA/AP/STA+AP working mode
  • Supports Smart Config features (including Android and iOS devices)
  • HSPI,UART, I2C, I2S,IR Remote Control,PWM,GPIO
  • Deep sleep current is 10uA and shutdown current is less than 5uA
  • Wake up, connect and transfer packets within 2ms
  • Standby power consumption less than 1.0mW (DTIM3)
  • Operating temperature range: -40°C - 125°C

Application:

  • create a web server
  • send HTTP requests
  • control outputs
  • read inputs and interrupts
  • send emails
  • post tweets

HOW DOES IT WORK

The ESP8266 WI FI module can be controlled from your local wifi network or from the internet (after port forwarding set on your router). The ESP8266 communicates with the Arduino through a serial interface.  It uses the Arduino’s Rx and Tx pins (digital pins 0 and 1) connected to the ESP8266 ESP-01 module for receiving commands and communicates back. The module features a full TCP/UDP stack support and can be configured as a web server. ESP-01 module powers the onboard ESP8266 through 3.3V. You will have to use a voltage regulator AMS1117 3.3 V or like the 78R33 to step down the 5V from the Arduino to 3.3V or voltage divider (You can find some info here with online calculation sheet) in order to power up the ESP8266.

The ESP8266 does not come with an USB connector on it. You need an additional component for ESP8266 to communicate with the PC or laptop via USB port. It's called USB to TTL serial adapter (for example, USB adapter for ESP8266 ESP-01, FT232RL FTDI USB to TTL Serial Adapter, CP2102 USB to TTL UART converter). So we can either use a USB to TTL serial adapter (converter) or use an Arduino to communicate and upload the code to the ESP8266.

ESP-01 adapters

ESP8266 ESP-01 module

We will use ESP8266 ESP-01 module in this project. It has 2 GPIO pins that can be programmed to turn an LED or a relay ON/OFF through the internet. 

The ESP-01 module contains the ESP8266 MCU and a flash memory chip (PN25F08 IC -  8M-bit (1M-byte) Serial Flash memory. The. PN25F08 supports the standard Serial Peripheral Interface (SPI). The PN25F08 can be programmed 1 to 256 bytes at a time. You can read specification here) or (CFEON Q80B-104HIP IC- 8M-bit Serial flash memory). There are two LED's: a red one which indicates power is connected to the module, and a blue one which indicates data flow, and can also be controlled by user programming. The Wi-Fi antenna is the PCB trace that covers the top of the module; it's called a Meandered Inverted-F Antenna (MIFA,) is surprisingly efficient, and only mildly directional.

There are eight connection pads near the bottom of the module. Usually, two 4-pin male headers are inserted in the rear of the module and soldered on the front. This makes the I/Os accessible, but is not breadboard friendly, and requires flywires from the ESP-01 to a solderless breadboard. This technique works, but it is messy. 

ESP8266 ESP-01 module has three operational modes: 

1. Access Point (AP) — In AP, the Wi-Fi module acts as a Wi-Fi network, or access point (hence the name). It allows other devices to connect to it. And establishes a two-way communication between the ESP8266 and the device that is connected to it via Wi-Fi. 

2. Station (STA) — In STA mode, the ESP-01 can connect to an AP (access point) such as the Wi-Fi network from your house. This allows any device connected to that network to communicate with the module. 

3. Both — In this mode ESP-01 act as both an AP as well as in STA mode. Refer to the following site for more ESP8266 AT commands. 

ESP8266 ESP-01 module can be set in Flash mode or UART download mode (for uploading new firmware or program) and Boot mode or Flash Boot Mode (normal startup and execution of existing firmware or program).

ESPlorer
ESPlorer — Integrated Development Environment (IDE) for ESP8266 developers.
The essential multiplatforms tools for any ESP8266 developer from luatool author’s, including a LUA for NodeMCU and MicroPython. Also, AT commands are supported.
Required JAVA (SE version 7 and above) installed.
You can download it here.
Supported platforms
  • Windows(x86, x86-64)
  • Linux(x86, x86-64, ARM soft & hard float)
  • Solaris(x86, x86-64)
  • Mac OS X(x86, x86-64, PPC, PPC64)
Detailed features list
  • Syntax highlighting LUA and Python code
  • Code editor color themes: default, dark, Eclipse, IDEA, Visual Studio
  • Undo/Redo editors features
  • Code Autocomplete (Ctrl+Space)
  • Smart send data to ESP8266 (without dumb send with fixed line delay), check correct answer from ESP8266 after every lines.
  • Code snippets
  • Detailed logging

What is the difference between RTOS and the NON-OS SDK?

The main differences are listed below:

Non-OS SDK 

Non-OS SDK enables features or events to be embedded via timers and call-back functions. In this regard, specific functions will be triggered in specific conditions. In the Non-OS SDK, espconn is utilized to operate the network. The users need to develop softwares based on the usage rules for espconn.

RTOS SDK

1. FreeRTOS is utilized in the RTOS SDK that features multitasking operation. Designed in this way, this system enables users to utilize the standard interface for resource management, cyclic operation, time delay within a task, and inter-task information delivery and synchronization. For specific usage methods for interfaces, please refer to the official website of freeRTOS or USING THE FREERTOS REAL TIME KERNEL--A Practical Guide.

2. lwIP API, a standard interface, is utilized in the RTOS SDK to operate the network. In the RTOS SDK, SD Socket API is encapsulated. Users may develop software applications in the same way that they apply socket API, or compile the standard Socket applications that run on other platforms. This helps reduce costs incurred in switching from one platform to another.

3. cJSON library is added into the RTOS SDK. This library facilitates its functions to parse the contents of JSON data packet.

4. RTOS is compatible with Wi-fi interfaces, smart config interfaces, Sniffer related interfaces, system interfaces, timer interface, FOTA interfaces and peripheral driver interfaces in the non-OS SDK, but does not support the AT commands.

Signals and contacts of ESP8266 ESP-01 WI FI module

 

TXD (TX, TXO or UTXD) - transmit pin. Connected to Arduino Uno pin 1.

RXD (RX, RXI or URXD) - receive pin. Connected to Arduino Uno pin 0.

VCC (3V3 or 3.3V) - power supply pin (3-3.6V). Connected to 3.3V DC 1A and more external power supply. The current required for the ESP-01 during Wi-Fi operation vary from 250mA to 750mA.

RST (RESET) - reset pin. Keep it on high (3.3V) for normal operation. Put it on 0V to reset the chip.

CH_PD (CHIP_EN or EN) - Chip enable. Keep it on high (3.3V) for normal operation.

GND - Ground. Connected to Arduino board GND pin

GPIO0, GPIO2 (IO0, IO2) - General Purpose Input Output pins. GPIO0 also controls the module mode (programming or normal operation). In our case (normal operation), it shall be connected to 3.3V (high). GPIO2 is not used in this example.

Build the circuit

There are different methods to update the firmware in ESP8266 ESP-01 module:

1. Using ESP01 programmer UART

It is very easy. Simply insert ESP8266 ESP-01 module to ESP01 programmer UART. However to go to flash mode you need to have GPIO0 pin grounded (attached to GND pin). A small modification on the back of ESP01 programmer UART posible to make the life more easy. You can just shift jumper from GND-GND to GND-GPIO0 position.

2. Using USB to TTL Converter with DTR Pin

If you are using a USB to TTL converter which has a DTR pin, then uploading will go smoothly. Serial monitor will not work while doing that.

USB to TTL converter -> ESP8266 ESP-01 module

  • GND->GND 
  • TX->RX
  • RX->TX
  • RTS->RST
  • DTR->GPIO0
  • VCC 3.3V->3.3V
  • VCC 3.3V->EN

3. Using USB to TTL Converter without DTR Pin

USB to TTL converter -> ESP8266 ESP-01 module

  • GND ->GND
  • TX -> RX
  • RX ->TX
  • VCC 3.3V->3.3V
  • VCC 3.3V-> EN
  • Reset Button –> RST
  • Flash Button –> IO0

Put ESP8266 ESP-01 module in Flash mode (UART download mode) by pressing and holding the Flash button on breadboard. While pressing and holding the Reset button click on Download button in Flash tool software (Flash downloader), and then release Reset button. The flashing will start now if things are all right and you can see percentage completed on-screen. Keep the Flash button pressed till the end of new firmware uploading. When uploading finished release the Flash button and press Reset button to reset the module. It may give errors like “Can’t connect” or “Invalid packet head” etc. It happens mainly for two reasons. Deficient power supply to ESP module, or error in circuitry. Use a dedicated 3.3V power supply for ESP. And if still getting the error, try holding the Reset button for a while, when Download button is clicked on in the Flash tool software. It may solve the problem.

4. Using Arduino board

The ESP8266 powered up using a separate 3.3 V power source or a voltage regulator AMS1117 3.3 V or  78R33 or a voltage divider. Note: Do not plug in ESP8266 ESP-01 module directly to 3.3V Arduino Uno board pin as the ESP8266 ESP-01 module may draw more current than the 3.3V regulator on your Arduino can supply so you can damage your Arduino board. 

To use this method you need to remove ATmega328P IC from the Arduino board. By removing the microcontroller you can use the Arduino Uno onboard FTDI interface to directly communicate with the ESP module. Be very careful as you can easily damage the ATmega328P IC pins.

ESP8266 ESP-01 module -> Arduino Uno board

  • GND ->GND (through voltage regulator)
  • TX -> TX
  • RX ->RX (through logic level converter)
  • VCC->3.3V (through voltage regulator)
  • EN -> 3.3V (through voltage regulator)
  • RST–> 3.3V (through voltage regulator)
  • IO0 –> GND (through voltage regulator)

Step by Step instruction

VERY IMPORTANT NOTE:

Before doing firmware update:

  • When you buy the ESP8266 ESP-01 module, it normally comes with a pre-installed AT firmware. It is possible to program the ESP8266 IC (chip) with another firmware, for example. 
  • Remember that AT commands will no longer be available after an Arduino sketch has been uploaded.
  • First of all you need to establish communication with ESP8266 ESP-01 module - check that it's responding to AT  commands, it's firmware revision and manufacturer of ESP8266 IC.
  • The backup plan. Always make sure that you have your firmware version on hands so you can restore previous version if next firmware version is bad.
  • Read all information about firmware update available on Web.
  • Just think if you realy need to do it (for example if your ESP8266 ESP-01 WI FI module is not responding) as it is a risk to damage the module!!!
  • If you decided to do it make sure that the next firmware version which you are planing to upload is not older than existing. 
  • Make sure that you have Flash tools to update firmwarenodemcu flasherESP_DOWNLOAD_TOOL, ESP8266 flash downloader, other flashers you can download here

Firmware download links:

1. Nodemcu (check for newer versions here)

2. Ai Thinker (check for newer versions here)

Ai-Thinker firmware version 1.0 and above requires at least 1MB (8Mbit) of Flash. 512kB (4Mbit) of Flash has to use older version (v0.9.5.2).

Note: Since 1MByte flash module is not enough memory, all AT firmware with AiCloud2.0 can not be used, flash needs >= 2MByte.  Before upgrading with the CIUPDATE command, make sure the flash of the module >= 2MByte!

Lexin official SDK you can find here: NONOS, RTOS.

Lexin modified version (some changes done on the Lexin official SDK so that it can be used immediately after download): ESP8266_NONOS_SDK_V1.5.4 ESP8266_RTOS_SDK_V1.5.0

ESP8266 Flash address configuration described here.

3. Espressif (check for newer version here, other documents here)

EP8266 flash address configuration described here.

You can download SDK NONOS and RTOS here.

You can also download latest SDK from GitHub NONOS and RTOS.

1. Using ESP8266 flash downloader

  1. Do wiring.
  2. Download firmware binary file (it has an extension .bin). 
  3. Download flash tool program (flash downloader) to update firmware in ESP8266 IC.
  4. Connect USB to TTL converter (UART converter) or Arduino Uno board to your PC USB port.
  5. Open flash tool program (flash downloader).
  6. Change the COM port (Serial port). Check in your Device manager -> Ports (COM & LPT) which USB port your UART converter/Arduino Uno board connected to. 
  7. Press Bin button. Select the binary file that you just downloaded.
  8. If you want to update Nodemcu firmware type 0x40000080, AiThinker firmware type 0x00000. Before you press Download button make sure you ground GPIO0 pin. This is required every time a new firmware is being flashed.
  9. Press Download button. Flash downloader will delete the current firmware and start installing the new one.
  10. Once the firmware has been installed, you can disconnect GPIO0 pin from ground.
  11. Reset the ESP8266 ESP-01 module.
  12. You can use it now.

2. Using Nodemcu firmware programmer

  1. Do wiring.
  2. Download firmware binary file (it has an extension .bin). 
  3. Download flash tool program (flash downloader) to update firmware in ESP8266 IC.
  4. Connect USB to TTL converter (UART converter) or Arduino Uno board to your PC USB port.
  5. Open flash tool program (flash downloader).
  6. Change the COM port (Serial port) in Operation section. Check in your Device manager -> Ports (COM & LPT) which USB port your UART converter/Arduino Uno board  connected to. 
  7. Go to Config section and select the binary file that you just downloaded.
  8. If you want to update Nodemcu firmware type 0x40000080, AiThinker firmware type 0x00000
  9. Go to Advanced section and select baudrate 115200, flash size 4Mbyte, flash speed 40MHz, SPI mode DIO or DOUT.
  10. Before you press Flash button in Operation section make sure you ground GPIO0 pin. This is required every time a new firmware is being flashed.
  11. Press Flash button. Flash downloader will delete the current firmware and start installing the new one.
  12. Once the firmware has been installed, you can disconnect GPIO0 pin from ground.
  13. Reset the ESP8266 ESP-01 module.
  14. You can use it now.

3. Using ESPFlashDownloadTool_v3.6.4

  1. Do wiring.
  2. Download firmware binary file (it has an extension .bin). 
  3. Download flash tool program (flash downloader) to update firmware in ESP8266 IC.
  4. Connect USB to TTL converter (UART converter) or Arduino Uno board to your PC USB port.
  5. Open flash tool program (flash downloader).
  6. Press ESP8266 Download tool button.
  7. Select SPIDownload section.
  8. Select the binary file that you just downloaded.
  9. If you want to update Nodemcu firmware type 0x40000080, AiThinker firmware type 0x00000
  10. Check settings in SpiFlashConfig field of SPIdownload section.
  11. Select Flash size 4Mbit, SPI speed 40MHz, SPI mode DIO or DOUT, CryctalFreq 26M.
  12. Select baud rate 115200 and COM port (Serial port). You can in your PC Device manager -> Ports (COM & LPT) which USB port your UART converter/Arduino Uno board connected to. 
  13. Before you press Start button in SPIDownload section make sure you ground GPIO0 pin. This is required every time a new firmware is being flashed.
  14. Press Start button. Flash downloader will delete the current firmware and start installing the new one.
  15. Once the firmware has been installed, you can disconnect GPIO0 pin from ground.
  16. Press Stop button and close the ESP8266 download tool.
  17. Reset the ESP8266 ESP-01 module.
  18. You can use it now.

3.1 Using ESPFlashDownloadTool_v3.6.4

  1. Do wiring.
  2. Download Espessif firmware. Can be SDK NONOS or SDK RTOS or AT bin file. Espressif ESP8266 firmware has been provided in binary format files (.BIN). Users can choose between FOTA(Firmware Over-The-Air) and Non-FOTA binaries. You need to unzip/unrar the files from downloaded package. The bin folder in firmware  stores the compiled binaries to be downloaded directly into the flash. You need 4 files to download to ESP8266 ESP-01 module (download addresses for flash memory size 512KB): esp_init_data_default.bin 0x7C000 ; blank.bin 0x7E000 ; boot.bin 0x00000 ; user1.bin 0x01000. The esp_init_data_default.bin, blank.bin, boot.bin files are in bin folder. The user1.bin file is in AT subfolder.
  3. Download flash tool program (flash downloader) to update firmware in ESP8266 IC. The ESP8266 FLASH DOWNLOAD TOOL is the official firmware download tool developed by Espressif. 
  4. Connect USB to TTL converter (UART converter) or Arduino Uno board to your PC USB port.
  5. Open flash tool program (flash downloader).
  6. Press ESP8266 Download tool button.
  7. Select SPIDownload section.
  8. Select the 4 files and enter their addresses - esp_init_data_default.bin 0x7C000 ; blank.bin 0x7E000 ; boot.bin 0x00000 ; user1.bin 0x01000
  9. Check settings in SpiFlashConfig field of SPIdownload section.
  10. Select Flash size 8Mbit, SPI speed 40MHz, SPI mode DIOCryctalFreq 26M.
  11. Select baud rate 115200 and COM port (Serial port). You can in your PC Device manager -> Ports (COM & LPT) which USB port your UART converter/Arduino Uno board connected to. 
  12. Before you press Start button in SPIDownload section make sure you ground GPIO0 pin. This is required every time a new firmware is being flashed.
  13. Press Start button. Flash downloader will delete the current firmware and start installing the new one.
  14. Once the firmware has been installed, you can disconnect GPIO0 pin from ground.
  15. Press Stop button and close the ESP8266 download tool.
  16. Reset the ESP8266 ESP-01 module.
  17. You can use it now.

Summary

We have learnt how to update the firmware in an ESP8266 ESP-01 WI FI module.

Library

  • No libraries needed in this project

Sketch

  • No sketches needed in this project


Other projects of Acoptex.com
Medium Basics: Project 083w Sipeed Maixduino board - Using PlatformIO IDE of Acoptex.com in Sipeed Maixduino 08-08-2019
Medium Basics: Project 083e Sipeed Maixduino board - Uploading MaixPy of Acoptex.com in Sipeed Maixduino 04-08-2019
Medium Basics: Project 083f Sipeed Maixduino board - Using MycroPython of Acoptex.com in Sipeed Maixduino 04-08-2019

Published at 20-03-2018
Viewed: 35688 times