Getting started with the WeMos D1 ESP8266 WiFi Board

The WeMos D1 is a ESP8266 WiFi based board that uses the Arduino layout with a operating voltage of 3.3V. As the documentation of this board online can be a little confusing, the purpose of this tutorial is to combine and simplify the steps needed to setup this board for development. With that, let’s proceed on with the specifications of the board.

Note: This is NOT an Arduino board, it only uses the Arduino Uno layout for the board design!

Specifications

Here are the specification of the board:

Microcontroller ESP-8266EX
Operating Voltage 3.3V
Digital I/O Pins 11
Analog Input Pins 1
Clock Speed 80MHz/160MHz
Flash 4M bytes
Length 68.6mm
Width 53.4mm
Weight 25g

In summary, the board is controlled by the ESP8266 chip (a 32-Bit processor) and has a larger flash memory compared to an Arduino Uno. It consists of 11 digital I/O pins and 1 analogue (input) pin. the board can be connected using a Micro-B type USB cable. (Aka “Android Cable”)

Pinouts

All the I/O pins:

  • Runs at 3.3V
  • Have interrupt/PWM/I2C/one-wire support except D0
Pin Function ESP-8266 Pin
TX TXD TXD
RX RXD RXD
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

IDE

There are 2 IDE that can be used to program the ESP8266:

  • The Arduino IDE
  • The NodeMCU IDE

In this tutorial, we’ll be looking at how to setup the board with the Arduino IDE on Windows. (For installation on a Linux-based system, you can visit this website, though the installation instructions are very similar: https://www.wemos.cc/tutorial/get-started-arduino.html)

Software Requirements

Installation

Create a new folder esp8266com/esp8266 in your Arduino sketch directory. (The Arduino sketch location should be located in “My Documents > Arduino” by default).

Next, download the library/driver file (as zip) from Github: https://github.com/esp8266/Arduino

After the download has completed, copy the zip file over to the [Arduino sketch]/hardware/esp8266com/esp8266 directory & extract the contents. A Arduino-Master folder will be created.

Next, enter the directory and drag all the content into the main directory. Finally, remove both the Arduino-master.zip and the Arduino-master folder. Your directory now should look like this:

Open the terminal and enter the esp8266/tools folder. (e.g. [Arduino sketch]/hardware/esp8266com/esp8266/tools) After that, exceute the get.py script via the python command.

This will download the Binary Tools required to program the board. Once the installation has completed, it should look like that:

With that, you are ready to test out your WeMos D1 board!

Examples

Blink

To test out whether the hardware library/driver is properly installed, we’ll be testing out the sample program Blink, an equivalent to the Hello World! example in the Hardware environment. To do so, start the Arduino IDE and open the sketch at the following location:

C:\Users\[username]\Documents\Arduino\hardware\esp8266com\esp8266\libraries\esp8266\examples\Blink

If you are lazy, just copy the code below:

After opening the sketch file,  go to Tools > Board and select the “WeMos D1 R2 & Mini” option. Connect the WeMos Board & upload the code. The LED on the ESP8266 will start to blink. (If the LED on the ESP8266 is blinking when a USB is plugged, you can try modifying the “delay” values to see whether it updates accordingly.)

 

Checking out the Chip ID

To check the ID of the chip, copy the code below & upload into the WeMos D1 board.

After the code has been uploaded, open up the Serial Monitor and set the baudrate to 115200. The ID should be printed in the monitor.

 

Running a Simple Web Server

For this section, the ESP8266 will be ran as a simple server in a local network, hosting a simple HTML file at port 80. Go to the following directory & open up HelloServer.ino.

C:\Users\[username]\Documents\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WebServer\examples\HelloServer

Alternatively, you can copy the code below:

Before uploading the code, you have to change 2 variable value: ssid and password. Replace them with your router’s ssid (or connection name) and the password accordingly. For example, if the router name is “router-17” and password “1234”, the variables would look something like this:

After changing the variable values, upload the code and open up the Serial Monitor. (Set the baud rate to 115200) If the board is connected to the network, it will display it’s IP address. Assuming that your computer is connected to the same network, copy the IP address of the server and paste it over at your preferred web browser. The webpage would display a simple “Hello from esp8266!” webpage.

 

References/Resources

  • https://www.wemos.cc/product/d1.html
  • https://github.com/wemos/D1_mini_Examples/blob/master/examples/02.Special/GetChipID/GetChipID.ino
  • http://educ8s.tv/arduino-esp8266-tutorial-first-look-at-the-wemos-d1-arduino-compatible-esp8266-wifi-board/
Share this post:

You may also like...