Learn

Wemos D1 R32 pinout: every Uno hole, and the ESP32 GPIO behind it

Beginner

Or see every lesson.

  • 455parts on the bench
  • 43boards running now
  • 1.00xreal time, on every board
Wemos D1 R32: a button on D2live0.000 s 0.00x
Hold the button
A button on D2 (GPIO 26) to ground lights an LED on D3 (GPIO 25) and the blue LED on GPIO 2.

The Wemos D1 R32 is a classic ESP32 on the Arduino Uno’s outline, with an ESP32-WROOM-32 module where the Uno’s chip would be and the Uno’s four headers in the Uno’s places. The holes carry the Uno’s names, but a sketch writes GPIO numbers, and the two do not match: the hole marked D2 is GPIO 26. This page lists every hole with its GPIO, the power pins, the input-only pins, the strapping pins, the onboard LED and which pin to use for what.

The circuit above is the board in Mokxi with a button on the hole printed D2, GPIO 26, lighting an LED on D3, GPIO 25, and the blue LED with it. Everything in the table is checked against the board model the simulator runs, and where Mokxi does less than the chip, the row says so.

Every pin on the header

The table goes along the power header from IOREF to VIN, the analog header from A0 to A5, the digital header from D0 to D7, and the ten-pin header from D8 to SCL, as on an Uno. The first column is what the board prints in large type; the second is the GPIO a sketch writes. The firmware also defines D0 to D13 and A0 to A5 as these GPIOs, as the Arduino IDE’s d1_uno32 board does.

Some boards misprint two of the small GPIO labels on the analog header: the white IO36 beside A2 is really GPIO 35, and IO38 beside A4 is really GPIO 36. The table uses the real GPIOs. Touch, the DAC and ADC2 are in the table because the chip has them and tutorials use them; Mokxi does not model any of the three.

Wemos D1 R32: the power and analog headers, then D0 to D7, then D8 to SCL
PinGPIOWhat it can doWatch out for
IOREF-Tells a shield the board’s logic level: 3.3 V.Not a GPIO.
RESET-Chip enable, which is the reset. Low holds the chip in reset, as the button does.Not a GPIO.
3V3-The regulator’s 3.3 V output.Not a GPIO.
5V-The 5 V rail from USB.Not a GPIO.
GND-Ground. Three holes.-
VIN-Power in for the barrel jack’s regulator.Mokxi leaves it open; the board is on USB.
A02PWM. ADC2_CH2 and touch T2 on the chip (not modeled). The blue LED, lit when HIGH.analogRead reads 0 in Mokxi. Strapping pin: must be low or floating to upload.
A14PWM. ADC2_CH0 and touch T0 on the chip (not modeled).analogRead reads 0 in Mokxi.
A235ADC1_CH7. Input only.No output driver and no internal pull-up or pull-down.
A334ADC1_CH6. Input only.No output driver and no internal pull-up or pull-down.
A436ADC1_CH0. Input only.No output driver and no internal pull-up or pull-down.
A539ADC1_CH3. Input only.No output driver and no internal pull-up or pull-down.
D03UART0 RX: Serial, and the USB-to-serial chip.Leave free, or uploads and the serial monitor break.
D11UART0 TX: Serial, and the USB-to-serial chip.Leave free, or uploads and the serial monitor break.
D226PWM. DAC2 and ADC2_CH9 on the chip (not modeled).Not GPIO 2: write 26.
D325PWM. DAC1 and ADC2_CH8 on the chip (not modeled).Not GPIO 3: write 25.
D417PWM.A safe all-rounder.
D516PWM.A safe all-rounder.
D627PWM. ADC2_CH7 and touch T7 on the chip (not modeled).ADC2 stops working while WiFi is on.
D714PWM. ADC2_CH6 and touch T6 on the chip (not modeled).ADC2 stops working while WiFi is on.
D812PWM. ADC2_CH5 and touch T5 on the chip (not modeled).Strapping pin: high at reset and the board does not boot.
D913PWM. ADC2_CH4 and touch T4 on the chip (not modeled).ADC2 stops working while WiFi is on.
D105PWM. SPI SS (default).Strapping pin: leave it unloaded at power-on.
D1123PWM. SPI MOSI (default).-
D1219PWM. SPI MISO (default).-
D1318PWM. SPI SCK (default).Not the LED: the LED is on GPIO 2.
AREF-Not connected on the R32.Mokxi leaves it open.
SDA21PWM. I2C SDA (default).-
SCL22PWM. I2C SCL (default).-

Power: IOREF, 3V3, 5V and VIN

