Learn

ESP-01 pinout: eight pins, and the two that decide how it boots

Beginner

Or see every lesson.

  • 505parts on the bench
  • 45boards running now
  • 1.00xreal time, on every board
ESP-01S: blinklive0.000 s 0.00x
Click to open it in the editor
GPIO 2 driven LOW lights the module’s blue LED and an LED wired from 3V3 the same way.

The ESP-01 is an ESP8266 with its flash chip and an antenna on a module 24.8 by 14.3 mm, and only eight pins: power, ground, reset, enable, the serial port and two GPIOs. This page lists all eight with what each can do, the boot modes GPIO0 and GPIO2 set, the power the module needs, how to get I2C onto two pins, and which pin to use for what.

The circuit above is an ESP-01S in Mokxi blinking its blue LED on GPIO 2, with an LED wired from 3V3 through a resistor to the same pin, the way the module’s own is, so both light when the pin goes LOW. Mokxi models the ESP-01S, and the table is held to the same board model the simulator runs. Where the simulator does less than the module, the page says so.

All eight pins

The pins are two rows of four on a 0.1 inch grid. One row is GND, GPIO2, GPIO0 and RX and the other is TX, EN, RST and 3V3; go by the labels printed on your module. The rows are only 0.1 inch apart, so the module does not go into a breadboard, where each pair would land in one strip and short. Wire it with jumpers or through an adapter.

Two of the four GPIOs are the serial port, so a sketch that prints has GPIO0 and GPIO2 for everything else. There is no A0: the ESP8266’s analog input is not brought out on this module.

ESP-01S: the eight pins, one row of four and then the other
PinGPIOWhat it can doWatch out for
GND-Ground.-
GPIO22Digital in and out, software PWM. The blue LED, lit when LOW. I2C SCL with Wire.begin(0, 2). UART1 TX on the chip (not modeled).Strapping pin: must be high at boot.
GPIO00Digital in and out, software PWM. I2C SDA with Wire.begin(0, 2).Strapping pin: low at boot waits for an upload.
RX3UART0 RX: Serial, and how the module is programmed.A GPIO only once Serial is off.
TX1UART0 TX: Serial, and how the module is programmed.A GPIO only once Serial is off.
EN-Chip enable: low holds the chip off.Pulled up on the ESP-01S; tie it to 3V3 on an original ESP-01.
RST-Reset: low restarts the chip.Not a GPIO.
3V3-The 3.3 V supply.Never 5 V. Give it a regulator that can deliver the radio’s current.

Boot modes: GPIO0, GPIO2 and GPIO15

The ESP8266 reads three pins as it comes out of reset. GPIO 0 and GPIO 2 must be high and GPIO 15 low for it to run your program, and GPIO 0 low means "wait for an upload", which is how a USB adapter flashes the module: GPIO0 to ground, reset, upload. GPIO 15 is tied low inside the module, so on an ESP-01 the two that matter are GPIO0 and GPIO2.

So a button, a relay or a sensor on GPIO0 or GPIO2 must not pull it low at power-on. An LED wired from 3V3 to the pin, as above, is fine, because it pulls the pin up. Mokxi does not model the boot modes: a program is loaded by pressing Run, and GPIO0 is an ordinary pin.

Power: 3.3 V only, and plenty of it

The module runs on 3.3 V and none of its pins is 5 V tolerant; 5 V on 3V3 damages it. The ESP8266 draws far more than a microcontroller when the radio transmits, about 170 mA by Espressif’s datasheet, so the 3.3 V pin of an Uno or of a small USB-serial adapter often cannot keep up, and the module resets at random. Give it a regulator of its own.

EN must be high for the module to run, and RST low resets it. The ESP-01S has pull-ups on both, so it runs with them left alone. Mokxi’s 3V3 is an ideal rail, so a circuit that would brown a real module out runs cleanly here.

The LED, and the original ESP-01

On the ESP-01S the blue LED is on GPIO 2, wired from 3.3 V to the pin, so it lights when the pin is LOW, and LED_BUILTIN is 2. digitalWrite(LED_BUILTIN, LOW) turns it on. Wire an LED of your own the same way, from 3V3 through a resistor to the pin, and it agrees with the blue one, as in the circuit above.

The original blue-board ESP-01 has its LED on TX instead, so it flickers with the serial port and cannot be blinked while Serial is in use. Mokxi models the ESP-01S.

I2C, PWM and the serial pins

The ESP8266’s usual I2C pins, GPIO 4 and 5, are not on this module, so put the bus on the two you have: Wire.begin(0, 2) makes GPIO0 SDA and GPIO2 SCL, in Mokxi and on the module. A sensor board’s pull-ups hold both pins high, which is what the boot wants anyway. analogWrite works on GPIO0 and GPIO2 in software, 0 to 1023, as on every ESP8266.

RX and TX are UART0, which is Serial and the way the module is programmed. To use them as GPIO 3 and GPIO 1, leave Serial out of the sketch. In Mokxi Serial reaches the serial monitor directly.

Open this circuit in the editor. ESP-01S: blink, wired as it runs at the top of this page. Change a part or a value and run it again.

Open the circuit

Questions

Which ESP-01 pins can I use?

GPIO0 and GPIO2, and RX and TX if you give up Serial. Both GPIOs must be high when the module powers up.

What are the ESP-01 I2C pins?

It has none of its own. `Wire.begin(0, 2)` puts SDA on GPIO0 and SCL on GPIO2.

How do I put an ESP-01 into programming mode?

Hold GPIO0 low while the module comes out of reset, then upload. An adapter with a flash button does it for you.

Can I power an ESP-01 from an Arduino’s 3.3 V pin?

Not reliably. An Uno’s 3V3 pin is rated at 50 mA and the module wants more than three times that while it transmits. Use a 3.3 V regulator of its own.

Why does my ESP-01 not boot with a relay on GPIO0?

If the relay circuit pulls GPIO0 low at power-on, the module starts its upload mode instead of your sketch, and GPIO2 low stops it starting at all. The relay’s input has to idle high.

Which ESP-01 pin should I use for a button or an LED?

An LED from 3V3 through a resistor to GPIO2, as above, so it lights on LOW and holds the pin high at boot. A button from GPIO0 to ground with `INPUT_PULLUP`, as long as nobody holds it while the module powers up, which would start the upload mode instead of your sketch.

Does the ESP-01 have an analog pin?

No. The ESP8266 has one, A0, but the ESP-01 does not bring it out. A D1 mini or a NodeMCU does.

Build this for real

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