0

members

Easy Basics: Project 066a How to upload sketch - ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3)

of Acoptex.com in NODEMCU

Basics: Project 066a

Project name: How to upload sketch - ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3)

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, how to upload sketch, blink sketch for ESP8266 ESP-12E module, LoLin NODEMCU V3, NODEMCU, V3, Development Board with USB-to-Serial Onboard, NodeMCU DevKit, IOT STARTUP

Attachments: BLINKSKETCH

In this project, you need these parts :

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

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

3.Jumper cables F-M, F-F, M-M

4. Breadboard 1 pc

5. LED 1 pc (can be of different color)

6. Resistor 1 pc (220 Ohm)

General

We will learn how to upload sketch to ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3) and use it to do your DIY projects.

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

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.

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-12E module for receiving commands and communicates back. The module features a full TCP/UDP stack support and can be configured as a web server. 

ESP8266 ESP-12E module

We will use ESP8266 ESP-12E module in this project. 

Out of the many ESP-NN modules that have been released, ourselves alongside the rest of the ESP8266 community became fond of the FCC-certified ESP-12E, also known as the ESP-12F given that the first versions of the ESP-12E weren't FCC-certified!

The ESP-12E module breaks out all the available ESP8266 pins, and it includes a visible LED for indicating the status of the SoC's Tx pin, which is very useful during programming.  In addition, under the tin can, the ESP-12E a 4MB SPI flash storage IC – typically the Winbond W25Q32FV, and all the necessary components needed for the onboard ESP8266 to operate properly (e.g., crystal, capacitors, resistors). It also includes an onboard antenna with a reasonable range (–70~–80 dBm at 50 feet).

Features:

  • ESP8266 ESP-12E module
  • Built-in USB to Serial UART Adapter (CP2102 or CH340)
  • Reset button
  • Input button (also used for bootloading)
  • Surface-mount, user-controllable red LED
  • 3.3V 500mA voltage regulator (LM1117 or AMS1117)
  • Two diode-protected power inputs (one for a USB cable, another for a battery)
  • No need to press reset/flash for progamming
  • Supports Wi-Fi protocol 802.11 b / g / n;
  • Supported modes Wi-Fi - access point, client;
  • The input voltage is 3.7V - 20V;
  • Operating voltage 3V-3.6V;
  • The maximum current is 220mA;
  • Built-in TCP / IP stack;
  • Operating temperature range from -40С to 125С;
  • 80 MHz, 32-bit processor;
  • Time to wake up and send packets 22ms;
  • Built-in TR switch and PLL;
  • The presence of power amplifiers, regulators, power management systems.

There are several generations of NodeMcu boards - V1 (version 0.9), V2 (version 1.0) and V3 (version 1.0). The designations V1, V2, V3 are used for sale in online stores. Often there is confusion in the boards - for example, V3 is externally identical to V2. Also, all boards work on the principle of open-source, so they can be produced by any company. Amica, DOIT and LoLin / Wemos are the main makers of NodeMcu boards.

V1 and V2 are easy to compare - they have different sizes. Also, the second generation is equipped with an improved modification of the ESP-12 chip and 4 MB of flash memory. The first version, obsolete, is made in the form of a bright yellow platform. It is inconvenient to use it, since it covers 10 outputs of the breadboard. The second generation made to correct this disadvantage - it has become narrower, the outputs are well suited to the board's contacts. The V3 boards same as V2 but have a more reliable USB-output. The LoLin board is manufactured by LoLin, from differences from the previous board, it can be noted that one of the two reserved outputs is used for additional ground, and the second one is for feeding USB power. Also, the board is larger than the previous ones.

The ESP-12E is a great breakout for the ESP8266, however, in order to maintain a small footprint it's been designed without any holes for pin headers. Rather than a breadboard-able module, the ESP-12E is meant to be mounted on a PCB.  Moreover, to further increase the usability of the ESP-12E during rapid prototyping, some power regulation and USB connectivity are necessary.  This is what ourselves and other US-based DIY Electronics vendors have contributed to the ESP8266 ecosystem.  In our case we've developed a board that includes, among other passive components and discrete ICs, a CP2102 or CH340 USB to Serial UART adapter, a NCP1117 (AMS1117) 3.3 VDC Voltage Regulator, a micro-USB connector, and through-hole (male) pin headers.

This board breaks out all the (available) ESP8266 pins to through-hole headers for easy breadboarding.  The board also includes additional GND, Vin, 3.3VDC signals for easy access during development.  This development board for the ESP8266 SoC inside the ESP-12E module is out-of-the-box ready for you to connect it to your computer, install USB drivers, and start writing programs that connect to your Wi-Fi network!

You can find more about NodeMCU DEVKIT V1.0 here.

NodeMCU

NodeMCU is, at the moment, the most popular alternative firmware that runs on the ESP8266.  Based on the eLua project, it runs a Lua interpreter onboard the ESP8266, which is able to execute commands written in the Lua scripting language.  The commands are sent to the ESP8266 via the Serial UART interface.

NodeMCU is a great starting point for Makers as it provides an interactive environment that allows running commands not only for controlling the ESP8266's wireless interface, but also its GPIO and hardware functionality such as PWM.  In addition, we have access to the full scope of the Lua programming language for writing our applications.  In the case of the default firmware (AT+Commands Interpreter), the application code would have to be developed using a programming language suited to the host microcontroller or SoC that would be sending the commands over Serial (e.g., C/C++ for the Atmel/ARM microcontrollers on Arduino boards).

Not only does the NodeMCU firmware allows us to execute commands interactively, but we can save our applications as a script in the ESP-12E's flash memory, and instruct it to run the application code every time it restarts!

ESP8266 ESP-12E 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-12E 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-012E act as both an AP as well as in STA mode. Refer to the following site for more ESP8266 AT commands. 

Disadvantages of the NodeMcu module

The main disadvantage is the ability to execute only LUA scripts located in the RAM. This type of memory is small, the volume is only 20 KB, so writing large scripts causes a number of difficulties. First of all, the whole algorithm will have to be divided into linear blocks. These blocks must be written to separate files on the system. All these modules are executed using the dofile operator.

At writing it is necessary to observe a rule - at data interchange between modules it is necessary to use global variables, and at calculation inside of modules - local. It is also important to call the collectgarbage (garbage collector) function at the end of each written script.

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

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

The LED should be connected to GPIO 2 (D4 marked on the module).

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. It is required to have Arduino IDE version 1.6.4 or higher in order to install the ESP8266’s platform packages.

  1. Open Arduino IDE. 
  2. Open the Preferences window from the Arduino IDE. Go to File -> Preferences.
  3. 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.)

  4. Open Boards manager. Go to Tools -> Board -> Boards Manager…

  5. 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
  6. 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. Uploading 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.
  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. Verify and upload the blinksketch to your ESP8266 ESP-12E module. AT commands will not work after that. You need to Flash the firmware to enable them again.

  7. Your LED should be blinking every 1 second.

Code

This is the modified blink sketch. Change the pin number to 2 from 13.

Summary

We have learnt how to upload sketch to ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3) and use it to do your DIY projects.

Library

  • No libraries required for this project.

Sketch

  • You can find it on the begining of this project


Other projects of Acoptex.com
Easy Raspberry basics: Project 26a Raspberry PI Zero W board - Enable SSH of Acoptex.com in Raspberry Pi Zero W 07-01-2019
Easy Raspberry basics: Project 24a Raspberry PI Zero W board - Apache web server of Acoptex.com in Raspberry Pi Zero W 05-01-2019

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 26-03-2018
Viewed: 1087 times