WeMOS D1 ESP8266 Arduino compatible, its specs and how to use it
Table of Contents
WeMOS D1:
The WeMOS d1 which is an Arduino compatible board with the built-in ESP8266 Wifi Module. WeMos D1 Arduino compatible development board is the cheapest WiFi-enabled board available today. It is a WiFi enabled based on the ESP8266 chip. The board looks like an ordinary Arduino board. The dimensions and the pin layouts are exactly the same. So, this board is compatible with all the existing shields for Arduino. But don’t expect them to work at once, since the libraries available for the ESP8266 chip are few so far. The boards, instead of an ATMEGA chip that standard Arduino boards use, use the impressive ESP8266 WiFi chip. The ESP8266EX chip that the WeMos D1 board uses offers:
- A 32 bit RISC CPU running at 80MHz
- 64Kb of instruction RAM and 96Kb of data RAM
- 4MB flash memory!
- Wi-Fi
- 16 GPIO pins
- I2C,SPI
- I2S
- 1 ADC
First of all you are going to notice there is no Atmel chip on the board. The esp8266 is the heart of the board acting not only as the WiFi chip but also as the main processor, other ICs on the board include the CH340 which is our UART USB. ESP8266 D1 R1 IOT board which is an alternative to NodeMCU this is built on ESP12e IC.
It has got a USB socket for power as well as serial communication. A separate power adapter is also there onboard, a 3.3 volt regulator is there so you can use an external adapter up to 12 volt. For our interface it has a micro USB, and then we have our CH340 chip, and having a reset switch. It consists of barrel Jack for DC input and we have got a selection of pin headers TX and RX. For I2C communication it has SDA and SCL pins and have digital pins which are D3, D4, D5, D6, and D7. Then we have another I2C communication pins which are copy of D1 and D2. This board only has the one analog input. We have Vin, ground, 5 volt, 3.3 Volt, and reset. Then we have some extra pin headers for 3.3 volts, RX, TX, and ground.
WeMOS D1Features:
- 11 digital IO, interrupt/pwm/I2C/one-wire supported(except D0)
- 1 analog input(3.2V max input)
- a Micro USB connection
- Compatible with MicroPython, Arduino, nodemcu
WeMOS D1Technical specs:
Operating Voltage | 3.3V |
Digital I/O Pins | 11 |
Analog Input Pins | 1(3.2V Max) |
Clock Speed | 80/160MHz |
Flash | 4M Bytes |
Size | 34.2*25.6mm |
Weight | 3g |
WeMOS D1Pin Description:
Pin | Function | ESP-8266 Pin |
TX | TXD | TXD |
RX | RXD | RXD |
A0 | Analog input, max 3.2V | 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 |
Comparison of the WeMOS D1 with Arduino:
The Wemos D1 has 32 bit processor that runs at a much higher frequency. The performance difference with a standard Arduino, I expect to be huge. The Arduino Uno, offers 2KB of RAM memory and this chip has 160Kbs. The Flash memory of the WeMOS D is also 100 times bigger than Arduino. Of course, the main reason that everyone is using this chip, is that it has embedded WiFi. All that for less than 10$. The hardware looks fantastic.
Interfacing the WeMOS D1 with Arduino IDE:
The WeMOS D1board build is just like Arduino UNO and as such you do not need Arduino UNO. To work with this board using board manager you can convert this board to Arduino and then use the Arduino IDE for programming. There are two versions of this board R1 and the R2 only the pin mapping is slightly different but for that both the boards are same plug in the USB socket to PC and then open the device manager to get the com port allotted, for this you have to install the driver ch340 driver for PC to recognize this port once the board is recognized a com port is allotted. Open the Arduino IDE select the port allotted and then upload speed is 115200.
Now to install the WeMOS in the Arduino ide you need to go file preferences
After clicking on the preferences a dialog box will appear down in the additional boards manager you need to type in copy or paste the following link
http://arduino.esp8266.com/stable/package_esp8266com_index.json
After this process is completed we come over to our board manager.
It will take a second and you just need to find this one here esp8266 by esp8266 community click on more info and we are going to install the latest version
In the next step we will select the board we need; will go to tools > board > ESP8266 boards and scroll down till we find WeMOS d1 R1and mini click that
Now the interfacing is completed, in the next step we will upload code. We can load an example so our example in this case we will go to the esp8266 and we will choose blink
WeMOS D1 Code:
So there we have our code:
1 2 3 4 5 6 7 8 9 10 11 12 |
void setup() { pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output } // the loop function runs over and over again forever void loop() { digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level // but actually the LED is on; this is because // it is active low on the ESP-01) delay(1000); // Wait for a second digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off by making the voltage HIGH delay(2000); // Wait for two seconds (to demonstrate the active low LED) } |
As you can see it is exactly the same as your standard Arduino code and let’s send it and see what we get after uploading the code to WeMOS d1, the led in the WeMOS will start blinking after 1 second.
After a while the LED on the ESP8266 chip will start flashing. Note, that this is not the standard Blink sketch we were using so far. It is a similar one developed for the ESP8266. Due to the different hardware architecture of the ESP8266 most programs will not work without modifications. Also most of the libraries need to be re written in order to work as well. That’s a lot of work that needs to be done.The first thing I wanted to find out was if it is easy to connect to the internet with this board.
Interfacing relay with Wemos D1:
We are going to control basically anything in your house from the internet and really I mean that’s why you bought an esp8266 so that you can turn things on and off from a different place. Now we are going to turn on and off a relay. The relay that we are using can control up to 10 amps 250 volts AC or 10 amps 125 volt AC and 10 amps 30 volt DC. It’s got three contacts in the center is your common on the right is your normally closed and on the left is your normally open. So when you activate the relay your normally closed contacts opens and you are normally open contacts closes. So if you want something that’s lonely off that you want to be able to turn it on you plug it into the open and the common. Now at the other end of the relay it has only three pins signal positive and negative. We will connect the signal pin of the relay module with the pin d4 on our esp8266 board and connect the VCC and ground of the relay with the 5 volts and ground of the WeMOS board. You could plug a light, motor, fan, heater, air conditioner whatever you want and control it over the Internet with the relay.
Note: this old version of the Blynk app is no more functional. For the blynk mobile App setup and Blynk.cloud dashboard setup ready my article on the New Blynk V2.0. In this article I have explained how to migrate your projects from Blynk 1.0 to the new Blynk V2.0. You can also watch the video.
Creating Application in Blynk:
In order to control the relay from the mobile first we will create the application in the blynk app. If we do not have blynk app in the mobile first we will download the blynk app from the play store.
After installing the blynk app create a new account in the blynk. After creating the account click on the new project.
Now give name to the project in our case we are controlling relay so we give the name relay control and click on the create
After that a token will be sent to the email through which you are login. We will use this token in Arduino code which is:
MMitf22Wsqo9yjohsXnNvC4k8U3XdQiT
Now a screen will appear in which we will make button by click the “+” sign button menu will appear in which we will select the button.
Now rename the button with name relay and click on the output and select the GP4 pin.
Now change the slide bar from push to switch
Now the blynk application is created after that we will code in the Arduino ide.
WeMOS D1 Control a Relay Code:
Before coding we will select the board go to tools in Arduino ide and select the board a dialog box will appear in ESP8266 menu select Node MCU 1.0 (ESP 12 E module).
‘
After selection of board we will first install blynk library:
In the tools select the manage libraries
Now write blynk and click on install
Now after installing the blynk library go to file in file select the examples select the blynk then select board WiFi and then select ESP 8266 standalone.
After that code example will appear.
WeMOS D1 Relay control Complete Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#define BLYNK_PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). // insert the Auth code char auth[] = " MMitf22Wsqo9yjohsXnNvC4k8U3XdQiT"; // Your WiFi credentials. // Set password to "" for open networks. // Write the network name in code to which you want to connect the module char ssid[] = "electronicclinic"; // set the password char pass[] = "123456"; void setup() { // Debug console Serial.begin(9600); Blynk.begin(auth, ssid, pass); } void loop() { Blynk.run(); } |
Now to see the working of the project we will open the blynk application and by pressing the button, bulb will be turned on and clicking again the button the bulb will be turned off.