Description
The ESP8266 NodeMCU V1.0 ESP-12E WiFi module is the latest version of this popular module and can be used as a WiFi enabled replacement for an Arduino in many applications.
PACKAGE INCLUDES:
- ESP8266 NodeMCU V1.0 ESP-12E WiFi Module
Key Features of ESP8266 NodeMCU V1.0 ESP-12E Module:
- Microcontroller: ESP-8266 32-bit
- Clock Speed: 80 MHz
- USB Converter: CP2102
- USB Connector: Micro USB
- Operating Voltage: 3.3V
- Flash Memory: 4 MB
- Digital I/O: 11
- Analog Inputs: 1
- Communications: Serial, SPI. I2C and 1-Wire via software libraries
- WiFi: Built-in 802.11 b/g/n
Besides adding WiFi capability, the main claim to fame for the ESP8266 processor over the AVR processor of the standard Arduino is that it has a larger 4 MB of Flash memory and runs at clock speeds of 80 MHz and can sometimes optionally be overclocked to 160 MHz and therefore has a very fast processing speed.
The Digital I/O all support PWM and interrupts. In addition they can be configured to have pull-up or pull-down resistors. Though there are 11 digital I/O pins, 2 are typically reserved for use as the TX/RX lines if serial communications are used which leaves 9 digital I/O.
On the down-side, it has only 1 analog input which is probably the most significant limitation for some sensor type applications. That can always be overcome by using an external Analog Mux module like our 16-channel 74HC4067 or our ADS1115 4-channel 16-bit ADC module below if more analog I/O is desired.
The module can be powered via the USB port or by using an external 7-12V power supply connected to the VIN pin. The module runs at 3.3V, so keep that in mind when working with I/O. The digital I/O is stated as being 5V tolerant, but the analog input needs to be limited to < 3.3V.
The blue on-board LED is connected to D0 (GPIO16) and can be accessed using the LED_BUILTIN constant.
The module has a typical ‘Reset’ button as well as a ‘Flash’ button. The Flash button is used when programming using the original NodeMCU firmware. If the module is being used with the Arduino IDE, the Flash button does not need to be used to program the board and it will program just as any Arduino board would.
The module comes loaded with the NodeMCU software that accepts the standard AT command set. The module was initially designed primarily to be programmed using Lua which is an interpreted language, but Lua has been mostly abandoned because it takes up a lot of memory and is slow because it is interpreted and more importantly it is generally buggy.
It can also be programmed in C using the Arduino IDE and is how the modules are most often used. An example program is shown down below. If a program is download via the IDE, it will overwrite the NodeMCU software or whatever else was loaded before. If that is a problem for what you want to do, the NodeMCU software can always be reloaded.
There are many instructions for installing and using ESP8266 based boards with the Arduino IDE, but here is a short-hand version. Note that once the ESP8266 board type is added to the IDE, there will be many more items added to the Tools drop down menu.
- Open Preferences window and enter the following into the ‘Additional Board Manager URLs’ field: “http://arduino.esp8266.com/stable/package_esp8266com_index.json“.
- Under Boards Manager, install ESP8266 by ESP8266 Community.
- Under Tools/Boards select “NodeMCU 1.0(ESP-12E Module)“.
- Set Upload Speed to “115200“.
- Select the port that the board is attached to. In my case it happened to be COM19
- In the Serial Monitor window, set comm rate to 115200 and line ending to Both NL & CR
Here is what it looks like on my setup.
Our Evaluation Results:
These assemblies have good build quality
To test whether the board is basically working using the preloaded software, you can open a Serial Monitor Window and simply enter ‘AT‘ into the serial monitor top window and hit ENTER. The board should return with ‘OK‘. That indicates the board is alive and the setup is working. If you don’t get the OK, make sure that you have the correct comm port selected, the serial monitor window is set to a baud rate of 115200 and the line ending is set to Both NL & CR.
The NodeMCU has a couple of quirks to be aware of compared to a standard Arduino.
First is that the compile time when using the IDE tends to be longer than for typical Arduino boards. This is especially true the first time a program is compiled or if the build options are changed which require a complete recompile. Subsequent compiles do run faster.
The module does not like long delays in code and it may cause the module to do a watchdog software reset. This is because the module has a network stack to handle the WiFi and that needs to be serviced regularly by the processor. An example of what not to do would be using something like a tight DO/WHILE loop waiting for a button to be pressed.
For instance in the program below, if you were to check the button using code like this which blocks the program until the button is pushed, you will run into this problem as it does not allow any free time for the processor to go off and reset the watchdog timer on occasion, so it thinks it has locked up and resets itself.
Do { btn_Status = digitalRead (BUTTON_PIN) } while (btn_Status == HIGH)
If the module keeps resetting every couple of seconds, look for this blocking type of issue. This can be resolved by inserting the yield() function into the loop as that function lets the processor go off and take care of other business before returning to the loop.
Using the delay() function does not create the same blocking issue because the delay() function internally calls the yield() function every so often.
The program below is based on one of the sample programs ‘WiFiScan’ that is available once the ESP8266 boards are loaded into the IDE. The version here also adds a button to initiate the scan for any available WiFi networks and turns on the on-board LED while a scan is in process to show use of some general I/O.
In our example, we have a pushbutton attached to pin D6, but another digital pin can be used. Be sure to ground the other side of the button. The internal pullup resistor is enabled on that pin, so an external resistor is not required.
/* * This sketch demonstrates how to scan for available WiFi networks. * A button input is used to initiate the scan and the on-board LED * is lit to indicate when a scan is in process * Connect one side of the pushbutton to ground and the other side to * pin D6 or any of the other digital input pins. */ #include "ESP8266WiFi.h" const int BUTTON_PIN = D6; // Define pin the button is connected to //=============================================================================== // Initialization //=============================================================================== void setup() { pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output pinMode(BUTTON_PIN, INPUT_PULLUP); // Initialize button pin with built-in pullup. digitalWrite(LED_BUILTIN, HIGH); // Ensure LED is off Serial.begin(115200); // Set comm rate to 115200 // Set WiFi to station mode and disconnect from an AP if it was previously connected WiFi.mode(WIFI_STA); WiFi.disconnect(); delay(100); Serial.println("Setup done"); } //=============================================================================== // Main //=============================================================================== void loop() { int btn_Status = HIGH; btn_Status = digitalRead (BUTTON_PIN); // Check status of button if (btn_Status == LOW) { // Button pushed, so do something Serial.println("scan start"); digitalWrite(LED_BUILTIN, LOW); // Turn LED ON // WiFi.scanNetworks will return the number of networks found int n = WiFi.scanNetworks(); Serial.println("scan done"); if (n == 0) Serial.println("no networks found"); else { Serial.print(n); Serial.println(" networks found"); for (int i = 0; i < n; ++i) { // Print SSID and RSSI for each network found Serial.print(i + 1); Serial.print(": "); Serial.print(WiFi.SSID(i)); Serial.print(" ("); Serial.print(WiFi.RSSI(i)); Serial.print(")"); Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" : Unsecure":" : Encrypted"); delay(10); } } Serial.println(""); digitalWrite(LED_BUILTIN, HIGH); // Turn LED Off } }
Before they are shipped, these modules are:
- Inspected
- Powered up checked using the ‘AT’ command
- Repackaged in high quality resealable ESD bag for safe storage.
Notes:
- None
Technical Specifications
Microcontroller | ESP8266 Tensilica 32-bit | |
Serial to USB Converter | CP2102 | |
Operating Voltage | 3.3V | |
Input Voltage (recommended) | 7-12V | |
Digital I/O Pins | 11 | |
PWM I/O Pins (Shared with Digital I/O) | 10 | |
Analog Input Pins | 1 (10-bit) | |
DC Current per I/O Pin | 12mA (Max) | |
Hardware Serial Ports | 1 | |
Flash Memory | 4 MBytes | |
Instruction RAM | 64 KBytes | |
Data RAM | 96 KBytes | |
Clock Speed | 80MHz | |
Network | IEEE 802.11 b/g/n WiF | |
Built-in LED | Attached to digital pin 13 | |
USB Connector Style | Micro-B Female | |
Board Dimensions (PCB) | 69 x 53mm (2.7 x 2.1″) | |
Country of Origin | China | |
Datasheet | ESP8266EX |
FURTHER READING
Martyn Currey has an excellent series of articles related to using wireless communications, especially with Arduino. This is a link to a series of his articles related to the ESP8266