0% found this document useful (0 votes)
5 views

node mcu

The ESP8266 Wi-Fi module is a low-cost, Arduino-compatible chip that enables Wi-Fi control of appliances and integrates a microcontroller for easy programming. It supports various interfaces and has multiple versions with different specifications, making it popular for projects like home automation and robotics. The document also covers technical specifications, pin descriptions, and instructions for using the module with the Arduino IDE and NodeMCU firmware.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

node mcu

The ESP8266 Wi-Fi module is a low-cost, Arduino-compatible chip that enables Wi-Fi control of appliances and integrates a microcontroller for easy programming. It supports various interfaces and has multiple versions with different specifications, making it popular for projects like home automation and robotics. The document also covers technical specifications, pin descriptions, and instructions for using the module with the Arduino IDE and NodeMCU firmware.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 32

4.

3 ESP8266 Wi-Fi Module


This is the heart of the project. Since the project is based on WIFI control of appliances, the
module forms the important component of the project.
The ESP8266 Arduino compatible module is a low-cost Wi-Fi chip with full
TCP/IP capability, and the amazing thing is that this little board has a MCU (Micro
Controller Unit) integrated which gives the possibility to control I/O digital pins via
simple and almost pseudo-code like programming language. This device is produced by
Shanghai-based Chinese manufacturer, Es press if Systems.
This chip was first time seen in August 2014, in ESP-01 version module, made by AIThinker,
a third-party manufacturer. This little module allows the MCU to connect to WiFi
network and create simple TCP/IP connections. His His very low price (1.7$ – 3.5$) and the
incredible small size attracted many geeks and hackers to explore it and use it in a large
variety of projects. Being a true success, Espressif produces now many versions having
different dimensions and technical specifications. One of the successors is ESP32. You can
find over the internet hundreds of projects and various implementations like home
automation,
data logging solutions, robotics, controlling things over the internet, even drones or copters.
4.3.1 ESP8266-01Technical specifications
 32-bit RISC CPU: Ten silica Xtensa LX106 running at 80 MHz **
 64 KiB of instruction RAM, 96 KiB of data RAM
 External QSPI flash – 512 KiB to 4 MiB* (up to 16 MiB is supported)
 IEEE 802.11 b/g/n Wi-Fi
 Integrated TR switch, balun, LNA, power amplifier and matching network
 WEP or WPA/WPA2 authentication, or open networks
 16 GPIO pins **
 SPI, I²C,
 I²S interfaces with DMA (sharing pins with GPIO)
 UART on dedicated pins, plus a transmit-only UART can be enabled on GPIO2
 1 10-bit ADC
** CPU and flash clock speeds can be raised via over clocking on some devices and the 16
I/O are not available in all versions.
xxiv
ESP8266 Arduino Module comes with PCB trace antenna which seems to have a very good
coverage (I saw a demonstration with more than 1km range!!!). Other version can have
onboard ceramic antenna or an external connector which allows you to attach external Wi-Fi
antennas modules. ESP-01 has only 6 active pins, although the MCU can support up to 16
I/O.
Board dimensions are 14.3 x 24.8 mm.

Over the internet i found that ESP8266 Arduino module, version 01, is sold in two or more
versions, which at first glance seem quite the same. After buying both of them i saw that
there
is a difference in size of the flash memory. You may encounter issues while flashing if you
don’t make the proper settings according to board specifications.
Although the board default has 2 available GPIOs, you can do some workarounds and use
other MCU available pins if you have the proper soldering tools. I managed to use GPIO 16
in
order to wake up the device after DEEP SLEEP mode (explained later in SLEEP MODES).
xxv
4.3.2 Module pin description (pin out)
Pins are arranged in two rows, having 4 on each row. Some models have pin description on
the PCB, which make it simple. On the top row you can find following pins from the left to
the right:
1. GND (Ground from power supply)
2. GPIO2 (Digital I/O programmable)
3. GPIO0 (Digital I/O programmable, also used for BOOT modes)
4. RX – UART Receiving channel
On the bottom (second row) you can find:
1. TX – UART Transmitting channel
2. CH_PD (enable/power down, must be pulled to 3.3v directly or via resistor)
3. REST – reset, must be pulled to 3.3v)
4. VCC -3.3v power supply
Power supply and current consumption
All esp8266 Arduino compatible modules must be powered with DC current from any kind of
source that can deliver stable 3.3V and at least 250mA. Also logic signal is rated at 3.3v and
the RX channel should be protected by a 3.3v divisor step-down. You should be careful when
using this module with Arduino or other boards which supplies 5v, because this module
usually do not come with overpower protection and can be easily destroyed.
The most basic way to use the ESP8266 module is to use serial commands, as the chip is
basically a WiFi/Serial
transceiver. However, this is not convenient. What we recommend is using the very cool
Arduino ESP8266 project,
which is a modified version of the Arduino IDE that you need to install on your computer.
This makes it very
convenient to use the ESP8266 chip as we will be using the well-known Arduino IDE.
Following the below step to
install ESP8266 library to work in Arduino IDE environment.
3.1 Install the Arduino IDE 1.6.4 or greater
Download Arduino IDE from Arduino.cc (1.6.4 or greater) - don't use 1.6.2 or lower version!
You can use your
existing IDE if you have already installed it.
You can also try downloading the ready-to-go package from the ESP8266-Arduino project, if
the proxy is giving you
problems.
3.2 Install the ESP8266 Board Package
Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional
Board Manager URLs
field in the Arduino v1.6.4+ preferences.
Scroll down to ‘ esp8266 by ESP8266 Community ’ and click “Install” button to install the
ESP8266 library package.
Once installation completed, close and re-open Arduino IDE for ESP8266 library to take
effect.
3.3 Setup ESP8266 Support
When you've restarted Arduino IDE, select ‘Generic ESP8266 Module’ from the ‘Tools’ ->
‘Board:’ dropdown menu.
3.4 Blink Test
https://github.com/nodemcu/nodemcu-devkit/tree/master/Drivers
We'll begin with the simple blink test.
Enter this into the sketch window (and save since you'll have to). Connect a LED as shown in
Figure3-1.
void setup() {
pinMode(5, OUTPUT); // GPIO05, Digital Pin D1
}
void loop() {
digitalWrite(5, HIGH);
delay(900);
digitalWrite(5, LOW);
delay(500);
}
Now you'll need to put the board into bootload mode. You'll have to do this before each
upload. There is no timeout
for bootload mode, so you don't have to rush!
• Hold down the ‘Flash’ button.
• While holding down ‘ Flash’, press the ‘RST’ button.
• Release ‘RST’, then release ‘Flash’
When you release the ‘RST’ button, the blue indication will blink once, this means its ready
to bootload.
The sketch will start immediately - you'll see the LED blinking. Hooray!
3.5 Connecting via WiFi
OK once you've got the LED blinking, let’s go straight to the fun part, connecting to a
webserver. Create a new sketch
with this code:
Don’t forget to update:
const char* ssid = "yourssid";
const char* password = "yourpassword";
to your WiFi access point and password, then upload the same way: get into bootload mode,
then upload code via
IDE.
4. Flashing NodeMCU Firmware on the ESP8266 using Windows
Why flashing your ESP8266 module with NodeMCU?
NodeMCU is a firmware that allows you to program the ESP8266 modules with LUA script.
And you’ll find it very
similar to the way you program your Arduino. With just a few lines of code you can establish
a WiFi connection,
control the ESP8266 GPIOs, turning your ESP8266 into a web server and a lot more.
In this tutorial we are going to use another ESP8266 module with pin header adapter board
which is breadboard
friendly.

ESP8266 Module Breadboard Friendly with Header Connector


4.1 Parts Required:
• ESP8266 Module Breadboard Friendly
4.4 Downloading NodeMCU Flasher for Windows
After wiring your circuit, you have to download the NodeMCU flasher. This is a .exe file that
you can download using
one of the following links:
• Win32 Windows Flasher
• Win64 Windows Flasher
You can find all the information about NodeMCU flasher here.
Getting Started with the ESPlorer IDE
ESPlorer is an IDE (Integrated Development Environment) for ESP8266 devices. It’s a multi
platform IDE, can be
used in any OS environment, this simply means that it runs on Windows, Mac OS X or
Linux.
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)
This software allows you to establish a serial communications with your ESP8266 module,
send commands, and
upload code and much more.
Requirements:
• You need to have JAVA installed in your computer. If you don’t have, go to this
website: http://java.com/download, download and install the latest version. It requires JAVA
(SE version 7
and above) installed.
• In order to complete the sample project presented in this Guide you need to flash your
ESP8266 with
NodeMCU firmware. Refer to chapter-4 in this guide on how to flash the NodeMCU
firmware.
Main Resources:
• ESPlorer Homepage: http://esp8266.ru/esplorer/
• GitHub Repository: https://github.com/4refr0nt/ESPlorer
5.1 Installing ESPlorer
Now let’s download the ESPlorer IDE, visit the following URL:
http://esp8266.ru/esplorer/#download
Grab the folder that you just downloaded. It should be named “ESPlorer.zip” and unzip it.
Inside that folder you
should see the following files:

Execute the “ESPlorer.jar” file and the ESPlorer IDE should open after a few seconds (the
“ESPlorer.jar” file is what
you need to open every time you want to work with the ESPlorer IDE).

Note: If you’re on Mac OS X or Linux you simply use this command line in your terminal to
run the ESPlorer: sudo
java –jar ESPlorer.jar.
When the ESPlorer first opens, that’s what you should see:
Here’s a rundown of the features the ESPlorer IDE includes:
• 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.
• And a lot more…
The ESPlorer IDE has a couple of main sections, let’s break it down each one.
In the top left corner you can see all the regular options that you find in any software. Create
a New file, Open a new
file, Save file, Save file as, Undo, Redo, etc.
In the top right corner you have all the options you need to establish a serial communication
(you’re going to learn
how to use them later in this Guide).
5.2 Schematics
To upload code to your ESP8266, you should connect your ESP8266 to your PL2303HX
USB-UART Programming Cable
like the figure below:
The next step is to save your code to your ESP8266!
At the left bottom corner click the button “Save to ESP”.
In your output window, it should start showing exactly which commands are being sent to
your ESP8266 and it should
look similar to the Figure below.
Note: If you want to delete your “init.lua” file, you can do that easily. Simply type
file.remove(“init.lua”) and press
the button “Send” (see Figure above). Or you can type the command file.format() to remove
all the files saved in your
ESP8266. You can type any commands and send them to your ESP8266 through that
window.
After uploading your code to your ESP8266, unplug your ESP8266 from your computer and
power up the ESP8288
module.
6. NodeMCU GPIO for Lua
The GPIO(General Purpose Input/Output) allows us to access to pins of ESP8266 , all the
pins of ESP8266 accessed
using the command GPIO, all the access is based on the I/O index number on the NoddMCU
dev kits, not the internal
GPIO pin, for example, the pin ‘D7’ on the NodeMCU dev kit is mapped to the internal
GPIO pin 13, if you want to
turn ‘High’ or ‘Low’ that particular pin you need to called the pin number ‘7’, not the internal
GPIO of the pin. When
you are programming with generic ESP8266 this confusion will arise which pin needs to be
called during
programming, if you are using NodeMCU devkit, it has come prepared for working with Lua
interpreter which can
easily program by looking the pin names associated on the Lua board. If you are using
generic ESP8266 device or any
other vendor boards please refer to the table below to know which IO index is associated to
the internal GPIO of
ESP8266.

D0 or GPIO16 can be used only as a read and write pin, no other options like PWM/I2C are
supported by
this pin.
In our example in chapter 5 on blinking the blue LED, the blue LED in connected to GPIO2,
it is defined as
Pin4 (D4) in Lua script.
7. Web Resources:
• ESP8266 Lua Nodemcu WIFI Module
• ESP8266 Breadboard Friendly Module
• ESP8266 Remote Serial WIFI Module
• PL2303HX USB-UART Converter Cable
This mod based on the D0 pi Please ref NODE M U is an 266 from E CU" by de cripting lan
266. It uses U was crea egan produc X106 core,w 8266 is a lo d by Shangh Pin confi dule
provide the I/O ind n on the dev fer to the be MCU open so Espressif, a efault refer nguage. It
is s many open ated shortly ction of the widely used ow-cost Wi hai-based Ch Figure 3
guration es access to dex number v kit is map elow GPIO Figure ource IoT pl and hardwa rs
to the f s based on t n source pro y after the e ESP8266. d in IoT app -Fi microch hinese manu
3: NODE M of NODE o the GPIO on the Nod pped to the i pin maps fo e 2: NODE latform. I
are which firmware ra the eLua pr ojects, such ESP8266 c The ESP82 plications hip with fu
ufacturer, E MCU with in E MCU de (General P deMCU dev internal GP or the index MCU
Deve It include is based ather than roject, and b as lua-cjson came out. O 266 is a Wi ull
TCP/IP Espressif Sy nbuilt wifi m evelopme Purpose Inpu v kits, not t IO pin 16. x↔gpio
map elopment bo es firmwa on the ES the dev k built on the n,and spiffs On Decemb i-Fi
SoC int stack and m stems. module nt board ut/Output) the internal pping.
3.2.2 Installation of Node MCU & Coding
Mostly these days devices download and install drivers on their own, automatically.
Windows
doesn’t know how to talk to the USB driver on the Node MCU so it can’t figure out that the
board is a Node MCU and proceed normally.

You might also like