So i've chosen to purchase a Wemos D1 R2 board in order that my old Arduino Uno R3 projects can get some new IoT features. However, even if my code is working in Uno perfectly, i want to test it using D1 before adding features. My problem is that, even if i have found tables showing differences between the 2 boards' pinouts, i cannot understand the correspondence between the pinouts.

So i am giving you the table below. Let's say i want to define echo and trigger pins for a sensor in my code. For example:

#define TRIGGER_PIN 4
#define ECHO_PIN 3

That would be pins D3 and D4 at my Uno. But i cannot understand which those pins would be in Wemos D1 R2. Also, my two boards can be seen below for comparison

enter image description here

enter image description here


The tricky thing with the WeMos boards is the pin notation is different from other Arduino boards.

Sometimes you will see the digital pins on Arduino boards referenced with the Dn notation. For example: "Connect the HC-SR04's Trig pin to D4 on the Uno". In fact some boards such as the Nano even use the Dn pin notation on their silkscreen. This is just a way of further differentiating the pins from the An pins. You will only refer to that pin by the number 4 in your code.

The WeMos boards are different. You actually need to use D3 and D4 in your code to control the pins marked D3 and D4 on the silkscreen:

#define TRIGGER_PIN D4
#define ECHO_PIN D3

We can take a peek at the source code of the ESP8266 core for Arduino to see why: https://github.com/esp8266/Arduino/blob/2.4.0/variants/d1_mini/pins_arduino.h#L40-L50

static const uint8_t D0   = 16;
static const uint8_t D1   = 5;
static const uint8_t D2   = 4;
static const uint8_t D3   = 0;
static const uint8_t D4   = 2;
static const uint8_t D5   = 14;
static const uint8_t D6   = 12;
static const uint8_t D7   = 13;
static const uint8_t D8   = 15;
static const uint8_t RX   = 3;
static const uint8_t TX = 1;

Now you can see that if you use your original code:

#define TRIGGER_PIN 4
#define ECHO_PIN 3

That would actually be referring to the pins marked D2 and RX on the WeMos D1 R2!

  • Perfect answer to sort that out. To the point and clear! Thanks. – Galinho Salonica Jan 26 '18 at 0:34
  • If i choose to use numbers with Ds, f.e. TRIGGER_PIN D4, will i connect jumper wire of trigger to D2(Arduino pin) or to D4 (physical D4 on Wemos)? – Galinho Salonica Jan 26 '18 at 14:54
  • Use the Dn names, as marked on the WeMos board, in your code and the pin with that marking will be used. i.e. if you write D4 in your code then connect the wire to the pin marked D4 on the board. – per1234 Jan 26 '18 at 21:49

I don't have a WeMos board, but I would say GPIO05 is digital pin 3 and GPIO04 is digital pin 4.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.