IOREF is 3.3 V, because the board’s logic is 3.3 V, and that is the thing a 5 V shield needs telling. 3V3 is the regulator’s output, enough for a sensor, not for a motor. 5V is the USB rail. VIN is the barrel jack’s side of the 5 V regulator. The three GND holes are one ground.

Every GPIO is 3.3 V and none is 5 V tolerant, so a shield made for a 5 V Uno can plug in and still damage a pin if it drives one to 5 V. Give a 5 V output a divider or a level shifter. In Mokxi the board is always powered from USB: VIN and AREF are open, and the regulator is not modeled, so a circuit that would overload the real one still runs here.

The Uno names are not the GPIO numbers

This is the thing that catches everyone who moves a sketch from an Uno. On an Uno, digitalWrite(2, HIGH) drives the hole marked 2. On a D1 R32 it drives GPIO 2, which is the A0 hole and the blue LED. The hole marked D2 is GPIO 26, D3 is GPIO 25, and D13 is GPIO 18.

Write the GPIO number, as the built-in Button sketch does with 26 and 25, or write D2, which the firmware defines as 26. A sketch that uses bare Uno numbers compiles and runs, and drives the wrong pins.

Input-only pins: A2 to A5

A2 to A5 are GPIO 35, 34, 36 and 39. On the ESP32 those pins have an input buffer and nothing else: no output driver and no internal pull-up or pull-down. They make good analog inputs, all on ADC1, and they cannot be outputs. A button on one needs a 10 k resistor of its own.

Mokxi refuses an output on these pins the way the chip does, so a sketch cannot believe it is driving one.

Strapping pins: A0, D8 and D10

The ESP32 reads GPIO 0, 2, 5, 12 and 15 as it comes out of reset. Three of them are on this board’s headers: GPIO 2 at A0, GPIO 12 at D8 and GPIO 5 at D10. GPIO 12 bites hardest: high at reset tells the chip its flash runs at 1.8 V, and the board will not boot until whatever holds D8 high lets go. A shield with a pull-up on D8 is the usual culprit. GPIO 2 has to be low or floating to upload.

GPIO 0 is not on the headers. The USB chip pulls it low to start the loader, and there is no BOOT button on the board. Mokxi does not model strapping, so a circuit that runs here can still refuse to boot on a desk.

The onboard LED, analog, PWM, I2C and SPI

The blue LED is on GPIO 2 and lights when the pin is HIGH. LED_BUILTIN is 2. GPIO 2 is also the A0 hole, so anything wired to A0 shares the pin with the LED.

Only ADC1 reads in Mokxi, and on this board ADC1 is A2 to A5. A0 and A1 are GPIO 2 and 4, on ADC2, and analogRead on them reads 0 here. On a real board ADC2 works only while WiFi is off. ADC1 is twelve bits, 0 to 4095, with a real part’s curve at the default 11 dB: a pot across 3.3 V reaches 4095 at about 3.1 V.

PWM is LEDC, on any pin with an output driver. Wire.begin() uses SDA, GPIO 21, and SCL, GPIO 22, and SPI uses D13, D12, D11 and D10, GPIO 18, 19, 23 and 5, for SCK, MISO, MOSI and SS, so an Uno shield that uses SPI finds it in the same place. In Mokxi both buses run in software on those pins, because the chip’s I2C and SPI controllers are not modeled.

Questions

What GPIO is D2 on the Wemos D1 R32?

GPIO 26. Write `digitalWrite(26, HIGH)`, or `D2`, which the firmware defines as 26. Pin 2 in code is GPIO 2, the blue LED on the A0 hole.

Which D1 R32 pins can read analog?

In Mokxi, A2 to A5, which are GPIO 35, 34, 36 and 39 on ADC1. A0 and A1 are on ADC2, which Mokxi does not model, and which on a real board stops working while WiFi is on.

Which pins are I2C on the D1 R32?

SDA is GPIO 21 and SCL is GPIO 22, the two holes past AREF, where an Uno R3 has them. `Wire.begin()` uses them.

Which D1 R32 pin should I use for a button?

D2 to D7, D9, D11 to D13, SDA or SCL, with `INPUT_PULLUP` and the button to ground. Avoid D8 and D10, which are strapping pins, and A2 to A5, which have no pull-up.

Can I use a 5 V Arduino shield on the D1 R32?

It plugs in, but the board’s logic is 3.3 V and the ESP32’s pins are not 5 V tolerant. A shield that only reads the board’s outputs is usually fine; one that drives a pin to 5 V needs level shifting.

Why do the labels on my D1 R32 not match this table?

Some boards misprint two labels on the analog header: IO36 beside A2 is really GPIO 35, and IO38 beside A4 is really GPIO 36. Go by the table.

Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.