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, see ArduinoLabPSU2#WiFi_ESP-01.

ESP8266 module

Features:

Specifications:

ESP-01

attachment:ESP8266_Pinout2.png

The most common module with printed PCB antenna:

Pinout:
UTXD-OUT       GND
CH_PD          GPIO2
GPIO16         GPIO0
VCC 3.3V ONLY  URXD-IN

CH_PD: VCC - start from Flash ROM (normal operation)
GPIO0: Pulse to GND - enter update firmware mode
Connecting on an USB-Serial interface, RDX and TXD should crossed.

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

esptool.py

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
Connecting...

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.

AT+RST

OK
bB....Sbr....H.....J...H.
[Vendor:www.ai-thinker.com Version:0.9.2.4]
ready

AT+GMR

0018000902-AI03
OK
    SDK version: 18
    Firmware version: 0902

AT+GMR

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

http://www.instructables.com/id/ESP8266-Wi-fi-module-explain-and-connection/step6/Talking-to-the-ESP8266/

AT+CWMODE=1

OK

AT+CWLAP

+CWLAP:(4,"DonnerNet",-93,"84:9c:a6:34:46:44",2)
+CWLAP:(3,"FRITZ-7170R",-70,"00:1f:3f:d1:15:00",11)
+CWLAP:(3,"FRITZ-7170R",-84,"00:1f:3f:1b:87:8a",11)
OK

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

AT+CWJAP="FRITZ-7170R","password"

OK

AT+CIFSR

192.168.4.1
192.168.17.199
OK

AT+CWJAP?

+CWJAP:"FRITZ-7170R"
OK

192.168.17.199  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

You need an USB-Serial adapter for that. /!\ 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.

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 ...)
Connecting...
MAC: 18:fe:34:9d:49:43
# that looks good
or on MAC OS X
$ ./esptool.py --port /dev/tty.SLAB_USBtoUART read_mac 
Connecting...
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
Connecting...
Erasing flash...
Writing at 0x00008000... (100 %)
Erasing flash...
Writing at 0x00064c00... (100 %)

Leaving...

# 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 192.168.17.199
Trying 192.168.17.199...
Connected to 192.168.17.199.
Escape character is '^]'.
+++AT BAUD
BAUD=115200 8 N 1
OK

    type: +++AT BAUD 9600   ENTER
OK

    type: '^]'
telnet>
    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

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.
eagle.flash.bin-------->0x00000
eagle.irom0text.bin---->0x40000
!!!
# 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

start...

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.
eagle.flash.bin-------->0x00000
eagle.irom0text.bin---->0x40000
!!!

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

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-07-21 09:29:38 by RudolfReuter)