loading

In this Instructable I will guide you through the steps needed to install, configure and program the WeMos-D1R2 board using the Arduino IDE.

WeMos-D1R2 is an ESP8266-12 based WiFi enabled microprocessor unit on a Arduino-UNO footprint. That means the board looks and works (in most cases) like an UNO. Apparently several shields, sensors and output devices that are manufactured for the Arduino platform will work on the WeMos-D1R2 with the added advantage of builtin WiFi.

There are two WeMos boards in the market.If you are not careful you will end up with a D1 Board which is an older version. You have to make sure you have the current version of the board WeMos-D1R2. I bought my WeMos-D1R2 from Banggood, I believe it is a Hong Kong based online retailer. The quality of the product is good and has a short delivery time, about two weeks to the US. They carry the genuine WeMos-D1R2. There are several older model WeMos-D1 being sold as WeMos-D1R2 to unsuspecting customers by several other vendors.

You will find several similarities between this Instructable and my previous one - Programming the ESP8266-12E using Arduino software/IDEbecause of the fact that the ESP8266-12 is the foundation of the WeMos-D1R2 board. In some cases I have copied and pasted the complete steps.

Step 1: Differences Between the I/O Pins.

Though the Arduino UNO and the WeMos-D1R2 are similar, there are a few differences in their pin assignment. The above illustration provides the mapping of the pins. In some situations programs written for the UNO will need to be modified a little to the proper pin assignments of the WeMos-D1R2. More on this when we write our first sketch.

Step 2: Getting Started - Connect the WeMos-D1R2 to Your Computer

The WeMos-D1R2 board comes without an USB cable. Make sure you have a data cable and not a ordinary charging cable. A data cable causes your Windows OS to react. It announces the attachment of a new hardware and tries to install the USB drivers. It either finds the driver on your system or it does not. If it does not then you will need to download the USB drivers. The USB interface chip is the CH340G. You will need to install the drivers for this chip.

A Google search for the "CH340G drivers" finds several sites. You can download the Windows 7 drivers from here or the Windows 8 from here. Though I have not tried them, other operating systems can be downloaded from here. Some flavors of Windows operating system come with the drivers.

Step 3: Is the WeMos-D1R2 Happily Communicating With Your Computer?

Lets find out if the WeMos-D1R2 and your computer are communicating with each other. Getting this step right is important for any further action. Open the Device Manager via Control Panel| Hardware and Sound.

Step 4: Installing Arduino Software/IDE

I downloaded the most current Arduino software (Version 1.6.8) from here. It is a Windows installer exe file so double clicking on it will start the installation including the installation of several peripheral drivers. You can find detailed instructions to install the Arduino software here.

Once the Arduono software is installed, I tested the install by connecting an existing Arduino Uno that I had and uploaded the Blink sketch. All systems worked as they were supposed to.

Step 5: Where to Find the Arduino IDE Preferences Dialog

You will need to familiarize yourself with the File| Preferencesdialog box. We will need this info later.

Step 6: Where to Find the Arduino IDE Boards Manager Dialog

You will also need to know about the Tools | Board:… | Boards Manager dialog box. You have an older version of Arduino software if you cannot see Board Manager in the menu. Go update your software.

Step 7: Telling Arduino Where to Find the Wemos-D1R2 Library

The WeMos-D1R2 board can be added to the Arduino software/IDE by installing the necessary libraries. This community supported Github page: Unofficial list of 3rd party boards support has the information needed to get your Arduino software to support the WeMos-D1R2. Search/look for “ESP8266” on this webpage. Look for the URL shown in the image above. Copy and paste that URL into your Preferences dialog and select OK. Else you can copy the following and paste into your Preferences dialog and select OK: http://arduino.esp8266.com/stable/package_esp8266com_index.json Either case do not click on the URL.

Step 8: Installing the WeMos-D1R2 Board Via the Board Manager

Open Tools | Board:|Boards Manager dialog box. Somewhere in there you will see the entry “esp8266 of ESP8266 Community version 2.1.0” select that. The Install button will appear, click the Install button. Wait for a while… This process will take some time to download and complete. After the install it is a good idea to shut the Arduino program and restarted it.

