Pin Numbering For WeMos D1 Mini (ESP8266) - Chewett Code
Maybe your like
Here I explain the difference in pin numbering for the WeMos D1 Mini compared to an Arduino and include a sample blink sketch.
Setting up the Arduino IDE for the WeMos D1 mini
This tutorial assumes that you have set up the Arduino IDE to able to compile the Wemos D1 mini.
You can follow the steps as outlined in the post Configuring the Wemos D1 Mini Pro ESP8266 for Arduino IDE. Once it is set up as described in the tutorial the Arduino IDE needs to be set to compile for the WeMos D1 Mini
Difference between the Arduino and WeMos D1 mini pins
One of the problems you will encounter when programming the WeMos D1 is that pin 1 on the WeMos isnt pin 1 in the Arduino IDE. The pin numbers in the WeMos D1 Pro (the ESP8266) are differently numbered than the Arduino.
This means that if you want to turn on pin 1 on the WeMos D1 mini you will need to use a different pin in the IDE. For example to enable the pin labelled D1 for output for the WeMos you would need to use the following code:
void setup() { Serial.begin(115200); pinMode(5, OUTPUT); //Digital pin 1 is pin 5 on the ESP8266 }The full list of output pins to identifiers are as follows, taken from the source code:
| Labelled WeMos Pin Number | Arduino Pin Number constant to use | “Real” Microcontroller Pin Number |
| Digital Pin 0 | D0 | 16 |
| Digital Pin 1 | D1 | 5 |
| Digital Pin 2 | D2 | 4 |
| Digital Pin 3 | D3 | 0 |
| Digital Pin 4 | D4 | 2 |
| Digital Pin 5 | D5 | 14 |
| Digital Pin 6 | D6 | 12 |
| Digital Pin 7 | D7 | 13 |
| Digital Pin 8 | D8 | 15 |
| TX | TX | 1 |
| RX | RX | 3 |
These can be used to program the WeMos D1 mini using the Arduino IDE.
However there is an easier way. The ESP8266 Arduino library provides a number of constants to program the WeMos electronics easier. These constants are named as same as the pins, so digital pin one labelled on the WeMos as D1 can be used with the constant D1.
So our above example can be made easier using these constants
void setup() { Serial.begin(115200); pinMode(D1, OUTPUT); //Digital pin 1 is pin 4 on the ESP8266 and D1 as a constant }Using these constants mean we don’t need to refer to the table to find which pin number relates to Arduino pin.
Example Blink Sketch for WeMos D1 mini
To demonstrate using these constants I have rewritten the Arduino blink sketch using the WeMos D1 mini. The code is as follows:
void setup() { Serial.begin(115200); pinMode(D1, OUTPUT); } void loop() { //We use D1 as a constant instead of 1 since the port mapping is different to the Arduino. digitalWrite(D1, HIGH); Serial.println("Blink On"); delay(2000); digitalWrite(D1, LOW); Serial.println("Blink Off"); delay(2000); }Here I initialize the Serial connection so we can see progress of the program. Using this I have added the additional logging to the program.
The main difference to the standard Arduino Blink sketch is that I am using the constant D1 as discussed earlier instead of 5 as the pin number.
Using these constants you can easily program the WeMos D1 mini and other WeMos microcontrollers.
If you have any questions about the WeMos or using the constants above feel free to ask below.
Share this:
- X
- More
- Tumblr
Tag » Arduino D1 Wifi Pinout
-
Wemos D1 Pins - Installation & Troubleshooting - Arduino Forum
-
Weird Wemos D1 R1 - #21 By Monteir00 - Arduino Forum
-
How To Use Arduino WeMos D1 WiFi UNO ESP8266 IOT IDE ...
-
Wemos D1 ESP8266 Based Board
-
Getting Started With The WeMos D1 ESP8266 WiFi Board
-
3 : WeMos D1 R1 Pinout | Download Scientific Diagram
-
ESP8266 D1 R2 WiFi Processor With Uno Footprint - ProtoSupplies
-
ESP8266 Pinout Reference: Which GPIO Pins Should You Use?
-
Tổng Hợp Wemos D1 Pinout Giá Rẻ, Bán Chạy Tháng 7/2022 - BeeCost
-
First Look At The WeMos D1 Arduino Compatible ESP8266 Wifi Board ...
-
Kit Arduino Wifi ESP8266 NodeMCU Lua WeMos D1 R2
-
WeMOS D1 ESP8266 Arduino Compatible, Its Specs And How To Use It
-
Giới Thiệu Về Board UNO WIFI - WeMos D1 - Khá Tiện Lợi Cho IOT