ESP8266 is a low-cost WiFi chip. ESP8266 chip is shown in Figure 1. This chip consists of a microcontroller and a full TCP/IP stack. ESP8266 is made by Espressif Systems, a Shanghai-based Chinese fabless semiconductor company. SP8266 is a very popular chip for developing IoT devices. The ESP8266's specifications are listed as the following
L106 32-bit RISC
microprocessor core based on the Tensilica
Xtensa Diamond Standard
106Micro running at 80 MHz
Memory:
32 KiB instruction RAM
32 KiB instruction cache RAM
80 KiB user-data RAM
16 KiB ETS system-data RAM
External QSPI ash: up to 16 MiB is supported (512 KiB to 4 MiB typically included)
IEEE 802.11 b/g/n Wi-Fi
Integrated transmit/receive (TR) switch, balun, LNA, power amplifier, and matching network
WEP or WPA/WPA2 authentication,
or open networks
16 GPIO pins (GPIO6 11 are used for communication with on- board ash memory).
SPI
I2C
(software implementation)
I2S
interfaces with DMA (sharing pins with GPIO)
UART on dedicated pins, plus a transmit-only UART can be enabled on GPIO2
10-bit
ADC (successive approximation ADC)
With ESP8266, you can make IoT devices that are connected to theinternet through WiFi network.
What is the difference
between ESP8266 and ESP8266EX?
ESP8266 is the initial version. ESP8266EX is the updated version. Now ESP8266EX is the most commonly available.
ESP-12E
ESP-12E is a WiFi module that uses the ESP8266. ESP-12E is shown in Figure 2. ESP-12E is made by Ai-Thinker, a third-party manufac-turer. There are other ESP modules made by this manufacturer. They are referred to as \ESP-xx modules". the disadvantage of ESP-12E is that it is not breadboard friendly.
ESP-12E has an RF shield (metal enclosure) that covers the ESP8266 chip as shown in Figure 3. This shield is used for compliance with Federal Communications Commission (FCC) emissions rules. This shield can minimize interference with other devices.
NodeMCU
NodeMCU is a development board that uses the ESP-12E. NodeMCU is shown in Figure 4. Compared to the ESP-12E, NodeMCU is breadboard friendly and includes USB to serial interface. NodeMCU can be programmed using Lua scipting, Arduino, or ESP8266 SDK.
What are the diferences
between NodeMCU V1, V2, and V3?
NodeMCU V1 is the _rst generation, but now outdated. NodeMCU V2 and V3 are the second generation. V2 is made by Amica, while V3 is made by LoLin. V2 and V3 use a di_erent USB to serial chip. V3's board size is signi_cantly larger than the V2.
Driver Installation
Before we can program NodeMCU, we need to install the USB driver. The step-by-step how to install NodeMCU's USB driver is describedas the following:
Download NodeMCU V3 driver from this link: https://github. com/nodemcu/nodemcu-devkit/tree/master/Drivers
Connect NodeMCU development board to the USB port.
Run the driver installer _le: CH341SER.EXE, and install the driver as shown in Figure 5.
Open Device Manager in order to _nd NodeMCU's COM port as shown in Figure 6.
If you use NodeMCU V2, then the USB driver is different. NodeMCU V2 use CP210x USB to serial chip, while NodeMCU V3 use CH341 USB to serial chip. The installation process NodeMCU V2 USB driver is similar to NodeMCU V3 USB driver. You can download the NodeMCU V2 USB driver from https://www.silabs.com/ products/development-tools/software/usb-to-uartbridge-vcp-drivers.
You can also find NodeMCU V2 USB driver in Arduino software installation folder, under the driver folder, there is CP210x driver.
You can also use this driver for NodeMCU V2, so you do not have to download the driver. You have to manually install the driver from Device Manager by right clicking on the NodeMCU's USB port, select Update Driver Software menu, and search for the driver in arduino-x.x.x/driver folder.
ESP8266 Library
Installation
Arduino IDE will be used for programming ESP8266 in this book. At the time of writing, the latest Arduino IDE version is 1.8.5. You can download either the installed or the portable version. ESP8266 library is not included in Arduino IDE, so you must install it manually. The step-by-step how to install the ESP8266 library is described as the following:
Start Arduino IDE, go to File menu, and open Preferences window.
Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field as shown in Figure 7.
Go to Tools -> Board menu, open Boards Manager, and install esp8266 platform as shown in Figure 8.
Create the First
Program
For the very first program, we will create a simple program that turns on the ESP-12E's on-board LED. The code for turning on the on-board LED is shown in Listing 1.1. The on-board LED is connected to pin D4, and the circuit is active-low, so a logic LOW is needed to turn on the LED.
void setup()
{
//
Set on-board LED pin as output
pinMode(D4,
OUTPUT);
}
void
loop()
{
//
Turn on the active-low LED
digitalWrite(D4,
LOW);
}
To compile the code, go to Sketch -> Verify/Compile menu or click the checklist button in toolbar menu as shown in Figure 9. After the code is compiled without any error, you can connect NodeMCU to USB port, then go to Tools ->Port menu, and select the correct COM port as you found in Device Manager. To upload the code to NodeMCU, you can go to Sketch -> Upload menu or click the right arrow button in toolbar menu.
LED Circuit
In on-board-led program, when a logic LOW is written to the GPIO pin, then the LED will turn on. This is because the LED circuit is active-low. It is called active-low because a logic LOW is needed to activate (to turn on) the LED. The active-low LED circuit is shown in image 10. When a logic LOW is written to the GPIO pin, the current can flow from the 3.3V through the resistor and LED, and then flows to the GND. Therefore the LED is on. On the other hand, when a logic HIGH is written to the GPIO pin, the current can not flow through the resistor and LED. Therefore the LED is off.
0 Comments:
Post a Comment
If you have any doubts . Please let me know.