WiFi with ESP8266

Since end of 2014 there is a very interesting WiFi module with application processor, called ESP8266, on the market, at a price of about 3 EUR. The main application is a Serial to WiFi Bridge, named AT.

Look at http://www.ebay.de for ESP8266 Serial WIFI Wireless Transceive Modul LWIP AP+STA.

I already used an ESP-01 module in a project as a Serial Transparent Bridge (from beckdac), see ArduinoLabPSU2#WiFi_ESP-01.

If your Access Point changes, it is annoying to change the credentials in the Transparent Bridge via programm change. So I was looking for a better solution.

1. A promising software is esp-link, it works reliable since version 2.2.3.

2. An other software is a fork of beckdac, ESP8266-bridge, which allows to set the cedentials from the serial side via +++ commands.

3. There is in the Arduino ESP8266 libraries an example WiFiTelnetToSerial.ino for a Transparent UART to Telnet Server. I added to this example a WPS (WiFi Protected Setup) functionality via push button switch, named WiFiTelnetToSerialWPS.ino.

Now, in case of an Access Point change, it is no longer needed to enter manually the credentials into the ESP8266, if the WiFi Access Point supports WPS.

/!\ There is a 5 minute timeout in the ESP8266 WiFi stack. That means, if you have after the first WLAN connection a data traffic pause longer than 5 minutes, you to have to resync the connection by sending some dummy characters.

/!\ It is much easier to develop application programs for the ESP8266 via Arduino IDE (actual version 1.6.12), than with the Espressif programming environment (SDK).

ESP8266 module





The most common module with printed PCB antenna:

CH_PD          GPIO2
GPIO16         GPIO0

/!\ pull up CH_PD, GPIO0, GPIO2 and RST with a 3.3 - 10 KOhm resistor each to 3.3 V.
    That will improve the noise immunitiy.

CH_PD: VCC - start from Flash ROM (normal operation)

GPIO0: Hold short to GND while releasing RST - enter update firmware mode
       Timing diagram:
      ----+        +---------  3.3 V
RST       |        |
          +--------+      0 V

      -------+         +-----  3.3 V 
GPIO0        |         |
             +---------+  0 V

Connecting on an USB-Serial interface, RDX and TXD should be crossed.

Because of the 4 MBit Flash ROM size for the ESP-01 module, only firmware version up to 1.2 (SDK) are programmable.


For programming the ESP-01 under Ubuntu and with an USB-Serial adapter (3V3 version), you can download from here. After unpacking the archive the user must get the dialout group permission:

$ sudo usermod -a -G dialout rudi

# logout, login and check:
$ groups
rudi adm dialout cdrom sudo dip plugdev lpadmin sambashare vboxsf

# test the connection
$ ./esptool.py read_mac
esptool.py v1.0.2-dev
MAC: 18:fe:34:9d:4d:95

Quick Start

There is a lot of information in the Internet about this interesting module. I will use module ESP-01 with patch antenna on board.

For a beginner, you should start with Links #6

You need an USB-Serial adapter for that. /!\ Take care to use a 3.3V unit, not 5V.

That works also in a VirtualBox installation, just announce the USB adapter to the virtual machine (e.g. FTDI FT232R USB UART [0600], or Silicon Labs CP2102 USB to UART Bridge Controller [0100]). If it does not work, try to swap RXD/TXD on one end.

Setup your ESP-01 for WLAN Router access, those data are stored in Flash-ROM and survive also a firmware update.


[Vendor:www.ai-thinker.com Version:]


    SDK version: 18
    Firmware version: 0902


AT version: 20 2015 10:04:26)
SDK version:1.0.0
compile time:Mar 20 2015 11:00:32






AT+CWJAP="Wifi SSID","password" # Syntax





OK  18:FE:34:9D:49:43       54 MBit/s       WPA2 
ESP-01 module #1 of 5

Community Forum and Wiki

There is a ESP8266 Community Forum and wiki at Links #1. I will mention important postings.

Transparent Bridge

It is the best compromise to set the baud rate to 115200 baud, which is stored in EEPROM.

You need an USB-Serial adapter for that (ESP-01). /!\ Take care to use a 3.3V unit, not 5V.

/!\ Do not use the 3.3 V supply of a CP2102 USB-UART converter, it allows 100 mA only

/!\ Better is a AMS1117-3.3V Modul (max. 800 mA), cost is about 1 EUR (delivered from China).

Unfortunately with the original firmware (version 0.9.2 - 1.0.0) a serial transparent bridge is possible only in send mode, not in receive mode. Therefore the effort of some programmers to create a software for a Transparent Bridge for both directions.

