Circle Device


Quick Reference

Programming the ESP8266

Programming ESP8266

The ESP8266 is a cheap WiFi enabled module that can be used very easily for simple and complex projects. Here I want to write my experience with the device, for reference and perhaps help others

Environment Setup

There are many sites and videos that detail how to install the platform and the various tools for Arduino. The Xtensa processor (the one used in this module and the ESP32 series) has a GCC compiler that is used by the Arduino environment and in here I intend to use it directly.

The following files I downloaded:

The first is a set of tools that is used to download your new firmware to the device. The second is the GCC compiler for the Xtensa LX106. They are all downloaded by the Arduino IDE so if it is installed they are likely already present on your system.

To test that eveything is working as it should, use esptool to download the AIThinker AT firmware to the ESP8266 device. Firmware is available here. Before powering the device you must put it into programming mode, this can be achieved by connecting GPIO_0 to GROUND then power-cycle the device.

./esptool -cp /dev/ttyUSB0 -cb 115200 -cf ~/esp8266/ai-thinker-v1.1.1.bin

You can also try the command (see references).

./ -p /dev/ttyUSB0 write_flash 0x00000000 ~/esp8266/ai-thinker-v1.1.1.bin

Once written, reset the device, open a serial terminal and verify it worked, here are some commands to try, they should all solicit some response from the device:


Sample Programme

First configure and check the toolchain is working:

export PATH=$PATH:~/esp8266/xtensa-lx106-elf/bin
xtensa-lx106-elf-gcc --version
xtensa-lx106-elf-gcc (crosstool-NG 1.20.0) 4.8.2

The sample programme I will use is available from the expressif github page: Clone this repo and play along with me :-).

Open the ESP8266_RTOS_SDK/examples/wifi/wps directory and run make menuconfig. Leave everything alone except the Serial flasher config (we will not use it but it will output all the arguments for which is nice).

In the build/ directory there should be our compiled code wps_example.bin along with a number of directories containing object files. There will also be warnings during compilation... we may have to resolve these later. Now, write the binary code to the device:

  • GPIO_0 to GND
  • read the command as outputted by the make or just make flash
  • Remove the GPIO_0 to GND link and ower-cycle the device
  • I would suggest minicom but it does not support the 74880 baud rate that is enabled in the firmware of the ESP8266
  • so... use tools/ examples/wifi/wps/build/wps_example.elf

When connected there should be occasional output of:

scan status 2
wps scan
build public key start
build public key finish
wifi_wps_scan : 17
scan status 4

Also... boot messages... but idf_monitor seems to die when they appear.


The ESP8266 mini module with a 0.1 inch header for UART and power is the cheapest and simplest device.

+-----------------+  View from TOP (
|                 |
| [2] [4] [6] [8] |  1 - RX
|                 |  2 - VCC
| [1] [3] [5] [7] |  3 - GPIO_0
|                 |  4 - RST
|                 |  5 - GPIO_2
|   ICs Here      |  6 - CH_PD
|                 |  7 - GND
|                 |  8 - TX

Firmware Writing Connections

This is not my artwork... if it is yours and you would like a link please send me an email.


Quick Links: Techie Stuff | General | Personal | Quick Reference