Introduction To WEMOS D1 Mini
WEMOS D1 Mini is an ESP8266-based WiFi microcontroller which is developed by Espressif System and used for Internet OF Things(IoT) Applications. WEMOS D1 Mini has a total of 18 digital input output pins out of which 4 pins are used as Pulse width modulation or PWM pins. Having that much number of input-output pins eases the work of many project makers as they can add numerous amount of devices to it.
WEMOS D1 Mini is truly a small powerhouse board which has capabilities similar to any other board but with one advantage that it consumes less power as it has low power consumption. Along with WEMOS D1 Mini has a built-in boot loader which makes it easy to flash the board with the program which we want to run.
WEMOS D1 Mini has two variants available in the market which are WEMOS D1 Mini and WEMOS D1 Mini Pro and the difference between these two variants is that WEMOS D1 Mini Pro has an onboard USB to Serial converter and a Li PO battery charging circuit.
That is all in the introduction of the WEMOS D1 Mini now let us have a look at the board components of the board:
Board Components OF WEMOS D1 Mini
Microcontroller – The WEMOS D1 Mini is based on the ESP8266 and has a Tensilica Xtensa Diamond 32-bit processor.
ESP8266EX SoC – ESP8266EX SoC is a self-contained SOC with an integrated TCP/IP protocol stack that can give any microcontroller access to your WiFi network
3.3v Voltage Regulator – There is a 3.3v voltage regulator available on the board which is used for regulating the input voltage so that the board will not get damaged.
Antenna – WEMOS D1 Mini has an in-built antenna that is used for connecting the board to Wi-Fi connectivity. The presence of an inbuilt antenna helps in simplifying the design by eliminating the need for an external antenna
Power LED – There is an inbuilt power LED present in the WEMOS D1 Mini WiFi module which is red in color and it will start blinking when the board is connected to a power supply.
RESET Button – There is a RESET button available on the board which is used to reset the board whenever needed.
Board Specifications OF WEMOS D1 Mini
Board | ESP8266 WeMos D1 Mini |
Microcontroller | ESP8266 |
Processor | Tensilica Xtensa Diamond 32-bit |
Digital I/O Pins (with PWM) | 11 (11) |
Analog Input Pins | 1 |
Resolution ADC | 10 bit (0…1023) |
Analog Output Pins | 0 |
Interfaces | SPI 1/ UART 1/ I2C 1/ I2S 1 |
Flash Memory | 4 MB |
SRAM | 64 KB |
EEPROM | 512 bytes |
Clock Speed | 80/160 MHz |
Length x Width | 34mm x 26mm |
WIFI | IEEE 802.11 b/g/n |
Bluetooth And Touch sensor Availability | no |
USB connection | micro USB type C |
Programmable | Arduino IDE, LuaNode SDK, Micropython |
3.3V Voltage Regulator | Yes |
Power Consumption OF WEMOS D1 Mini
Total Current Consumption | 0.13 mA |
Output Voltage | 3.3V |
Maximum Input Voltage | 6V |
Minimum Input Voltage | 4.3V |
Maximum Output Current | 500mA |
Light Sleep [mA] | 0.68 |
Deep Sleep [mA] | 0.17 |
Max DC Current per I/O Pin | 12 mA |
Pinout OF WEMOS D1 Mini
Pin | Function | ESP-8266 Pin Mapping |
TX | TXD | GPIO 1 |
RX | RXD | GPIO 3 |
A0 | Analog input, max 3.3V input | A0 |
D0 | IO | GPIO16 |
D1 | IO, SCL | GPIO5 |
D2 | IO, SDA | GPIO4 |
D3 | IO,10k Pull-up | GPIO0 |
D4 | IO, 10k pull-up, BUILTIN_LED | GPIO2 |
D5 | IO, SCK | GPIO14 |
D6 | IO, MISO | GPIO12 |
D7 | IO, MOSI | GPIO13 |
D8 | IO,10k pull-down, SS | GPIO15 |
G | Ground | GND |
5V | 5V | – |
3V3 | 3.3V | 3.3V |
RST | Reset | RST |
Power Pin
This pin is used for input voltage or for powering up the board. The input voltage is a direct current supply voltage which ranges between 4.3v to 6v. The input voltage is used to regulate the integrated circuits which are used in the connections. Vin is also known as the primary voltage source on the WEMOS D1 Mini board.
5V pin
The 5v pin is used as the output for external components. The output is 5v. The power source of the 5v pin is a USB connector or we can say that this pin is used only when the board is powered by USB.
3V3 Pin
The 3V3 pin is used as an output pin which powers an external circuit. This pin generates an output voltage of 3.3 volts.
RESET Pin
The RESET pin is used to reset the microcontroller. For resetting the microcontroller we have to pull down this pin to LOW
Input Output Pins
Digital I/O Pins
There are a total of 9 digital input/output pins available on the WEMOS D1 Mini board. The digital pins are used as an input or output according to the requirement. The digital pins are only able to read two values which are:-
- High
- Low
However, we can use 1 for high state and 0 for low state. When these pins receive 0V they are in a LOW state and when they receive 5V they are in the HIGH state.
The digital pins on the WEMOS D1 Mini board board are from D0 to D8
S.NO | Pin Number | Type | Pin Name |
1 | D0 | I/O | Digital I/O Pin |
2 | D1 | I/O | Digital I/O Pin |
3 | D2 | I/O | Digital I/O Pin |
4 | D3 | I/O | Digital I/O Pin |
5 | D4 | I/O | Digital I/O Pin |
6 | D5 | I/O | Digital I/O Pin |
7 | D6 | I/O | Digital I/O Pin |
8 | D7 | I/O | Digital I/O Pin |
9 | D8 | I/O | Digital I/O Pin |
Analog Pin
There is only 1 analog pin available on the WEMOS D1 Mini board. Analog Input Pin is used to take the signal from analog sensors and then convert it into a digital value. Analog pins can receive any value, unlike digital pins. It can receive value not only in high or low state but in other forms also. The analog pin of the board is Pin A0.
S.NO | Pin Number | Type | Pin Name |
1 | A0 | Input | Analog Input Channel 0 |
PWM Pin
There are a total of 9 pins available on WEMOS D1 Mini which are also known as Pulse Width Modulation pins. The work of these PWM pins is to convert the digital inputs to analog output. These pins provide 8-bit PWM output with the analogWrite () function.The PWM pins of WEMOS D1 Mini board are D0, D1, D2, D3, D4, D5, D6, D7 and D8.
S.NO | Pin Number | Type | Pin Name |
1 | D0/PWM | I/O | Digital I/O PinPulse Width Modulation Pin |
2 | D1/PWM | I/O | Digital I/O PinPulse Width Modulation Pin |
3 | D2/PWM | I/O | Digital I/O PinPulse Width Modulation Pin |
4 | D3/PWM | I/O | Digital I/O PinPulse Width Modulation Pin |
5 | D4/PWM | I/O | Digital I/O PinPulse Width Modulation Pin |
6 | D5/PWM | I/O | Digital I/O PinPulse Width Modulation Pin |
7 | D6/PWM | I/O | Digital I/O PinPulse Width Modulation Pin |
8 | D7/PWM | I/O | Digital I/O PinPulse Width Modulation Pin |
9 | D8/PWM | Input | Digital I/O Pin Pulse Width Modulation Pin |
Communication Pins of WEMOS D1 Mini
I2C Pins
The WEMOS D1 Mini board supports the I2C communication protocol. It stands for “Inter-Integrated Circuit.” It is a two-wire serial communication protocol. It uses two pins for communication purposes. One of them is used to send data while the other pin is used to receive data.
The two pins of the I2C protocol are the serial Clock Pin(SCL)” and “Serial Data Pin(SDA)”.
- SCL – It is defined as the line or pin which transfers the clock data. SCL pin is used to synchronize the shift of data in between two devices. This signal is generated by the master device. It is a clock line.
- SDA – It is defined as the line or pin which is used by slave devices to send and receive data. It is a data line.
I2C pins on the board are D2 which is SDA and D1 which is SCL.
S.NO | Pin Number | Type | Pin Name |
1 | D2/SDA | I/O | Digital I/O PinSerial Data Pin |
2 | D1/SCL | I/O | Digital I/O PinSerial Clock Pin |
SPI Pins
The WEMOS D1 Mini board supports the “Semi-Peripheral Communication Protocol” or SPI. The SPI protocol is used to develop communication between the controller device and its peripheral devices. Three pins are needed for SPI communication protocol which are:-
- MISO – It stands for Master Input/Slave Output. This data line sends data to the master device.
- MOSI – It stands for Master Output/Slave Input. This data line is used for sending data to slaves/peripheral devices.
- SCK – This pin is used to synchronize the data transfer between the master and slave device.
SPI pins on the board are D5 which is used as the SCK pin, D6 which is used as the MISO pin, and D7 which is used as the MOSI pin.
The Pins MISO and MOSI are also known as CIPO and COPI which stand for “Controller In Peripheral Out” and “Controller Out Peripheral In” respectively.
S.NO | Pin Number | Type | Pin Name |
1 | D5/SCK | Output | Clock From Master To Slave |
2 | D6/MISO | I/O | Master In Slave Out |
3 | D7/MOSI | I/O | Master Out Slave In |
UART Pins
The WEMOS D1 Mini consists of a UART communication protocol which is used for serial communication of data. It needs two pins for the communication purpose which are Rx and TX.
- Rx – This pin is used to transmit the serial data.
- TX – This pin is used to receive the serial data.
UART pins on the board are GPIO 1 which act as TX pin and GPIO 3 which act as Rx pin
S.NO | Pin Number | Type | Pin Name |
1 | TX | I/O | Serial TX Pin |
2 | RX | I/O | Serial RX Pin |
GND Pin
This pin is used as the ground pin of the board.
S.NO | Pin Number | Type | Pin Name |
1 | GND | Power | Supply Ground |
Programming OF WEMOS D1 Mini
The programming of WEMOS D1 Mini consists of several stages. One of the major stages of this is installing the relevant and important library for it. We are going to use the ESP Microgear library for this purpose.
ESP Microgear Library
ESP Microgear library is a library designed for the ESP8266 microcontrollers. This library allows microcontrollers to connect to the Network of Things Platform for Everyone service(or NETPIE), which is a cloud-based IoT platform developed by the National Electronics and Computer Technology Center(or NECTEC).
With the help of the ESP Microgear library, we can easily establish communication between ESP8266 devices and the NETPIE platform which will enable seamless data exchange, remote control, and monitoring capabilities for us.
Installing The Drivers
For connecting our board to the computer we are going to use the CH340 driver. It works great and does not cause any problems. You can download the driver from the link given below
Link to download the CH340 driver
Installing The Board Manager
Now, that we have downloaded the driver it is time to install the board manager. For this purpose go to File ->Go to preferences -> then go to Additional boards Manager URLs -> paste the link given and click ok http://arduino.esp8266.com/stable/package_esp8266com_index.json Detail article on How to Program ESP8266 Nodemcu using Arduino IDE
Install The Library
Once we download the board now go to Sketch -> Include library -> Manage libraries -> then inside the search box type ESP8266 Platform -> We have to download ESP Microgear Library.
Connecting The Board
Connect the WEMOS D1 Mini board to the USB port on the PC using a data cable. Now we have to tell the Arduino IDE about the board we are using and for this purpose go to Tools -> Boards -> WeMos D1 R2 & Mini and make sure that the WEMOS com port is selected.
Uploading The Sketch
Now that we have connected the board and completed all the prerequisites it’s time to upload the sketch and check if everything is working perfectly.
We are going to upload the blinky sketch.
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // Arduino: turn the LED on (HIGH)
// D1 Mini: turns the LED *off*
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // Arduino: turn the LED off (LOW)
// D1 Mini: turns the LED *on*
delay(1000); // wait for a second
}
Frequently Asked Questions
Q1 – What is the difference between Arduino Uno and WeMos D1?
Ans – WEMOS D1 has a strong processor that runs at a higher frequency than Arduino UNO Also WEMOS D1 mini has 160KB of RAM memory while Arduino UNO only has 2KB of RAM memory.
Q2 – What are the advantages of using WeMos D1 mini?
Ans – The advantage of using WEMOS D1 Mini is that it can be used as a stand-alone for processing each code without using Arduino as its microcontroller.