Following some implementations.


This was the first Transparent Bridge open source software, but the most difficult to use, especially for setup or changing the credentials (SSID, password).

Fortunately a nice programmer (on github named beckdac, on Forum named dacb) extended the firmware with a serial transparent bridge in both directions, see Links #11,12,13.

It looks like, that with this software the Station login credentials can not be set. So, set first the Station login credentials with the expressif firmware (up to version 1.2 for 4 MBit ESP-01). Then flash the Transparent Bridge software.

Version May 2016 will now allow to control the GPIO2 output via AT command (0, 1, 2=pulse down for 100ms).

The programming of the Flash ROM can be done with esptool.py, see Link #14, 15. That needs also Python package pyserial, which is also installed, when esptool gets installed.

It looks like, that firmware version 0.9.5 was the base.

To program this software to the ESP-01 module do the following, under Linux/Ubuntu 14.04.

That works also in a VirtualBox installation, just announce the USB adapter to the virtual machine (e.g. FTDI FT232R USB UART [0600], or Silicon Labs CP2102 USB to UART Bridge Controller [0100]). If it does not work, try to swap RXD/TXD on one end.

# Download the github master ZIP: ESP8266-transparent-bridge-master.zip
# unpack archive

# Download the github master ZIP: esptool-master.zip
# unpack archive (version 1.04, 2016)
$ cd esptool-master
$ sudo apt-get install python-setuptools
$ sudo python setup.py install
default port: /dev/ttyUSB0
default baud: 115200

# connect the ESP-01 to an USB-Serial adapter, GND, RXD, TXD and 3.3 V (max. 250 mA)
# connect at the ESP-01 module CH_PD to VCC (via 10k resistor)
# connect at the ESP-01 module RST to GND (Reset)
# connect at the ESP-01 module GPIO0 to GND
# connect at the ESP-01 module RST to VCC (via 10k resistor)
# connect at the ESP-01 module GPIO0 to VCC (via 10k resistor) U = 1.9 V
# pulse at the ESP-01 module RST to GND (Reset), or reconnect modul
# GPIO0 should show now U = 3.2 V

# test the connection
$ ./esptool.py read_mac (in another folder $ esptool.py ...)
MAC: 18:fe:34:9d:49:43
# that looks good
or on MAC OS X
$ ./esptool.py --port /dev/tty.SLAB_USBtoUART read_mac 
MAC: 18:fe:34:9d:46:94

# copy esptool.py to the folder ESP8266-transparent-bridge-master/bin
$ cd ESP8266-transparent-bridge-master/bin

# if your USB-Serial adapter is not on /dev/ttyUSB0, use option --port <port name/path>

./esptool.py write_flash 0x00000 eagle.app.v6.flash.bin 0x40000 eagle.app.v6.irom0text.bin
Erasing flash...
Writing at 0x00008000... (100 %)
Erasing flash...
Writing at 0x00064c00... (100 %)


# remove the jumper from GPIO0 to GND, and power cycle, to go back to normal mode

/!\ The AT commands must be given only via telnet.

/!\ The initial baud rate could be 74880 baud. In my case I need 9600 baud. So, my first command is:

# In a terminal program
$ telnet
Connected to
Escape character is '^]'.
BAUD=115200 8 N 1

    type: +++AT BAUD 9600   ENTER

    type: '^]'
    type: 'q' ENTER
Connection closed.

The AT commands are case sensitive, please use always upper case:

+++AT                                    # do nothing, print OK
+++AT MODE                               # print current opmode 
+++AT MODE <mode: 1= STA, 2= AP, 3=both> # set current opmode, 1=Station, 2=Access Point
+++AT STA                                # print current ssid and password connected to
+++AT STA <ssid> <password>              # set ssid and password to connect to
+++AT AP                                 # print the current soft ap settings
+++AT AP <ssid>                          # set the AP as open with specified ssid
+++AT AP <ssid> <pw> [<authmode> [<ch>]]]# set the AP ssid and password, authmode:1= WEP,
                                         # 2= WPA,3= WPA2,4= WPA+WPA2,
                                         # channel: 1..13
+++AT BAUD                               # print current UART settings
+++AT BAUD <baud> [data [parity [stop]]] # set current UART baud rate, optional data bits = 
                                         # 5/6/7/8 , parity = N/E/O, stop bits = 1/1.5/2
+++AT PORT                               # print current incoming TCP socket port
+++AT PORT <port>                        # set current incoming TCP socket port (restarts ESP)
+++AT FLASH                              # print current flash settings
+++AT FLASH <1|0>    # 1: The changed UART settings (++AT BAUD ...) are saved 
                     # (Default after boot), 0=no save to flash.
+++AT RESET                              # software reset the unit
+++AT GPIO2 <0|1|2 100>          # 1: pull GPIO2 pin up (HIGH) 0: pull GPIO2 pin down (LOW)
                                 # 2: reset GPIO2, where 100 is optional to  
                                 # specify reset delay time in ms (default 100ms)

Upon success, all commands send back "OK" as their final output. Note that passwords may not contain spaces.

The settings are saved after the commands +++AT PORT +++AT BAUD ...

After +++AT FLASH 0 the parameter of command +++AT BAUD ... are NOT saved to the flash memory. The new settings are applied to the UART and saved only in RAM. But a following +++AT PORT need to flash the settings for the necessary reboot. Then also the changed UART setting are saved to flash.

The disable of flash of the settings is for devices with baud rate changes to avoid permanently flash of the setting sector. Some electric meter start conversion with 300 baud and accept a command to change to 9600.

A very good HowTo to this application for Quadrocopter you can find at Links #17

A promising software is esp-link from Thomas (tve), version 2.2 beta was not so reliable, but now version 2.2.3 (2016-06-22) works reliable.

There is one peculiarity. If you connect via Telnet, after 5 minutes of inactivity you get the message from the Telnet client:

Connection closed by foreign host.

This is a timeout limitation from Espressif SDK, but if you know in advance, you can send on a regular base a live trigger, to overcome this timeout.

If the program can not connect to an Access Point (AP), it will switch to AP mode on IP address and offers a web mask on port 80 in order to enter the new credentials (SSID, password).

It is the best to use a tablet for that handling. Connect to the ESP8266 hotspot named ESP_XXXXXX. The XXXXXX are the last 3 bytes (in hexadecimal) of the MAC number of your ESP8266 module. I used an Android version 4.1.1 tablet.

Be aware, that the web mask handling is very slow. Once you are used to it, and after some retries, it worked for me to set the credentials.

The programming under Mac OS 10.11.5:

$ ./esptool.py --port /dev/tty.SLAB_USBtoUART  write_flash -fs 4m -ff 40m 0x00000 boot_v1.5.bin 0x1000 user1.bin 0x7E000 blank.bin


For download of the binary archiv ESP8266_F1_1.9.19.zip (Sep. 2016) and programming of the ESP8266 see the instructions. The author is Jim Spence (jimeer).

For the WiFi credentials (SSID, password) it is possible to use a web page, but on a smartphone it is difficult to enter the data.

It is easier to enter the credentials (SSID, password) on the Serial Port of the ESP8266 module, via +++ commands.

The +++ commands are documented in a pop-up page.

/!\ Take care to start and finish every +++ command with the Enter key.

That works quit well. There is only one drawback, with the +++info command, see following:

Firmware version vF1_1.9.19
Chip ID: 9d4694 Flash ID: 1340c8 sys Flag: 30
Current Device Sockets:
remote port 0
local port 80
local IP
remote IP
Mode is 1 (STATION)
Station mode the following applies:
FRITZ-7360 <password>    ****** the passowrd in in clear text,,
Port 80

The Access Point password is printed in clear text. That should not be for security reasons. I contacted the author about it. He will change that with the next revision of the program.

The programming under Ubuntu 16.04:

$ ./esptool.py write_flash 0x00000 0x00000.bin 0x40000 0x40000.bin
esptool.py v1.0.2-dev
Running Cesanta flasher stub...
Flash params set to 0x0000
Writing 40960 @ 0x0... 40960 (100 %)
Wrote 40960 bytes at 0x0 in 3.6 seconds (92.1 kbit/s)...
Writing 172032 @ 0x40000... 172032 (100 %)
Wrote 172032 bytes at 0x40000 in 14.9 seconds (92.3 kbit/s)...

# to clear the data
$ ./esptool.py write_flash 0x7E000 blank.bin


By combining 3 pieces of existing software I made it to allow an Access Point change for the Serial Transparent Bridge just by using a Push Button switch together with a WPS functionality. The next chapter WPS explaines the setup and usage.

Please see for the details the source code WiFiTelnetToSerialWPS.c.

If you download the software, you have to rename the program extension .c to .ino for the use in the Arduino IDE. The extension .c allows pretty printing of the source code in the wiki.