Step 9: Determining the COM Port WeMos-D1R2 Shows Up On

If not connected connect the Wemos-D1R2 board to your computer. Give it a couple of minutes to get to know the computer. Go to Control Panel| Hardware and Sound| Device Manager and click on Ports (COM & LPT). There you will find the port number that your Wemos-D1R2 is connected on. In my case it is COM12. Make a note of that, we need this info later.

Step 10: Selecting the WeMos-D1R2 Board

Go to Tools | Board:… scroll way down and select WeMos D1 R2 & mini. The Tools menu changes to the second image shown above.

Step 11: Configuring COM Port

In a Step 9 we had determined the COM port WeMos-D1R2 appears on. To select the COM port, go to Tools | Port: and select the COM port, in my case it was COM12.

Step 12: Configuring COM Port Speed

To select the speed of communication between the WeMos-D1R2 and the computer. Go to Tools | Upload Speed: and select 115200. We are ready to upload our first sketch.

Step 13: Test Drive the Setup

Test drive the complete setup using the boiler plate sketch.
To upload the boiler plate sketch go to Sketch | Upload or use the shortcut key Crtl+U or click on the right arrow button next to the check mark. A successful compile and upload means all systems are working and we are ready to get to the real stuff.

Step 14: Trying the Blink Example

Load the packaged example Blink. To find it go to File | Examples | 01.Basics | Blink. Compile and upload as instructed in the previous step. Nothing happens. :(

The reason nothing happens is because the on board LED on the UNO is connected to pin 13. Refer to the table in Step 2. On the WeMos-D1R2 the on board LED is connected to pin 14.

Replace all instances of pin 13 with pin 14 and save the sketch as WeMosBlink. Compile and upload as instructed in the previous step. Viola the blue LED starts blinking.

Replace all instances of pin 13 with pin 2 and save sketch. Compile and upload as instructed in the previous step. The blue LED on the ESP8266-12 module starts blinking.

Disconnect the WeMos-D1R2 from your computer and connect an external 5V power source. I connected it to the power bank that I use to charge my phone. The LEDs will start blinking.

We aren't WiFing yet. That will be in the next Instructable. Time permitting I will write one soon. If you feel motivated enough try adopting my previous Instructable Programming a HTTP Server on ESP-8266-12E to the WeMos-D1R2 and update me in the comments.

Happy IoTing.

<p>Thanks a bunch! If only I had found this article Hours ago...</p>
<p>nice work!</p>
<p>excellent tutorial. keep posting good one. </p>
<p>Compiled file is HUGE. Blink is 222k. Seems to be adding all possible functions even if they are not used.</p>
<p>kekeke. There is a competition in Russia who writes the smallest blink on Arduino or AVR, the ex-top result was 2 bytes, and now is 0 (zero) bytes (blinking via FUSES). So blink with code size 222k seems ridiculous.</p>
<p>Sure, but 4M on the wemos, who cares, right? I have some smaller esp8266 with 8M, just in case :D</p>
<p>Excellent.</p>
<p>Great tutiorial, simple and &quot;to the point&quot;. Moving on to your next Wemo's D1 tutorial. Thank you.</p>
<p>Im super new to this and thank you very much for your help, its very precise and saved me a lot of nervous breakdown. Way to go. </p><p>I am trying to connect my wemos D1 mini to display data on a 1.8 screen tft (to get the weather) and all I get is a blank white screen when uploading example. Im not sure of my soldering skill. is there a way to know if the issue is hardware (soldering) or software (version issues and so on)?</p>
<p>White screen is a good first step, you just gotta make sure you match the pins.<br><br>I'm using ucglib and following did work for my D1 (I have a mini too but didn't try with that, yet):<br></p><p>Ucglib_ST7735_18x128x160_SWSPI ucg(/*sclk=*/ SCL, /*data=*/ SDA, /*cd=*/ D11 , /*cs=*/ D10, /*reset=*/ D12);<br><br>and wire the five pins scl, sda, cd (rs on my display), cs and rs to the correct pins.</p><p><br><br>btw, you know <a href="http://wttr.in" rel="nofollow"> http://wttr.in </a> ?</p>
<p>I am trying this (well at least trying to run examples for now) :</p><p><a href="https://www.instructables.com/id/Art-Deco-Weather-Forecast-Display/" rel="nofollow">https://www.instructables.com/id/Art-Deco-Weather-F...</a></p><p>Just a blank screen, with any library I tried. </p>
<p>it's not so much about the library as the correct pinout.</p>
<p>Couldn't find a pin 13 listed in any of the program lines under file/examples/basics/blink, DID find it under file/examples/digital/blink without delay, changed the pin number 13 to a 14, uploaded it and got an onboard led to blink. Little errors in instruction and programming could easily cause my noob self to chuck the board as a bricked unit. Although I do agree that experience is what you get when things go wrong. Seems like when you select the wemos d1 board in board manager...then it should load up the sketch examples for that specific board....especially allowing for the different from UNO pinouts and onboard led locations. Oh well...now it is time to try some 8266 wifi stuff...glutton fpr punishment here! Thank you for this instructable...it really did help over all.</p>
<p>my pro-tip: use D13, D14 instead of 13, 14. There's a header file that defines those to the correct interal pins say D6 becomes pin 12.</p><p>https://github.com/esp8266/Arduino/blob/master/variants/d1_mini/pins_arduino.h</p>
<p>Thank you very much. </p>
I just got a Wemos D1. I was able to get the web server working without any problems. I'm an OK Arduino programmer but a complete NOOB on the Wemos. Is there a reference I can look to in order to better understand the wifi and web commands?<br>Thanks
<p>Hi there </p><p>Thanks for a great tutorial.</p><p>Does this one WeMos-D1R2 only control one on/off function, or can i control more in/outputs on the same ip and port ?</p><p>To be more exact. Can I control different devices with only one WeMos-D1R2 ?</p><p>Thanks in advance.</p>
<p>Excelent tutorial, I've used pin 2 for the D1 mini<br>One thing I've noticed is that the LED is ON when output is LOW</p>
<p>Hope someone is still monitoring this thread.</p><p>I ran the blink code and the LED blinks rapidly BUT then it stops!!</p><p>The On led is now on and the SCK led is slowly blinking but the led on Pin 14 no longer blinks!!</p>
<p>Brilliant tute, uploading to my WeMos before this, I was getting header, exit code 1 errors. I renamed the arduino15 to something different and loaded the IDE up, copied the link to the preferences etc...loaded the blink.....YAY!! it's working again.</p><p>Thanks a mil.</p>
<p>I'm blinking away! Awesome get started tutorial.</p>
<p>thanks for the tutorial. It helps me a lot</p>
<p>Hi, i tried to upload a sketch which was working for arduino mega, but i got a compiler error in an ISR declaration: ISR(TIMER3_COMPA_vect)</p><p>Can i use timer interrupts with WeMos?</p><p>Regards, Daniel</p>
<p>I felt motivated and i tried your previous instructable on my Wemos D1(retired). It work perfect, the only thing i had to change were the led pin assingment, thank you very much! Made me very happy when i got things to work! Hope to see more of your tutorials, greetings from Brazil!</p>
<p>Erion, thank you for the update and kind words.</p>
<p>Hello,</p><p>What is the difference between D1 vs D1 R2 version?</p><p>I wrote to Wemos seller on Ali and he mention &quot;R2 is compatible with nodemcu&quot;.</p><p>Thanks</p>
<p>I believe it has to do with the pull-up resistors. There could be more. I will need to fire up my D1R1 to know more.</p>

About This Instructable

134,084views

59favorites

License:

More by jainrk:ESP8266: I2C PORT and Address Scanner $1 USB to UART-serial flashing device (dongle) with 3.3 V power supply for ESP8266MOD ESP-12 module Program/Flash the ESP8266MOD ESP-12 module using the Witty Board and Arduino IDE 
Add instructable to: