Using D5 to D8 pins on wemos


I know there is a mess with pin numbers between arduino and wemos

for example, if I want to use digital port 1, I have to use D1 in my program, which value is 5

as a reminder, the mapping table is as follows
#define D0 16
#define D1 5 // I2C Bus SCL (clock)
#define D2 4 // I2C Bus SDA (data)
#define D3 0
#define D4 2 // Same as “LED_BUILTIN”, but inverted logic
#define D5 14 // SPI Bus SCK (clock)
#define D6 12 // SPI Bus MISO
#define D7 13 // SPI Bus MOSI
#define D8 15 // SPI Bus SS (CS)
#define D9 3 // RX0 (Serial console)
#define D10 1 // TX0 (Serial console)

I tried successfully on blynk to switch on a led on wemos port D1. For this, I had to set D5 in button settings on my phone. Weird, but it works, and I think I will be able to switch leds on ports number D1, D2, D3, D4, using button settings D5, D4, D0 and D2

but button settings goes max to D10, so impossible to set D14, D12, D13 and D16 to use wemos D5, D6, D7 and D0

any solution to this ?


First of all, the pin mappings you’ve listed above are for a Wemos D1 Mini, which is very different to the Wemos D1 (sometimes known as the D1 R1).

Secondly, creating a device in the app of type Wemos D1 will give you digital pin numbers D1 to D10
But, creating a device in the app of type Wemos D1 Mini will give you digital pin numbers D1 to D8 (even worse from your point of view).
I have no idea why this is, but there simple solution, change the device type to ESP8266 and you’ll get digital pins 1 to 16 and it will work fine with the Wemos D1 Mini.

To avoid confusion between pin numbers, I don’t refer to “digital” pins, i refer to GPIO numbers. The Digital pin numbers in the app (D1-8, D1-10 or D1-16 depending on the device) are GPIO numbers.

The only reason to use the “D” numbers screen printed on to the Wemos or NodeMCU devices is to assist with wiring.
So, I work the other way - in my code I always use GPIO numbers and add a comment at the side like this:

#define relay 5  // GPIO5 = Wemos Pin D1 

Having said all of that, you’d be better using virtual pins rather than digital pins, they are much better and more powerful.


1 Like


Thanks for your answer.
I’m using Wemos D1 R2 and, as far as as know, the pin mapping is the same as for D1 mini (Actually, it works for me :wink:)
That said, your proposal of using ESP8266 is a good idea and seems to work (I’ll confirm when my disconnection issue will be solved, but this is an other problem). Thanks
I’ll have a look at virtual pins when I’ll have my yellow belt on blynk


Hi Pete,
I confirm virtual pins are great and easy to use !
Thanks for the advice.

1 Like