WPS (WiFi Protected Setup, see Links #19) allows to connect to a new WiFi Access Point via push button switch, instead of entering the credentials manually.

For the wiring of the Push Button switch and a LED for indication see the schematic:

 *  Connection of ESP8266 GPIO0 and GPIO2 for WPS push button and LED indicator:
 *         Vcc  Vcc       Vcc = 3.3 V
 *          |    |         |
 *         4K7  4K7       1k0  pull up resistors (3K3 to 10K Ohm)
 *          |    |   +-|<|-+   LED red
 *          |    |   |
 * GPIO0  - +--------+---o |
 *               |         | -> | push button switch for WPS function
 * GPIO2  -------+-------o |
 * from http://www.forward.com.au/pfod/ESP8266/GPIOpins/index.html

If you power up the ESP8266 module, and the red LED (WPS indicator) lits (ON), it signals, that the WiFi module has lost the connection to the known Access Point, or the credentials of the Access Point had changed.

In case of changed credentials, it is possible to connect to the Access Point via WPS. The procedure is:

  1. Push the WLAN/WPS button at your Access Point, until it is signallsing the WPS mode. You have a 2 minute timeout.

  2. Push the WPS button switch at the ESP8266 module. The ESP8266 module is now trying to connect to the Access Point.

  3. If the connect was successful, the LED goes OFF.
  4. Check the WiFi connection via ping command in a terminal, or the application program, or the WiFi Access Point status web page.

Compile Firmware

Help comes from Official GCC compiler VM from Espressif. To make the compile process easier, a Virtual Machine with Lubuntu 32Bit 14.04 LTS was setup (File: ESP8266_lubuntu_20141021.ova), which can be used with Virtualbox.

# check Lubuntu version
$ lsb_release -a
Description:    Ubuntu 14.04.1 LTS

# user: esp8266, password: espressif

# change time zone with: Menu: System Tools -> Time and Date (unlock with password)
# change keyboard layout (in my case: Germany)

$ cd esp_iot_sdk_v0.9.5

# Compile the AT application (WiFi to serial)
# Copy the contents from examples/at/* to app
$ cp -R examples/at/* app/

# Test with "make"
$ make
No boot needed.
Generate eagle.flash.bin and eagle.irom0text.bin successully in folder bin.
# OK, it works

# now make specific version
$ ./gen_misc.sh
Please follow below steps(1-5) to generate specific bin(s):
STEP 1: choose boot version(0=boot_v1.1, 1=boot_v1.2+, 2=none)
enter(0/1/2, default 2):

boot mode: none

STEP 2: choose bin generate(0=eagle.flash.bin+eagle.irom0text.bin, 1=user1.bin, 2=user2.bin)
enter (0/1/2, default 0):

generate bin: eagle.flash.bin+eagle.irom0text.bin

STEP 3: choose spi speed(0=20MHz, 1=26.7MHz, 2=40MHz, 3=80MHz)
enter (0/1/2/3, default 2):
spi speed: 40 MHz

STEP 4: choose spi mode(0=QIO, 1=QOUT, 2=DIO, 3=DOUT)
enter (0/1/2/3, default 0):
spi mode: QIO

STEP 5: choose spi size(0=256KB, 1=512KB, 2=1024KB, 3=2048KB, 4=4096KB)
enter (0/1/2/3/4, default 1):
spi size: 512 KB


make[1]: Entering directory `/home/esp8266/esp_iot_sdk_v0.9.5/app/user'
No boot needed.
Generate eagle.flash.bin and eagle.irom0text.bin successully in folder bin.

LUA firmware

  1. ESP8266 Community Forum and wiki

  2. ESP8266 WiFi Module Library

  3. 2. Get ESP8266 source code

  4. ESP8266 Documents, Firmware

  5. Forum of company espressif for ESP8266

  6. ESP8266 WiFi Module Quick Start Guide

  7. electrodragon, ESP8266 wiki, ESP8266 IC pinout

  8. ESP8266 flashing LUA firmware

  9. LUA nodemcu ESP8266 firmware

  10. Wlan2Serial Modul für 5 euro (German Forum

  11. ESP-8266 transparent bridge software

  12. Forum thread: ESP8266 UART to TCP socket absolutely transparent bridge

  13. ESP8266, transparent bridge, AT command from local uart

  14. Github: esptool.py for programming ESP8266

  15. pyserial software on sourceforge

  16. ESP8266-transparent-bridge, fork with GPIO2 control

  17. MultiWii (Cleanflight) WiFi to EZ-GUI “HOW-TO” – ESP8266

  18. Tutorial_ESPEasy_Firmware_Upload, Module Flash size

  19. how-does-wi-fi-protected-setup-work

List of pages in this category:

-- RudolfReuter 2015-02-15 16:55:39

Go back to CategoryAVR or StartSeite ; KontaktEmail (ContactEmail)

rudiswiki9: WiFi2AT-ESP8266 (last edited 2016-10-18 14:44:16 by RudolfReuter)