ESP8266 – Making it work

How to get an ESP8266 Board working

As you can see from the title, this page is a guide to getting a the small 8266 processor units to work.

If you want to use it simply, you can buy the units with programmer and all the support infrastructure ready made, for example on Ali-Express as here. Note this was just the first one that showed up, so it’s up to you if you use this one or not.

However for me, I wanted to keep the size as small as possible. If you want the background on how I got interested in the units, then take a look at this blog.

For this post I am using a combination of ESP-12E and ESP -12F units, the 12F units I got from here , these turned up fairly quickly and seem to work perfectly.

Doing a bit of checking online you find assorted information on connecting these unit up, the best I found was the datasheet on the ESP-12F from the Ai-thinker website, which you can get at this link. This is not the most detail on the core chip, but on page 13 does give the recommended application circuit. Shown below:

The key points here are the 4 resistors on RST, EN, GPIO15 and GPIO0.

The RST and EN (Reset and Enable) are operational mode pins used to reset and enable the chip itself (fairly logical given their names). However it is important to note that the Reset is Active Low (i.e. 0V = Reset and 3.3V = Normal operation). The Enable is Active High (0V = Not active, 3.3V = Normal operation). In practice this just means both are High for normal operation.

GPIO15 and GPIO0 however have other uses during startup. GPIO15 is used specifically to enable external SPI storage for program and GPIO0 is used to enable programming mode.

For most operations the GPIO15 is set to Low (0V), but the GPIO0 is normally High and only low for programming.

For me and probably most operations, this mean that we need 3 configurations of these pins:

Normal RunningHighHigh
Start ProgrammingHighLow

In all cases EN is High and GPIO15 is Low.

From this you can see the reason for the 4 Pull Up/Down resistors in the reference drawing as this makes sure the normal operation mode is the default.

However we do then need the ability to pull both RST and GPIO0 Low for us to program the device.

The simplest way to do this is to add two momentary push button switches.

To reset the device you can then just press and release the RST button, and to enter programming mode you Press both buttons together, release RST and then release the GPIO0 button. I will come on to improvements to this later, but actually I find this manual control to be must more helpful.

The other key point to take from the reference diagram is the decoupling capacitors, this has 100nF and 10uF on the 3.3V power rail. At first I didn’t have these as my supply was very close, but I was having a lot of erratic behavior until I added the 10uF capacitor to the board. Don’t be like me and waste a lot of time on this, just add the capacitors.

Programming for the ESP8266

For programming I use the Arduino IDE.

The first thing to do for this is to use the board manager and install the support for ESP8266, this should then look like:

You can then select Generic ESP8266 as the board type.

Write your sketch, typically use something like the blinky program, my version is as follows:

#define LED 2 //Define blinking LED pin
int count =0;
void setup()
pinMode(LED, OUTPUT);// Initialize the LED pin as an output
Serial.begin(74880); // Start the Serial communication to

// send messages to the computer
Serial.println("i am alive\n");
Serial.println("starting loop \n");

char buffer[80];
// the loop function runs over and over again forever
void loop()
sprintf(buffer,"loop %d\n",count);
digitalWrite(LED, LOW); // Turn the LED on
delay(500); // Wait for half a second
digitalWrite(LED, HIGH); // Turn the LED off
delay(500); // Wait for half a second

If you compile the code and there are no errors (CTRL R in arduino IDE), then it’s time to program the device.

Point to note here is that you might notice that I use 74880 Baud for the serial speed, and most other code you will see uses 115200 which is faster. However using 74880 allows you to also see the bootloader information from the ESP8266 and this can be helpful when you are debugging the startup.

How to program the ESP8266

In order to physically program the device, you will need to:

  1. have the relevant Pull up/down resistors in place
  2. Have switches to reset and configure the programming mode
  3. Have a stable 3.3V supply capable of 200mA+
  4. Have a suitable serial port with 3.3V I/O

The first 2 points I covered earlier.

For the serial port, I am using a standard USB to TTL serial converter such as this one. However do make sure it is configured to 3.3V and not 5V. You can do this by changing the jumper near the pin ends. This will give you the TX and RX lines needed, but do not assume the 3.3V output can power the ESP8266. Spoiler alert, it can’t.

For power, you could use any 3.3V supply (just make sure all the grounds are connected correctly). For ease of use, I use a small DC to DC converter which I stuck to the back of the serial adapter. You can then use the 5V from the PC as its input and set it to produce 3.3V as output.

In my case I feed the output from this DC DC converter to a wired Dupont connector and connect it to the center pin of the voltage select on the Serial adapter. This means the output from the board is from the DC DC converter and also the 232 converter is using the same supply. As a side note you can also use this to depower the device by unplugging the pin if needed. Just be careful to connect it to the center pin when re-connecting.

Note the large capacitor is not needed here, it was part of my testing.

