Getting Started with WeMos D1 on Mac OSX

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
    Screen Shot 2016-05-06 at 10.35.43 AM.png

  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
    Screen Shot 2016-05-06 at 10.30.02 AM.png

  5. Open Tools → Board:xxx → Boards Manager and install esp8266 by ESP8266 Community
    Screen Shot 2016-05-06 at 10.31.40 AM.jpg

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 Screen Shot 2016-05-06 at 10.32.59 AM.png

  4. Plug your WeMos D1 board into your Mac using a micro USB.

  5. Open Tools → Port:xxx and in the dropdown, select the option with "usb" in its name.
  6. Your Tools dropdown should look like this:
    Screen Shot 2016-05-06 at 1.45.55 PM.png

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
RXRX<-D0D03
TXTX->D0D11
D0D2D216
SCL/D1D15/SCL/D3D35
SDA/D2D14/SDA/D4D44
D3D13/SCK/D5D50
D4D12/MISO/D6D62
D5D11/MOSI/D7D714
D6D8D812
D7TX1/D9D913
SS/D8D10/SSD1014
MOSI/D7D11/MOSID1113
MISO/D6D12/MISOD1212
SCK/D5D13/SCKD1314
SDA/D2D14/SDAD144
SCL/D1D15/SCLD155

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
    1. In Finder, navigate to ~/Library (to get to Library, click on Go, then press control, and click on Library). Rename Arduino15 to Arduino15-backup.
    2. Download and install the latest version of the Arduino IDE (replace your current version)
    3. 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.

Comments