Wemos D1 pins

Hi,

I have some problems with Wemos D1 pins. I’ve got working only 2 pins.

Like this:
#define ONE_WIRE_BUS 5 // this works on D3 (or is it D15, confusing markings on board, see the image)
#define ONE_WIRE_BUS 4 // this works on D4

Others than those 5 and 4, I cant find, cant figure out pins for those.

I can find these pinouts from Google but cant figure out for my case. Cant understand the correlation or logic: https://storage.googleapis.com/stateless-www-faranux-com/2017/06/Reloaded-295x300.jpg

Attached also screenshot from Arduino IDE setup.

Any help to get more pins working than those two?

did you see http://cyaninfinite.com/tutorials/getting-started-with-the-wemos-d1-esp8266-wifi-board/ ?

.

Thanks for the link but don't know if that helped to understand this pin problem of mine.

The WeMos D1 and some other ESP8266 boards are a bit different than other Arduino boards in that their pin numbers refer to the GPIO numbers but the labels you see on the silkscreen don't match the GPIO numbers (I guess because the board layout would have made the numbering non-consectutive). The solution is to simply use the Dn notation, just as written on the silkscreen, to refer to the pins. For example:

#define ONE_WIRE_BUS D3
digitalWrite(D2, HIGH);

ECE9:
Thanks for the link but don’t know if that helped to understand this pin problem of mine.

You obviously didn’t read it.

If you are going to ask for help, at least have the courtesy of reading the information that someone took time to link.

.

ieee488: You obviously didn't read it. http://cyaninfinite.com/tutorials/getting-started-with-the-wemos-d1-esp8266-wifi-board/#Pinouts

If you are going to ask for help, at least have the courtesy of reading the information that someone took time to link.

.

Could you copypaste the key sentence from that page you think that helps? I read it twice and couldnt find.

pert: The WeMos D1 and some other ESP8266 boards are a bit different than other Arduino boards in that their pin numbers refer to the GPIO numbers but the labels you see on the silkscreen don't match the GPIO numbers (I guess because the board layout would have made the numbering non-consectutive). The solution is to simply use the Dn notation, just as written on the silkscreen, to refer to the pins. For example:

#define ONE_WIRE_BUS D3
digitalWrite(D2, HIGH);

Thanks pert! I will try to write the code in that way.

ECE9: I can find these pinouts from Google but cant figure out for my case. Cant understand the correlation or logic: https://storage.googleapis.com/stateless-www-faranux-com/2017/06/Reloaded-295x300.jpg

on referred picture the labels close to pins are irrelevant. those are the uno labels. you must use the left Dx labels. the gpio markings for rx and tx are wrong, there are io 1 and io 3.

btw: io pins on esp8266 are not called gpio (general purpose), because some of them have constraints on boot state

Thanks pert and Juraj, now it works! :D

Hi mates, I have trouble, I can't find corrispondence from pin declared on Arduino IDE and hardware pin on board. Are you so kind to draw it on the picture? (so there will not be possible misunderstandigs), thank you a lot!

For example i need to know which is: pinMode(13,OUTPUT); Please also tell me which is the corrispondent output pin of pinMode(LED_BUILTIN,OUTPUT); I see that LED_BUILTIN is phisicalli connected to pin D9/TX (what is written on the board), but if I write on pin9 (digitalWrite(9,HIGH); for example) I don't have the seme effect than digitalWrite(LED_BUILTIN,HIGH);

|500x500

pert: The WeMos D1 and some other ESP8266 boards are a bit different than other Arduino boards in that their pin numbers refer to the GPIO numbers but the labels you see on the silkscreen don't match the GPIO numbers (I guess because the board layout would have made the numbering non-consectutive). The solution is to simply use the Dn notation, just as written on the silkscreen, to refer to the pins. For example:

#define ONE_WIRE_BUS D3
digitalWrite(D2, HIGH);

My understanding is that digitalWrite(D9,HIGH) refers to the pin marked D9, but digitalWrite(9,HIGH) refers to GPIO 9, which is not actually usable because it's one of the pins used to communicate with the flash chip. That is, unlike a normal Arduino, D9 and 9 are not the same pin.

For bad reasons, the NodeMCU people started this alternate pin mapping that uses different numbers than the GPIO's are numbered. Wemos followed this convention in their silkscreen. Everyone else uses the GPIO numbers.

if you select “Wemos D1 R1” in IDE, th Dx constants will match the labels.

Thank you all for answers! Ok now it works, but it's strange, I declared all lines from D13 to D5 output and I?m having this: WHen D13 is low also D5 goes low, and viceversa, like pins are connected together also D7 and D11 and D12 with D6

Is it normal? Thank you

GiovanniG11: Thank you all for answers! Ok now it works, but it's strange, I declared all lines from D13 to D5 output and I?m having this: WHen D13 is low also D5 goes low, and viceversa, like pins are connected together also D7 and D11 and D12 with D6

Is it normal? Thank you

the pinout of D1 R1 is strange. R2 has it like NodeMcu

|500x467

Ok can be strange, but why (for exmple) D13 and D5 command activate both two ports? Amazing.. Other way to test outputs?

The explanation is clear after looking at the variant file for the WeMos D1 board definition: https://github.com/esp8266/Arduino/blob/2.5.0-beta2/variants/d1/pins_arduino.h#L38-L53

static const uint8_t D0   = 3;
static const uint8_t D1   = 1;
static const uint8_t D2   = 16;
static const uint8_t D3   = 5;
static const uint8_t D4   = 4;
static const uint8_t D5   = 14;
static const uint8_t D6   = 12;
static const uint8_t D7   = 13;
static const uint8_t D8   = 0;
static const uint8_t D9   = 2;
static const uint8_t D10  = 15;
static const uint8_t D11  = 13;
static const uint8_t D12  = 12;
static const uint8_t D13  = 14;
static const uint8_t D14  = 4;
static const uint8_t D15  = 5;

In order to fill out the Uno-style form factor of the board, they connected some of the ESP8266's GPIO to multiple pins on the headers.

GiovanniG11: Ok can be strange, but why (for exmple) D13 and D5 command activate both two ports? Amazing.. Other way to test outputs?

because it is strange. :-) but it has it's logic:

the SPI pins of esp8266 are mapped to pins where SPI is on Uno (D10, D11, D12, D13). but then no enough pins would be left for the first section of D pins.

and 4 and 5 as default I2C pins in esp8266 Wire library. they are connected to I2C pins SDA and SCL where they should be for shields (on the header next to usb connector). they are on Uno twice too (A4 and A5)

Thank you a lot for explaining! If it is like that we have (at least I counted now 3) some outputs which are electrically connected to 2 din bars, the result is a limited amount of input outputs available (duplicated are useless). I was thinking more compatible with integrated wi fi, few lines, only one analog, I'm a bit dispappointed, I go to buy a real UNO clone with 328p )

I now managed to get mine working after alot of try and error to figure out the pinout but with the pinout that you provided on previous post really helped me alot. Thank you Juraj.