Using this combination of Power Supply and Serial adapter, you have the required pins needed and these can be connected to the ESP8266 device. Take care to swap TX and RX as both adapter and ESP8266 use the device point of view. i.e. TX on 8266 is output and hence has to go to the RX (input) on the Adapter board.

If you have it all made up then you can select the appropriate COM port on the Arduino IDE:

You can then run the upload option (CTRL U) and it will recompile and then upload.

Before it does the upload though, you will need to put the device into programming mode. Press and hold both buttons, release the RST and then release the GPIO0.

The programming should start and you should see something like:

If it just says “connecting …____…” then it’s most likely that you have not put the board into programming mode, simply try to reset and try again. If this still doesn’t work, then see the trouble shooting section later.

Seeing what’s happening

The Arduino IDE has a tool called serial monitor which is very helpful as it allows you to see what the output of the device is doing. Simply select this and ensure it is configured to the correct COM port and importantly is set to 74880 Baud.

Once it’s set up and open, press and release the reset button (without touching the GPIO0 button) and the output should give you the boot loader information and if all worked okay the startup messages and count from the program.

It should look something like:

Sketch booting and running

The LED should also be blinking at a 1Hz rate.

If this works, then congratulations your system is working.

Making the code more functional and especially using the WiFi elements will be another post.


Corrupt character showing in serial monitor

If you see something like:

In the serial monitor then it is likely there is a problem with the baud rate, either the serial monitor is not set to 74880 or the Arduino sketch is set to a different value.

Incorrect boot mode displayed.

If after a normal reset the boot mode is not showing as (3,6) or (3,7), then there is probably an issue with your pull up/down resistors.

The 1st number 3 in the idea case give the bitwise values of GPIO15,GPIO2 and GPIO0. so the value of 3 is in binary 011 which means the GPIO15 is low, GPIO2 is high and GPIO0 is high (ideal).

If the 1st number value you see is 4, 5,6 or 7 then the GPIO15 resistor is not pulling the pin to ground. This should be your first thing to fix.

If the 1st number is 0 or 2 then the GPIO2 pin is shorted to ground, this pin has an internal pull up but is may be shorted as it is next to the GPIO5 pin.

Note: Technically the pull up resistor is via the LED, not internal to the core chip.

If in a normal reset you see 1 as the 1st digit then the GPIO0 pin is shorted to ground, since that’s also attached to a switch, you need to check that the switch is actually working as well as the pull up resistor is connected.

Note that in programming mode you should see 1,6 (or 1,7) as this is the normal programming mode.

Boot mode for programming

Boot loader but nothing else

If all you see in the Serial monitor is the boot loader, such as:

And nothing else, then there is a problem with loading. If the previous programming went well (no errors) then there can be a few causes.

  1. If there is no Serial output from the program this would be the case. So best to make sure there is at least a simple “Hello world” output just to show operation even if you don’t intent to use any serial in the main program.
  2. if there is something but it’s not readable, then check the baud rates as it’s possible the program is using a different baud rate to the boot loader.
  3. Power supply. Check you power and check again you have included the board capacitor. The board can happily boot and program but fail to run a sketch if the power is not good.

Program starts but crashes/freezes when trying to use WiFi

A bit more for the next article, but I had 2 additional issues when using WiFi.

Before you go further, recheck the power and capacitor. Honestly this caused me more issues than anything and I wasted a lot of time chasing up issues due to decoupling.

Okay if you have checked and still getting issues, then check your RST wire. As the RST pin is right at the end nearest the WiFi antenna, I found a couple of times that the board would reset when I tried to turn on the WiFi. This appears to be pick up in the RST as rerouting the wire to RST away from the Antenna track seemed to fix that issue. This is probably marginal and a separate filter capacitor on the RST pin would also probably solve it.

Exception Errors that stop booting

On occasions I was getting exception errors whenever I tried to run a more complex sketch that used WiFi. Returning to the blinky sketch (with no Wifi) still caused exceptions. This appears to be caused by corrupting the WiFi settings (which are not always reset even by re-programming).

Simple fix to this is to ensure all the flash is erased. As a default now, I always erase the sketch and WiFi settings, and have not had the issue since, other than programming errors.

More Colours

After yesterdays post, I had a bit of feedback asking if there would be other vendors colours (not just the Vallejo Game Colour range). The original post with how I got these charts can be found here. As I was able to get the RGB values from a few other ranges, I have now generatedContinue reading “More Colours”

Formatting in WordPress

This page is a test, but might help. I originally was using this page to help me to try out new layout styles and techniques. But it ended up having information which might be useful to others, so it’s published rather than being internal only. I would like to use the various plug-ins and inContinue reading “Formatting in WordPress”


Something went wrong. Please refresh the page and/or try again.

Get new content delivered directly to your inbox.

%d bloggers like this: