11

members

Easy Basics: Project 066w ESP8266 ESP-12E module - Over the Air updates (OTA)

of Acoptex.com in ESP8266 ESP-12

Basics: Project 066w

Project name: ESP8266 ESP-12E module - Over the Air updates (OTA)

Tags: ESP, ESP8266, WI FI module, ESP-12E, Ai Thinker, AI-Cloud, SOC, GPIO, General Purpose Input Output, System On a Chip, IOT, internet of things, FTDI232, FTDI 232, how to upload sketch, LoLin NODEMCU V3, NODEMCU, V3, Development Board with USB-to-Serial Onboard, NodeMCU DevKit, Wi-Fi OTA, Wireless Update ESP8266 ESP-12E module from the Arduino IDE, ESP8266 ESP-12E moduleOver-the-Air (OTA) Updating, OTA update, Over the Air updates (OTA)

Attachments: basicOTAsketch, newsketchOTAArduinoOTAlibrary

In this project, you need these parts :

1. ESP8266 ESP-12E module with micro USB cable 1pc

2. Arduino IDE version 1.6.13 ( you can download it here )

3. Python 2.7.15 ( you can download it here )

4. Led (red and green) 2 pcs

5. Resistor 220 Ohm 2 pcs

6. Breadboard 1 pc

7. Jumper wires F-M, M-M

General

We will learn how to do update through WiFi (OTA - Over The Air Update) with ESP8266 ESP-12E module (LoLin NODEMCU V3). 

 

OTA (Over the Air) update is the process of loading a new firmware to ESP32 development board using WiFi connection rather than a serial communication. This type of functionality is extremely useful in case of no physical access to the ESP module.

Uploading a new sketch wirelessly from Arduino IDE is intended for the following typical scenarios:

  1. during firmware development – as a quicker alternative to uploading a new sketch over a serial.
  2. for updating the firmware of multiple ESPs in your network.

Understanding the ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3)

You can read more about it here.

Signals and connections of LED

The operating voltage of the LED is 1.8V and the operating current is 10mA-20mA. The Arduino Uno board can supply 5V or 3.3V power. We will use 5V for this project, so the minimum resistance of the current limiting resistor should be (5 V to 1.8 V)/20 = 160 Om. The 220 Om offered in the kit is suitable and you can also choose other resistors that meet the condition. The larger the resistance is, the dimmer the LED will get.

Signals and connections of the ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3)

TX - transmit pin. GPIO pin

RX  - receive pin.  GPIO pin

3V3 (or 3V or 3.3V) - power supply pin (3-3.6V). 

GND ( or G) - ground pin.

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

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

Vin - External power supply 5VDC.

D0-D8 - GPIO (General Purpose Input Output) pins 

D5-D8 - SPI interface

D1-D2– I²C/TWI Interface

SC (or CMD) - (Chip Select) - the pin that the master can use to enable and disable specific devices. GPIO pin

SO (or SDO) - Master In Slave Out (MISO) - SPI communication. The Slave line for sending data to the master. GPIO pin

SK (or CLK) - SCK (Serial Clock) - SPI communication.The clock pulses which synchronize data transmission generated by the master. GPIO pin

S1 (or SD1) - Master Out/Slave In (MOSI). SPI communication. The Master line for sending data to the peripherals. GPIO pin

S2 (or SD2) - GPIO pin

S3 (or SD3) - GPIO pin

VU (or VUSB) - external power 5VDC.

A0 - ADC output.

RSV - reserved

Wiring

Step by Step instruction

1. Adding ESP8266 platform to Arduino IDE

the Arduino environment has to be set up to make it compatible with the 
ESP-01 module. It is required to have Arduino version 1.6.4 or higher in order to install the ESP8266’s platform packages.

The Arduino environment has to be set up to make it compatible with the ESP8266 ESP-12E module. 

We are using PC with Windows 10 OS.

1. Installation of  ESP8266 add-on in Arduino IDE on Windows OS.

  1. Download and install the Arduino IDE version 1.6.13 Windows Installer. You can download it here.
  2. Open Arduino IDE. 
  3. Open the Preferences window from the Arduino IDE. Go to File -> Preferences.
  4. Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field and click the “OK” button. If you already have a URL in there, and want to keep it, you can separate multiple URLs by placing a comma between them. (Arduino 1.6.5 added an expanded text box, separate links in here by line.)
  5. Open Boards manager. Go to Tools -> Board -> Boards Manager…

  6. There should be a couple new entries in addition to the standard Arduino boards. Look for esp8266. or scroll down to the ESP8266 entry (usually at the bottom). Select the ESP8266 entry. When you click it an install option will appear. Select the latest version and click install
  7. The board definitions and tools for the ESP8266 include a whole new set of gcc, g++, and other reasonably large, compiled binaries, so it may take a few minutes to download and install (the archived file is ~110MB). Once the installation has completed, an Arduino-blue “INSTALLED” will appear next to the entry.

2. Installing Python 2.7.x

  1. You need to install Python 2.7.X on your PC. Go to python.org website and download the latest version of Python 2.7.X for your OS (Operating System) (We are using Python 2.7.15 version in this project. You can download it here).
  2. Open the downloaded file to start the Python installation wizard. 
  3. Press Next button. Select destination directory.
  4. Press Next button.
  5. Scroll down in the Customize Python 2.7.15window and open the Add python.exe to Path. Select the option Will be installed on local hard drive.
  6. Press Next button to complete the installation. Press Yes button to give access to the drive.
  7. Press Finish button to complete installation.

3. Uploading the BasicOTA sketch to ESP8266 ESP-12E module 

 If you’re using an ESP-12E NodeMCU Kit, uploading the sketch is very simple, since it has built-in programmer. 

Before use ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3), you need to download the manufacture's driver (CH340)  for this chip and install it in your PC. Here is the link. See the description of driver installation package below: CH340 / CH341 USB to serial WINDOWS driver installation package that supports 32/64 bit Windows 10 / 8.1 / 8/7 / VISTA / XP, SERVER 2016/2012/2008/2003, 2000 / ME / 98, through Microsoft digital signature authentication, support USB to 3-wire and 9-wire serial port, with the product release To the end user. Applicable scope: CH340G, CH340C, CH340B, CH340E, CH340T, CH340R, CH341A, CH341T, CH341H chips.

If you have CP2102 chip then  you need to download the manufacture's driver for this chip and install it in your PC. Driver for Mac, Windows, Linux or more.. 

  1. Do wiring.
  2. Open Arduino IDE and open basicOTAsketch sketch.
  3. Plug your ESP8266 ESP-12E module into your PC USB port.
  4. Choose your NodeMCU board. Go to Tools -> Board -> NodeMCU 1.0 (ESP-12E Module)
  5. Select the correct com port.
  6. Modify sketch with your SSID and password for WiFi network which you are going to use for OTA updates.
  7. Compile and upload the basicOTAsketch to your ESP8266 ESP-12E module. If everything went as expected, you should see a “Done uploading” message. 
  8. Open the Serial Monitor at a baud rate of 115200 to verify that the ESP8266 ESP-12E module is properly connected to the Wi-Fi network. 
  9. Press RST button on your ESP8266 ESP-12E module to reset it.
  10. When your ESP8266 ESP-12E module restarts, you will see the IP address of your ESP8266 ESP-12E module in Serial monitor (in our case it’s 192.168.0.118). You will see the green LED blinks and the red LED is off.

 4. Uploading a new sketch Over the Air

  1. Now your ESP8266 ESP-12E module is ready to receive OTA firmware updates. You can unplug your ESP8266 ESP-12E module from your PC and power it through any power source (for example a power bank). If your ESP8266 ESP-12E module has a wireless connection to your router, you should be fine to upload new firmware.
  2. Open Arduino IDE and open newsketchOTA sketch.
  3. The Arduino IDE automatically detects devices that support remote update. They are added to the list of ports in a new section called Network ports - Tools -> Port -> Network ports, you should see something like this: myesp8266 at your_esp8266_ip_address (we have myesp8266 at 192.168.0.116)
  4. Select the myesp8266 at 192.168.0.116 in Network ports. 
  5. Modify sketch with your SSID and password for WiFi network which you are going to use for OTA updates.
  6. Compile and upload the newsketchOTA to your ESP8266 ESP-12E module. When compilation done the input pop up window appears. You need to enter your password (we used admin password here) and press Upload button.
  7. If the password is correct the uploading starts.
  8. If everything went as expected, you should see a “Done uploading” message. It will take less than minute to upload through WiFi.
  9. This sketch blinks the red LED now and green LED is off.

 

Summary

We have learnt how to do update through WiFi (OTA - Over The Air Update) with ESP8266 ESP-12E module (LoLin NODEMCU V3). 

Library

  • ArduinoOTA library included in your Arduino IDE.
  • ESP8266WiFi library included in your Arduino IDE.

Sketch

  • See attachments on the begining of this project description.


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 21-08-2018
Viewed: 2242 times