Introduction: ESP8266 Bits 'n Pieces!

About: Just me!

I played with the Arduino for quite sometime & I have several UNOs, MINIs, NANOs, ...

The IDE is awful but easy, lots of resources, lots of projects, lots of supporting addons to play with, ... heaven for makers!

You need internet connectivity? No problem! just connect the ESP-01 sketch & you are ready to go. But wait a minute, this ESP-01 already has a microprocessor in it & you can program & no need for the Arduino!

But, who wants to learn new tricks & new IDE? wait, it is also ported to the Arduino IDE!

That was the beginning of a new era!

I think the ESP8266 now is The board of choice for almost any small project that needs Internet - A real IoT for a buck or two!

All based on the ESP8266 WiFi chip with a microcontroller produced by Espressif.

What makes this chip unique is its the price - For less than $2 you may get yourself a working development board with Internet connectivity and plenty of room for your program & all for less than $2

This instructables are data collected from here & there & may even look scattered & unsorted but I tried to put all the links that got me going in one place as a reference.

The WIKI page has all the needed information & more.

A very active forum that has everything you may need to know.

For a lot of to technical you should check the Kolban's book.

For Arabic speakers there is an arabic book but I have not checked it - it maybe downloaded from here.

Step 1: ESP Breakout Boards and Modules

The ESP8266 is a tiny IC (produced by Espressif) & it is very hard for soldering or breadboarding - and since its production on 2014, the ESP8266 was just used in several Internet controlled devices such as lamps & power sockets. Only when companies such as AI-Thinker produced several development/breakout boards or modules to work with that it was easy for us to use & play with.

The board comes in different shapes & capabilities. All
share the same brain; ESP8266 but varies physically (Dim: W x L) & electronically (available I/O pins & size of flash memory)

Some are breadboard friendly & some not due to pin spacing or pin arrangement but there are always workarounds to use them for prototype on a breadboard & several adapters are available to do just that.

All are listed in the WIKI page and also on this page.

Each board has a flash memory chip with a certain size. You must know the flash size of your board to be able to upload firmware or programs to it.

Here I will discuss the boards that I already have & worked with. Again, all the data comes from the internet, I claim no rights for anything in the following pages & I’ll post the references if I know it but some data maybe so common to list a reference or I forgot where I got it from. Please let me know if a reference or a link to original content is missing.

Step 2: ESP-01 Boards

ESP-01 is the first that came out & it was intended to be used with other microcontroller. It has only 2 I/O & programmed to talk to the wold using the good old AT commands of the Hayes Modems era.

Here is an introduction.

The Flash sizes of different boards as per the datasheet:

1. The Blue PCB is 4Mb (bit) = 512 KB (Byte) = 0.5 MB (Byte)

The Black PCB is 8Mb (bit) = 1024 KB (Byte) = 1.0 MB (Byte)

It maybe hard to read the tiny numbers on the chip to know its size but later we'll see later how to interrogate the board for the flash size.

Step 3: Modifying the ESP-01 for Breadboarding

Although the 4x2 DIL in the ESP-01 is 0.1" the pins will be shorted if used in a breadboard.

There are several adapters to fix this & you can even make one your self.

A neat DIY by technochatter is here.

If you're good in soldering & desoldering then one way to fix it is to flip one of the pin lines to the other side of the PCB as in the photos.

1. De-solder the top 4 pins
2. bend the bottom 4 pins.
3. Solder 4 90-dgree pins on the other side of the PCB.

Test the board again & if the "OK" is received then the job is done.

Step 4: ESP-01 Out of the Box (AT Commands)

To test the ESP-01 we need:

1- ESP-01 of course.

2- USB to Serial (FTDI) - I will be using the modified BTE13-009 (check my other instructables article)

3- F-F / M-M / M-F Dupont wires

4- Any terminal program - I am using CoolTerm or Termite or PUTTY or any terminal program.

5- A 3.3V power source - I will be using the MB-102 power module in the breadboard (see my other instructables article)

ESP-01 as in the diagram:

Tx to Rx

Rx to Tx

3.3V to ESP Vcc

