3 Simple Ways of Programming an ESP8266 12X Module




Introduction: 3 Simple Ways of Programming an ESP8266 12X Module

About: Hey everyone! My name is Brian and thanks for checking my Instructables. I'm a software developer by trade but I've recently gotten into Arduino development after discovering the esp8266 chip, a WiFi enable…

If you are not familiar with ESP8266 micro controller, I really feel you have been missing out! These things are incredible: they are cheap, powerful and best of all have built-in WiFi!

ESP8266 started their journey out as a WiFi add on board for more traditional Arduino boards but shortly after, the community realized the power of them and added support to be able to program directly with the Arduino IDE.

These days if you are looking to use an ESP8266 for your project I would recommend using a development board such as the Wemos D1 Mini* ($2.50 delivered!!) or Adafruit Feather Huzzah. These boards have all the usable pins broken out, are easily programmable via their micro USB connector and have a built in 3.3V regulator.

But what if you want to use an ESP8266 in a project with a custom PCB? The easiest way is to use an ESP12 module, and in this Instructable I'll show you a couple of simple ways of programming them.

* = Affiliate Link

Step 1: Check Out the Video!

Here is a video with all the info contained in the Instructable if you like to check it out.

On my channel I do a lot of work with ESP8266s so my channel in general maybe worth checking out if that sort of stuff interests you!

Step 2: Pre-Step: Setup for Programming the ESP8266

If you have never used the ESP8266 or Arduino before, we will need to a little bit of software setup. I have a dedicated video for this. It's only 5 minutes long and goes through everything you need to setup.

If videos are not really your thing, check out lesson 2 of Becky's awesome IoT Class, it goes over everything you need as well.

