It took me way too long to get started with the WeMos D1 R2 board, partly because mine is an eBay knockoff.

Getting Started

  1. Download and install the Arduino IDE (just called Arduino): https://www.arduino.cc/en/Main/Software Note: I use version 1.6.8, newer versions may not work.
  2. Open Arduino
  3. Open File → Preferences
  4. Copy and paste http://arduino.esp8266.com/stable/packageesp8266comindex.json into Additional Boards Manager URLs field. You can add multiple URLs, separating them with commas
  5. Open Tools → Board:xxx → Boards Manager and install esp8266 by ESP8266 Community
Screen Shot 2016-05-06 at 10.32.00 AM.png
  1. Open Tools → Board:xxx and select WeMos D1 R2 & mini.
  2. Open Tools → Upload Speed and select 115200. If you're brave, you can try 230400 to upload code to the board faster, but watch the console for errors.
  3. Download a driver so your Mac recognizes the WeMos D1 board (the site looks sketchy, but I can confirm the driver is legit): Note: This driver is needed for both real and knockoff D1 boards. http://www.wch.cn/download/CH341SERMACZIP.html
  1. Plug your WeMos D1 board into your Mac using a micro USB.
  2. Open Tools → Port:xxx and in the dropdown, select the option with "usb" in its name.
  3. Your Tools dropdown should look like this:

Testing

  1. To make sure everything is working properly, let's download WeMos' example files: https://github.com/wemos/D1miniExamples/archive/master.zip
  2. Rename the uncompressed directory to D1miniExamples
  3. In Arduino, open File → Preferences
  4. In Finder, navigate to the Sketchbook location show in in Arduino's Preferences
  5. Move the D1miniExamples directory to Sketchbook location
  6. The path will look like Sketchbookdirectory/D1mini_Examples
  7. Restart the Arduino IDE
  8. All examples are under File→Sketchbook→D1miniExamples

Hello World

  1. Open File→Sketchbook→D1miniExamples→01.Basics→HelloWorld
  2. Click Upload
  3. After upload, open Tools→Serial Monitor, set baudrate to 9600 baud

Digital I/O

If you've gotten to this point, good work! Now we're going to learn a bit more about the WeMos D1's I/O ports. They're f***ed.

The fact that I have a knockoff board doesn't help either. Anyways, enough complaining. Basically, the labels on the WeMos D1 are not the same as those used in Arduino programs.

As an example, if I want to use digital port 3 (D3) as an output, this is the code I would use:

void setup() {  
  pinMode(5, OUTPUT);
}

void loop() {  
  // Turn on for 1 second
  digitalWrite(5, HIGH);
  delay(1000);

  // Then off for 1 second
  digitalWrite(5, LOW);
  delay(1000);
}

I've created a couple of reference tables for your convenience.

Official WeMos D1 Board Label Knockoff WeMos D1 Board Label Digital Port Arduino Software
RX RX<-D0 D0 3
TX TX->D0 D1 1
D0 D2 D2 16
SCL/D1 D15/SCL/D3 D3 5
SDA/D2 D14/SDA/D4 D4 4
D3 D13/SCK/D5 D5 0
D4 D12/MISO/D6 D6 2
D5 D11/MOSI/D7 D7 14
D6 D8 D8 12
D7 TX1/D9 D9 13
SS/D8 D10/SS D10 14
MOSI/D7 D11/MOSI D11 13
MISO/D6 D12/MISO D12 12
SCK/D5 D13/SCK D13 14
SDA/D2 D14/SDA D14 4
SCL/D1 D15/SCL D15 5

Note: I can't guarantee the official WeMos D1 board mappings are correct, but they're based off this:
http://www.instructables.com/id/Programming-the-WeMos-Using-Arduino-SoftwareIDE/?ALLSTEPS


Troubleshooting

  1. Restart the Arduino IDE
  2. Try a different micro USB cable
  3. In Finder, navigate to ~/Library (to get to Library, click on Go, then press control, and click on Library). Rename Arduino15 to Arduino15-backup.Download and install the latest version of the Arduino IDE (replace your current version)Open Arduino, re-install esp8266 in the Boards Manager.

If you have any other troubleshooting tips, send them my way.


Notes

A good amount of the content here is based on the official WeMos documentation ( http://www.wemos.cc/tutorial/getstartedin_arduino.html ). I've simply filled in many of the gaps preventing my board from functioning properly.

This is what an actual WeMos D1 board looks like:

r2_1.jpg

This is what my knockoff WeMos D1 board looks like:

IMG_0539.jpg

Resources


Final Words

Now you know how to set up your WeMos D1 board and use its ports. I'm going to leave out discussion on its WIFI capabilities because there's plenty of documentation on that already.

In the next article, I will discuss how to connect a stepper motor to the WeMos D1.