Power supply GND to ESP GND and BTE13 GND (very important to tie all grounds together.

Connect the BTE13 to USB & Start CoolTerm. If the driver is installed correctly select the COM port on Options & "Connect".

Power on the ESP-01 and type "AT" on CoolTerm and press ENTER & you should receive an "OK" on the terminal window.

Step 5: ESPlorer - the IDE for ESP8266

Several tools are published that makes playing with the board as fun as it can be!

A must see is ESPlorer - It is a Java-based tool written by Victor Brutskiy & as described on his website:

The essential multi-platforms tools for any ESP8266 developer including a LUA for NodeMCU and MicroPython. Also, AT commands are supported.

Check this tutorial on using Esplorer with Lua.

Step 6: AT Command (original) Firmware

This is the default firmware flashed in most if not all ESP-NN series.

There are several variations of this firmware - AI-Thinker & Espressif maybe downloaded from here.

All AT commands are in Espressif Documents - "ESP8266 AT Instruction Set" and "AT Command Examples".

I think other implementation of AT Command firmware may have more/less AT commands.

v1.3.0.2 AT Firmware.bin

AT Firmware by AI-Thinker:

• V1.1.1 (115200) [not for 512K boards like ESP-01]

AT version: 5 2015 16:27:16)
SDK version:1.1.1
Ai-Thinker Technology Co. Ltd. Jun 23 2015 23:23:50

• V0.9.5.2 (two versions, 9600 & 115200)

AT version:
SDK version:0.9.5

v0.9.5 Beta (9600)

compiled @ Dec 25 2014 21:40:2
AI-THINKER Dec 25 2014

You need to make sure that the size of the firmware matches the board's flash size or the upload will terminate with an error (more on this later)

Trying to flash ESP-01 (Blue board 0.50 MB) with v1.3.0.2 AT Firmware.bin (1.00 MB) ended with an error at 50% (obvious!) - but when I tested the board at baud rate 115200 I got this:

Ai-Thinker Technology Co.,Ltd.
AT version: (Aug 8 2015 14:45:58)
SDK version:1.3.0 Ai-Thinker Technology Co.,Ltd.
Build: Sep 11 2015 11:48:04

I'm sure it will break with certain commands though!

Step 7: Flashing Tools:

AT commands is not the best way to utilize ESP boards and there are several firmware flavors available to satisfy all needs.

To change the board's firmware you need a flashing program, get the firmware binary file (s) & connect the board to the PC using the USB to serial as in the diagram.

The flashing procedure is simple; you power off the board & power on again while GPIO0 is pulled down to ground.

This can be done by holding the push button on the diagram above while power off/on or GPIO0 maybe connected to DTR & the flasher should do the job (not all flashing tools can do that!)

There are several Flashing applications available - some of them are command line based & some have GUI wrapper to facilitate the process.

For tech info you may read the Flash read/write introduction at Espressif

Espressif (?) esp8266_flasher: Very simple, just select the firmware BIN file & the COM port then press "Download"
A tutorial can be found here and also a video tutorial.

A more advanced flasher by Espressif maybe found here - ver 2.4.

I couldn't find a simple tutorial so I am attaching a screen shot with some help!

• Using the Flasher by NodeMCU team: it maybe used to flash other firmware binaries as well not just NodeMCU.
A tutorial video& another video.
• Another flashing tool is esp_flasher also from Espressif

Step 8: ESP BASIC Interpreter Firmware:

Most of stone age people like me started with BASIC language & here is ESP BASIC Flasher!

The interesting thing about this is firmware is that once flashed the board, you can program the board just by wireless connection to the board using a web browser.

This is a work in progress (as described by the developer) & the future is promising!

To get our LED on GPIO2 to blink check the code here. - copy the code in the "EDIT" tab.

One feature in ESP BASIC that I use often is "Format Flash" to erase the flash to fix a board if it is corrupted due to a bad upload. This is the only GUI I found to do this.

After Flashing if you look at it with 9600 terminal you get:


To "Format Flash":
Run ESP_BASIC_Flasher.exe & select the COM port & the size of the flash in the ESP then press "Format Flash" to remove any bad firmware. Normally I do that when I can't upload new firmware to the board.

After this process a non-responsive board may come to life again & may be flashed by a working firmware.

Another version of BASIC is called Zbasic is intended for a ZX microcontroller family by Elba Corp. - developed as a subset of Mico$oft VisualBasic 6 with some extension to support their hardware and some other platforms. They announced a ZBasic for ESP8266 & it is not free ($199)

Step 9: MicroPython Firmware

This is new comer for running Python 3 scripts on any ESP board specially NodeMCU board.

It is a Kickstarter project and binary firmware for version 1 is released early May 2016 to backers only.

Non-bakers should compile the code by following this.

MicroPython firmware 1.7-130 is included with ESPlorer

An unofficial nightly build of the MicroPython for ESP8266 firmware (dated 25 May 2016) maybe downloaded from here - another build is here.

Check the video & also a quick rereference.

A very lengthy & detailed how-to by Tony DiCola from AdaFruit Learn site starting by how to build the firmware & how to use it is here - also videos are available, Part 1 & Part 2.

I have never used Python before & it looks too complicated for me & I am very happy with C on the Arduino IDE so it is all yours to try.

Step 10: Espruino, JavaScript Firmware

Espruino is a special development board and the firmware is open source & maybe flashed to almost any ESP module.

The latest firmware is here.

Like ESP Basic, you just need a browser to program the board. The IDE is a Chrome add-on that may be downloaded from here - even a graphical programming IDE is included!

You have to set the "baud rate" first in order to start working from settings (The gear icon on top right corner) then "Communications" and select 115200.

Step 11: Using Arduino IDE With ESP866 Boards

IMHO that was the real take off of the ESP8266!

Starting with version 1.6.4 of Arduino the IDE already supports ESP8266 boards.

A tutorial for how to setup the IDE for ESP8266 development.

You need to go to "Preferences" in the file menu & add:

to the additional board text box.

After that you go to "Board Manager" from the "Tools" menu & update the boards to load ESP8266 core files.

That's it!

We can go & test the Blink example but we need to change the LED pin to 2 instead of 13 for the UNO board.

Note that you can't use the serial monitor & blink the LED since the internal LED on GPIO2 which is also the TXD pin.

Check this instructables for a clever way to utilize the GPIO pins on the ESP-01 as GPIOs.

Step 12: ESP-01 Blink by Arduino IDE

Connect a LED to GPIO2 as in the diagram & open Arduino IDE.

Set the board as in the figure & load the Blink example.

Make sure that the output pin = 2 and Upload the sketch to the board.

The led should be blinking & your IDE is ready.

Step 13: Other Boards: ESP 07 & ESP 12

There are not many technical differences between the 2 boards - both has the same pin-out & same 4M flash.

The main obvious difference is the antenna shape hence the range & signal power I guess (!).

There is no zigzag track on the 07 board - instead there is a long odd looking thing which is a ceramic antenna. Also there is a U.FL connector to connect an external antenna (more on this later)

I haven't checked the difference in performance between the ESP-07 (ceramic antenna) & ESP-12 (PCB antenna) but if want, you may check here.

The module pin spacing is not the standard .1" but using a smaller 2.0mm that is not breadboard friendly. So I ordered an adapter board that is compatible with ESP-07 & ESP-12.

The adapter board has unoccupied pads underneath supposedly to solder a 3.3V regulator so you may use a 5V power supply - I am using a 3.3V power supply so I didn't use these pads - more in using a regulator maybe found here.

The adapter is not very breadboard friendly - actually it is a little bit wide leaving no room for connection on the breadboard so I used 2 breadboards to easily work with it.

Step 14: Other Boards: ESP 12E & ESP 12F

The main difference from the previous modules are the 6 extra pins along the bottom edge of the module (read on!)

I don't have the ESP-12E because when I ordered I got the ESP-12F module.

The Breif specs doc for the ESP-12E may be interesting (strange that the silk-screen on the photo inside is labeled ESP-12Q!)

The schematic for ESP-12E maybe found here.

ESP-12F is supposed to be an enhanced E version, with better antenna (claiming 30-50% communication distance increase compared to ESP-12E!), FCC & CE approval, RHOS and 4MByte Flash.

The ESP-12F spcs page from Electrodragon and the schematic is strangely labeled ESP-12Q and it is identical to the above schematic for the ESP-12E! - maybe the component quality is different - who knows?!

The ESP boards are mysterious :)

Now for the 6 extra pins, SCLK, MOSI, MISO, CS0 & GPIO9 & 10.

From the schematic, these are SPI0 pins (not HSPI pins) - the usage of these pins is not easy because they are directly connected to the SPI Flash and using them will interfere with Flash operation. It is reported working but I haven't played with it yet.

As far as I know, SPI pins are not yet supported by the ESP8266 Arduino IDE till this moment (July 2016)

Step 15: NodeMCU Board

Saving the best for the last!