Before you move to the next section you should be able to upload a simple sketch to an ESP8266 (such as the blink example mentioned in both the video and Becky's lesson)

Step 3: Method 1: "Frog" Pin Programmer

This is probably the easiest way to program an ESP12 module. You basically just pop the module into the board and then it behaves exactly like one of the development boards mentioned earlier. I selected the Wemos D1 Mini board from the boards drop down when programming.

There downsides to this method are:

  • The programmer is a little bit expensive if you are only making a few boards.
  • Boards can only be programmed this way before they are soldered to your PCB

The one I bought is from Aliexpress, but I believe the original designer is a user on Tindie called Fred. They were sold out at the time so I ended up going with the Aliexpress one, but I'll link to both.

* = Affiliate Link

Step 4: Method 2: Using Basically Any USB to Serial Converter

For the next method we are going to manually put the ESP module into programming mode and then use basically any USB to serial converter to program the ESP8266, even this PL2303 one* that costs 50c delivered works!

Normal Operation:

Before we get started on programming we first need to take a look at the what external components the ESP8266 needs to run. For normal operation an ESP-12 module needs the following

  • EN, RST and GPIO 0 needs to be pulled high using a 10K resistor
  • GPIO 15 needs to be pulled to Ground using a 10K resistor
  • 3.3V power supply capable of about 250mA of current (A cap between VCC and GND is recommended)

With the above configuration the ESP8266 when powered on will be in Normal operating mode, so it will run whatever sketches you have programmed to it.

You can buy breakout boards for ESP-12 modules* that are really useful for testing out the different setups. The modules have the resistors setup for the EN and GPIO 15 pin, so you will still need to add the pull-up resistor for RST and GPIO 0,

Enabling Programming mode:

To get it into programming mode, GPIO 0 needs to be pulled low when the ESP is starting up. The easiest way to do this is to add buttons to GPIO 0 and the RST pin that connect to ground when pressed. Then to enable flash mode, you simply

  • Hold down the GPIO 0 button
  • Press the RST button
  • Then let go of both buttons

You don't need to perform this sequence at any particular time during the upload process or anything, once the ESP is in programming mode it will stay there til the next reset, so just perform the steps any time before uploading.

Programming with a USB to serial adapter:

Enabling program mode is only half the battle, now we need to actually program the module. Most USB to serial adapters can not provide enough current to the ESP8266 so it's recommended that you power the ESP8266 using an external 3.3V source.

To wire up the programmer you need to connect the following pins (also shown in an image above):

  • Connect TX of the programmer to RX of the ESP8266 (Not a typo, the connections are reversed)
  • Connect RX of the programmer to TX of the ESP8266
  • Connect Ground of the programmer to Ground of the ESP8266

To upload your sketch, do the following steps:

  • Select the port number of your Serial adapter (Tools->Port)
  • Enable programming mode on your ESP8266 as described above
  • Click the upload button. (If it fails double check your wiring and try resting your board into programming mode again)
  • Click the reset button when the upload has finished

Here are the board settings I used when uploading using this method:

  • Board: Generic ESP8266 Module
  • Flash Mode: DIO
  • Flash Size: 4M (3M Spiffs)
  • Reset Method: ck
  • Flash Frequency: 40MHz
  • Upload Speed: 115200

The last thing to note is the LED_BUILIN defintion for a generic ESP8266 module points to pin 1, but the built in LED of a ESP12 module is connected to pin 2 (It's active low too just as an FYI). So if you are testing out a blink sketch you will need to use the number 2 rather than LED_BUILTIN

* = Affiliate Link

Step 5: Method 3: Auto Resetting Programmer Using a NodeMCU

If you used any ESP development boards you will have noticed that basically all of them do not require you to manually enable programming mode using the buttons, so how do they do that?

Most USB to serial chips have additional pins that output signals at different stages of the upload process and with the use of some external circuitry it's possible to trigger the low of the GPIO 0 and the resets required. RuiMoteiro has an instructable on this topic using an FTDI board and ESP8266.

But I think there is a simpler approach to this, and what's even better is there is a good chance you already have everything you need to do it! You can use an ESP8266 development board such as a NodeMCU as the programmer*.

Whats the advantage of using a NodeMCU?

The main advantages of using the NodeMCU as a programmer are the following:

  • You can power the ESP8266 directly from 3V pins of the NodeMCU
  • Will handle the auto-resetting/enabling of programming mode
  • Costs about $2.50 delivered (and can be used as regular dev board when not programming others!)

You can use this same approach with any dev board the exposes the chip enable pin of the ESP8266.

How does it work?

I got the idea of this from a YouTuber called Mika Kurkela, in his video he was using the NodeMCU to program an ESP-01 module, but we can use the same idea for the ESP12 module.

Basically we are going to disable the ESP8266 on the NodeMCU by forcing the EN pin low, this will prevent the ESP8266 module on the NodeMCU from booting. We are then going to going to connect all the relevant pins of the NodeMCU board to our external ESP8266.

Wiring it up

To wire it up, you will need the standard ESP8266 wiring as shown in the previous step and then to add the following connections (also shown in the image above):

  • Connect 3V of the NodeMCU to VCC of the ESP8266
  • Connect GND to GND
  • Connect TX of the NodeMCU to TX of the ESP8266 (This is different than the previous step)
  • Connect RX of the NodeMCU to RX of the ESP8266
  • Connect D3 of the NodeMCU to GPIO 0 of the ESP8266 (D3 is GPIO 0 of the ESP8266)
  • Connect RST of the NodeMCU to RST of the ESP8266
  • Connect EN of the NodeMCU to GND

Uploading a sketch

Once you have the ESP8266 wired up, you need to do the following:

  • Select the port number of the NodeMCU (Tools->Port)
  • Select the Board type "NodeMCU 1.0 (ESP12-E Module)"
  • Click upload

And that's it! It will automatically enable programming mode and will automatically reset when finished uploading so it will start executing the sketch.

Using this in your board designs

In order to use this method in your board designs, you simply need to break out the following pins:

  • Ground
  • GPIO 0
  • VCC
  • TX
  • RX
  • RST

And when you want to program your boards, wire it up as above.

Hopefully you find this Instructable useful, if you have any questions please feel free to ask!

* = Affiliate Link

2 People Made This Project!


  • Hide It Challenge

    Hide It Challenge
  • Reclaimed Materials Contest

    Reclaimed Materials Contest
  • Laser Challenge

    Laser Challenge



1 year ago on Step 5

Step 5, Method 3
Mika Kurkela´s method shows that any external resistor are not needed. Node MCU has all the nesessary resistors builtin. I programed ESP12S just without resistors. In this link there are shematic diagrams with those pull upps and pull downs.


Reply 11 months ago

hey ,in my opinion if you only use a single esp board, i think you need resistors to wake the esp to working mode


1 year ago on Step 3

Arduino:1.8.12 (Mac OS X), Kort:"LOLIN(WEMOS) D1 R2 & mini, 80 MHz, Flash, Disabled, All SSL ciphers (most compatible), 4M (1M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 921600"
Sketch uses 257688 bytes (24%) of program storage space. Maximum is 1044464 bytes.
Global variables use 26572 bytes (32%) of dynamic memory, leaving 55348 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.6
esptool.py v2.6
Serial port /dev/cu.wchusbserial1410
Chip is ESP8266EX
Features: WiFi
Traceback (most recent call last):
MAC: 50:02:91:75:e2:b2
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
File "/Users/berne/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/upload.py", line 25, in <module>
Configuring flash size...
File "/Users/berne/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool/esptool.py", line 2694, in main
detect_flash_size(esp, args)
File "/Users/berne/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool/esptool.py", line 2073, in detect_flash_size
flash_id = esp.flash_id()
File "/Users/berne/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool/esptool.py", line 567, in flash_id
return self.run_spiflash_command(SPIFLASH_RDID, b"", 24)
File "/Users/berne/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool/esptool.py", line 812, in run_spiflash_command
old_spi_usr = self.read_reg(SPI_USR_REG)
File "/Users/berne/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool/esptool.py", line 475, in read_reg
val, data = self.command(self.ESP_READ_REG, struct.pack('<I', addr))
File "/Users/berne/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool/esptool.py", line 332, in command
p = self.read()
File "/Users/berne/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool/esptool.py", line 277, in read
return next(self._slip_reader)
File "/Users/berne/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool/esptool.py", line 1877, in slip_reader
raise FatalError("Timed out waiting for packet %s" % waiting_for)
esptool.FatalError: Timed out waiting for packet header
esptool.FatalError: Timed out waiting for packet header
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

have no idee what this is:S


2 years ago

Nice post. You forgot to mention what value capacitor to place between VCC and ground - can you share this please?


2 years ago

Well done, just one remark on:
Step 4: Method 2: Using Basically Any USB to Serial Converter
That is not entirely true, it needs to be a 3v3 converter. You do not want to put 5 volt on your Rx and TX pins


Reply 2 years ago

just leaving this here, this is not entirely true. People tested this and if i remember correctly, the RX pin draws 26 μA when fed with 5V, which is not enough to do anything bad, plus there are necessary safeguards in place inside of the esp.

I've been using an ESP12E hooked up directly to a Mega2560 (high level is around 3V, so it's just there) and it's been working perfectly for months already. It's not officially 5V tolerant on RX and TX but it works.

What IS important is that the converter should be able to supply enough current. Some say 250mA but around 150mA will be fine if you use a capacitor


2 years ago

Thanks for this great instructable. I feel a little confused. In this post and in others that I have studied mention that it is necessary to have EN (CH_PC), RST, and GPIO in high and that GPIO 15 needs to be in low. I will tell you my experience to listen to your comments.
I am using an ESP-12E and a USB to serial adapter for my tests.
The ESP-12E has only the pins VCC (3.3V), GND and the test sketch (blink) works well. To do programming (using Arduino IDE), plus VCC and GND, I put RST to down and GPIO 0 to down, obviously the TX and RX are connected, and I can upload the sketch without problems.
My doubt is, I could expect some type of misfiring because the pins CH_PC (VCC) or GPIO 15 (GND) have not been connected. Apparently they are not necessary for the operation of the sketch and to do the programming.
I would like to hear your opinions.


3 years ago

This makes me want to go out and buy some of these, and check them out! Thanks for a well-written instructable.


3 years ago

The idea of using nodemcu for programming is great.
Is ESP12-F only the programed? or ESP12-F+Nodemcu (together) at the same time?


3 years ago

Great, I have a bare esp8266 roaming around . I will try to program and will share


3 years ago

Very "pro" instructable - nicely done! I ordered my ESP8266 today. Thank you for the contribution.


3 years ago on Step 5

I'd like to see more love for the esp8266-01 :-(
Regardless, nice instructables and thanks for sharing what you know!!