Programming an ESP-01

A little while ago I started on a project where an ESP8266 would take a reading on one of its GPIOs periodically, and push this value to a server over WiFi. This was my first time working with the ESP8266, and I found it to really only be valuable because of the user community.

During the process, I don’t think I saw a single scrap of documentation from the manufacturer, but I didn’t need to. Due to its price, the production of a few choice breakout boards, and its availability for a few years, there are enough resources online if you know where to look.


The book

A fantastic book has been put together by Neil Kolban which goes into some depth about what the ESP8266 is, what kind of modules are available, where you can buy them from, how to create your dev circuit, and many other things (to be honest I only read the first quarter or so, and this had enough info to get me going).

The software

The ESP8266 can be programmed using Eclipse and the right libraries. Some legend, “CHERTS”, has bundled everything necessary into a software dev kit for Windows, with instructions on how to configure it.

I followed these instructions as well as I could, but made two changes:

  • For Java Runtime I used version 8u65, x86 instead of 7uXX as stated.
  • MinGW link took me to latest version on SourceForge. I’m not sure which version the tutorial would have originally been written for.

These changes did not make any difference and I was able to get my dev environment set up without hassle.

As far as I know, you’re on your own when it comes to development on Linux or Mac.

The gear

The main components of the system are the power supply, the FTDI USB to RS232 programmer, and the ESP8266. In this case, I am using the ESP-01 module.

I got a nice little USB to breadboard power supply from Little Bird for less than AUD4, and the ESP-01 and programmer from a mate. I couldn’t say what their origins were, but the ESP-01 seems typical, while the programmer had some issues which are explained later.

The ESP-01 does not fit neatly into a breadboard. You can get around this putting female to male headers with long legs into the breadboard, and kinking them so that they fit the pitch of the headers coming off the ESP-01 module. I didn’t have any such headers on me, so I soldered the ESP-01 to some veroboard and soldered some leads to it to go in the breadboard. Let’s just say I would not recommend this approach.

Some wire, resistors, capacitors and momentary switches are also required.

Programming the ESP8266

To put the ESP8266 into programmable mode (or “flash update” mode), GPIO0 is held low while the chip is being booted. Once this is done, the TXD and RXD lines can be used to download the program from your PC.

Cherts dev circuit

Initially, I attempted to program the device using the method outlined by Cherts, which is straightforward:

Programming circuit of the ESP-01 from USB to RS232 converter. Original link in Russian, Google translated to English link.

Since we have access to DTR and RTS, we can use them to trigger the RESET and GPIO0 lines so that it goes into programmable mode. However, I just could not get this working.

Kolban dev circuit

The far more reliable, but costly (in terms of dollars and time) solution was to follow the exact circuit described in Kolban’s book, on page 37 of the January 2016 edition or the first section of this post.

Wiring up an ESP-01 and an FTDI USB-RS232 programmer (Neil Kolban).

Pushing S1 will bring RESET to ground, and pushing S2 will bring GPIO0 to ground. These are used to put the ESP-01 into programmable mode, by setting GPIO0 to low on boot. The process is as follows:

  1. Push and hold S2
  2. While holding S2, push S1 for a second then release
  3. Release S2

To put back into normal mode, just push and release S1.

I have a few theories as to why I could not get Cherts’ system working:

  • Pullups ensure that GPIO0, and RESET are pulled to either supply for high or ground for low.
  • My USB-RS232 was running at 5V, not 3.3V. I used a voltage divider for the connection to the ESP-01 but could have made a mistake.
  • The supply through the USB-RS232 may not have been sufficient to power the ESP-01 as well as itself. Kolban’s circuit draws its power from the rail, not the USB-RS232.

Downloading software

There are many example projects available in the Cherts bundle. You should be able to build and download these “as is”, but you will probably have to make a change to each of their Makefiles, on line 23, where the default COM port has been set up.


Change this to whatever COM port your FTDI programmer is on. If you are seeing:

ValueError: Cannot configure port, some setting was wrong. Original message: WindowsError(87, ‘The parameter is incorrect.’)

when you are attempting to download your code, you likely have the wrong COM port entered here.

Listening to your ESP-01

If you’re not using your USB-RS232 for programming the chip, you can use it to display any messages your ESP-01 is sending out on Putty. Simply enter the correct COM port, and for speed use a baud rate of 115200, as shown.

2016-01-24 18_42_58-PuTTY Configuration
Opening a connection to your ESP-01’s RS232 lines through an FTDI USB-RS232 converter on Putty.

In the example projects in the bundle from Cherts, select the “Hello World”, and build and download it onto the ESP-01.

Once the program has downloaded, open Putty and start the session. Push S1 once to reboot the device in normal mode. You will see a bit of garbage (although it looks like it would be meaningful information to someone) before it starts printing “Hello World!”.

2016-01-24 18_55_10-COM5 - PuTTY
Output on Putty when connected to the ESP-01, running the Hello World example in the Cherts dev kit.

Un-bricking your FTDI chip

A major hurdle, and apparently a fairly common one that I came across was having an illegitimate FTDI chip on your USB to RS232 converter. As is usually the case when a chip is wildly successful, fakes start appearing on the market. Chances are, if you have gotten a great deal on your chip, it will be fake.

This only became a problem for consumers when some bright spark at FTDI wrote a check into the Windows driver v2.12.xx and later. If you are running this version of the driver, it will totally brick your device by overwriting its product ID to 0000. Even if you go back to a machine running earlier drivers, it still won’t work.

The best way to deal with this is through prevention. Disable automatic driver installation before you plug anything in. Once you’ve plugged it in, install driver v2.10.00 manually, which you can still get from FTDI’s website.

You can tell a device driver is bricked by connecting it to Putty as described above and getting the ESP8266 to send some data to it. This can be achieved by booting the ESP8266 normally, and a few strings will be sent over its TXD line. If it’s a dodgy FTDI chip, it will just print


Unbricking it is quite a process. The steps I took to do this were taken from these two excellent guides.

  1. Download Windows driver v2.10.
  2. Modify the drivers so that instead of looking for PID 6001, they look for PID 0000 (as in Find and Replace “6001” with “0000”)
  3. Install these drivers manually. You will have to disable check for certified drivers, as their hash will no longer match their certificates (because they were edited). Disable by going Run->gpedit.msc->User Configuration->Administrative Templates->System->Driver Installation->Code signing for device drivers->Enabled and Ignore.
  4. Download FT_PROG:
  5. Reprogram that bastard with default PID 6001
  6. Uninstall our modified driver. Uninstall all FTDI drivers. Make sure automatic installation of drivers is disabled!
  7. Install the unmodified version of v2.10 (or earlier, if you want).

One thought on “Programming an ESP-01

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s