Description
The ESP8266 D1 Mini V2 ESP-12F WiFi Module is a powerful WiFi enabled processor in a compact package ideal for embedding into WiFi enabled projects.
PACKAGE INCLUDES:
- ESP8266 D1 Mini V2 ESP-12F WiFi Module
- Qty 2 – 1 x 8 Male Headers
- Qty 2 – 1 x 8 Female Headers
- Qty 2 – 1 x 8 Stackable Male/Female Headers
KEY FEATURES OF ESP8266 D1 MINI V2 ESP-12F WIFI MODULE:
- Microcontroller: ESP-8266 32-bit
- Clock Speed: 80 / 160MHz
- USB Converter: CH340
- 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
- Programming: Compatible with Arduino IDE and NodeMCU
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. These can be used as a stand-alone MCU in place of something like an Arduino or it can be used as a peripheral in conjunction with another MCU just to provide WiFi capability.
The module has a typical ‘Reset‘ button which resets the processor.
The module ships with a selection of headers depending on intended usage.
Digital and Analog I/O
All of the Digital I/O support PWM and interrupts except D0. 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 for other uses.
The blue on-board LED is connected to pin D4 (GPIO2) and can be accessed using the LED_BUILTIN constant.
Per spec, the digital I/O is limited to 3.3V, but the mfr has made statements that the digital pins are in fact 5V tolerant and there are many installations using the module directly connected to the logic lines of 5V MCUs.
The analog input is limited to a single 10-bit ADC input which is probably the most significant limitation for some sensor type applications. That limitation 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 analog input does need to be limited to a maximum voltage of 3.2V or less on the A0 pin. The module has a built-in 100K/220K resistor voltage divider on this pin that reduces the amplitude to a maximum of 1V at the ESP8266 processor which is the max that it can handle.
Powering the Module
The module can be powered via the USB port or by using an external 5V power supply connected to the 5V pin.
The 3.3V pin provides 3.3V output when powering the module from USB or 5V. This output can be used to power an attached module such as a sensor.
It is also possible to power the module directly from 3.3V by using the 3.3V pin as an input, but in that case the USB cable or external 5V cannot be connected or there will be a conflict on the 3.3V power line. Typically it is best to stick with powering the module from 5V.
Programming the Module
The board uses the CH340 chip for USB communications. If you have any issues with connecting to the board, you may need to download a driver. Just search for Arduino CH340 driver and you will find a number of sources for drivers depending on what Windows or Mac operating system you are using.
The module comes preloaded with the NodeMCU software that accepts the standard AT command set.
To test whether the board is basically working using the preloaded NodeMCU 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.
It 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 “LOLIN(WeMos) D1 R2 & Mini“.
- Set Upload Speed to “921600“.
- Select the port that the board is attached to. In my case it happened to be COM3
- 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 modules have good overall build quality.
Things to Watch Out For
The micro USB connector has a very small footprint and solder pads which makes it popular for small MCUs where space is limited. As with any MCU that uses the micro USB connector, some care should be taken not to put excessive upwards strain on the USB cable or it is possible for the connector to be dislodged from the board.
The D1 Mini (and ESP8266 processors in general ) have a couple of software quirks to be aware of compared to working with a standard Arduino.
First is that the compile and download 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 second thing is that 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 example program down 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 in your code. 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.
Example Setup
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. It sends the list of networks found to the Serial Monitor window.
In our example, we have a pushbutton attached to pin D6, but any digital pin can be used. Be sure to ground the other side of the button. The internal pull-up resistor is enabled on that pin, so an external resistor is not required.
ESP8266 D1 Mini V2 ESP-12F WiFI Module Example Program
/* * 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:
- Sample inspected and tested per incoming shipment
Notes:
- None
Technical Specifications
Microcontroller | ESP8266 Tensilica 32-bit | |
Serial to USB Converter | CH340 | |
Operating Voltage | 3.3V | |
Input Voltage | 3.3 or 5V | |
Digital I/O Pins | 11 | |
PWM I/O Pins (Shared with Digital I/O) | 10 | |
Analog Input Pins | 1 (10-bit) Max input 3.2V | |
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 pin 4 | |
USB Connector Style | Micro-B Female | |
Board Dimensions (PCB) | 34 x 26mm (1.3 x 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