This board IMHO is the best tool to explore ESP8266 world. It's a real plug-n-play solution with its on-board USB-to-Serial & the automatic Flash/Reset circuitry there is no need to do anything other than pressing the "Flash" or "Upload" button to get the firmware or program to the board (with ESP Flash Download tool 2.4 the board do not automatically enter flash mode & I have to press RST button & press FLASH button then release RST then release FLASH)

It is ESP-12E with 32Mb (4MB) of Flash memory

It is a great easy to use board - works with all the flashers & IDEs so you'll never lose buying this boards.

I also ordered the baseboard which make prototyping much easier.

Step 16: Lua Firmware (for NodeMCU Board)

This is the official Lua firmware flasher NodeMCU Flasher.

Lua is a programming language. I've never used Lua & I don't think I'll have time soon to learn a new language!

But, you may find this tutorial useful - and this also.

NodeMCU is supposed to work with NodeMCU DevKit (more about this board later) based on the ESP-12 core but the firmware maybe flashed on other boards as well (I flashed ESP-01 without problems but using the DevKit has many advantages)

The firmware page has both Integer(less memory usage) and Float version firmware provided.

You may use NodeMCU Stodio to upload programs to the board.

There is a GUI called LoaLoader basically for Lua.

Another Loader is LUA Uploader by Hari Wiguna - also a Lua only and Hari made a very good tutorial for it.

Another GUI is ESPlorer which is described as Integrated Development Environment (IDE) for ESP8266 developers.

It is not just for Lua but also supports AT commands & MicroPython (later).

A tutorials for ESPlorer maybe found here.

Lua may be used to check the board flash size with the function:

0 9 6 16398478 1458400 512 2 40000000

512 is the Flash size - the rest of the values are:

0.9.6 is the firmware version

16398478 is the Chip ID (0xFA388E)

1458400 is the Flash ID (0x1640E0)

512 is the Flash size
2 Flash Mode
40000000 is the clock frequency

Step 17: NodeMCU Bounce, a Scratch-like Visual Language

I have just heard about this language a week ago but haven't used it so I am just adding the link for reference.

It is designed for the esp8266/NodeMCu using the LUA NodeMCU firmware.

Bounce maybe downloaded from here - it is a Google Chrome browser extension.

There is an interesting video too!

Step 18: Other Boards: D1 Mini WeMos Board

I just received this board & haven't tried it yet but it looks promising.

As stated on the site:

• 11 digital input/output pins, all pins have interrupt/pwm/I2C/one-wire supported(except D0)
• 1 analog input(3.2V max input)
• Micro USB connection.
• Compatible with Arduino.
• Compatible with NodeMCU.
• lots of shields.

I'm ordering some shields for this board & maybe doing an instructables later.

Step 19: Other Boards: ESP 201

This board is breadboard friendly only if you desolder the 4-pin header & revers it to point up.

The board came with an external antenna & although there is an internal antenna it only worked with the external!

On checking the PCB, I found out that the internal antenna is not even connected & a ZERO-OHM SMD resistor is supposed to be desoldered & soldered vertically to have the internal antenna connected (later on, I discovered this page that could have saved me 2 hours!)

The module is not good IMO since it is not shielded & prone to interference - but since I already have it, there is no harm to try it.

I trimmed the external antenna since it was a bit longer than it was supposed to be (back to school days:

λ {Lambda} for the WiFi 2.4GHz wavelength = c / f = 125mm - and the antenna = λ / 4 = 31.25 mm)

Anyway, this board won't be used!

Step 20: Other Boards: ESP-14

I ordered this module without checking the specs thinking it is an update for the ESP-12!

It turned out that it is a completely different concept - it has "STM8S003 Inside" engraved on the metal can.

The STM8S003 is microcontroller & we need to learn new tricks to work with it - I am not sure why did they choose this approach but I think they are targeting AT guys giving them more I/O pins - it might work!

I found few data on this board & in one Electrodragon page is giving a simple schematic to work with the module.

The schematic in AI Thinker PDF is a bit strange to me since it has a push button RST to GND & a push button E_GPIO0 to GND while the board has no push buttons at all!

All M_??? pins are directly from the STM only 2 pins are vonnected to the ESP chip, GPIO0 & E_VDD plus GND of course.

M_PD5 is STM8_TX and also ESP_RX
M_PD6 is STM8_RX and also ESP_TX

So is the ESP-14 flashable? Yes, instructions are here but what's next? you still need to deal with the STM8.

I am preparing my ESP-14 & will play with it - for now, it doesn't look very interesting as you must use AT commands only :(