ESP8266 WiFi module
ESP8266 WiFi SoC has gained enormous popularity in the nick of time. Right after hackaday introduction dedicated community forum was created despite that first batch of modules was still in shipping so virtually no one had it in hands. The key to success was its price - $5 or even less, including shipping fee. That's significantly cheaper than e.g. CC3000 module from Texas Instruments ($13.80 @ 1000 pcs for basic module that requires pretty much BGA soldering or $35 for more friendly breakout board).
ESP-01 / Wi07C V090
ESP-01 is the most common variant, with PCB antenna and 2x4 100mils header.
PCB size is 14.2 x 24.5 mm.
Funny observation: so far (October 2014) on all pictures I was able to read timestamp chip is dated to 25th week of 2014. Exception is espressif.com (manufacturer) website where chip from 15th week is pictured. I could speculate that chip made it to the market very quickly and this is the reason for perfunctory documentation.
- VCC: 1.7 (really?) - 3.6V, 3.3V typ. for ESP8266, limited to 2.7-3.6V range by Flash, up to 240mA consumed,
- RST: connected to pin 32, EXT_RSTB, active low, pull up for normal operation,
- CH_PD: connected to CHIP_EN pin, pull-up needed,
- GPIO0: pull low for updating firmware via UART, it looks like it can be left floating in normal operation,
- GPIO2: looks unused by current official firmware; modified firmware from electrodragon.com allows controlling both GPIO0 and GPIO2 with either AT commands or commands sent via TCP/UDP,
- TXD, RXD: UART, according to Teo Swee Ann reply in July 2016 they are 5V-tolerant, although prior to this it was not officially stated. Connect RXD to TXD of uC/UART converter and vice versa.
Note: there is also very similar in shape/size and component location module that has only power and UART connected (otherwise known as Wi07C V080) - you should probably avoid it. Second (and more visible since it may be difficult to see traces on the photo) difference is lack of status LEDs.
Module I've bought contains W25Q40BV Winbond serial Flash memory in SOIC8 package. It has 4Mbit capacity, so it matches exactly size of available firmware files (512kB with bin format, around half of file is filled with 0xFF, ~128kB when packed with zip). As shown by custom electrodragon.com firmware it actually consist of two images: "flash.bin" loaded at address 0 and "rom.bin" at address 0x40000.
Out of the box version I've received was 00160901 - older than first version that can be updated online (so called "cloud update"). Using XTCOM_UTIL (API Test / Flash image download) I've updated it directly with "v0.9.2.2 AT Firmware.bin". For this version UART speed has to be set to 9600bps, but than it can be changed with AT command and it stays at set after power down cycle.
With standard firmware module acts like a modem (WiFi to UART) with limited AT command set. Default communication parameters are 115200bps, 8N1 for older version and 9600bps, 8N1 for 0.9.2.2. Most commands (except for AT/at) are case-sensitive. Since v 0.92 commands have to be terminated with \r\n (CRLF) - check your terminal, for Termite 1.6 this is default setting. Here is communication snip (commands sent in bold, some newlines may be omitted, comments starting with //):
AT OK AT+RST> OK ets Jan 8 2013,rst cause:4, boot mode:(3,0) wdt reset load 0x40100000, len 25020, room 16 tail 12 chksum 0x55 ho 0 tail 12 room 4 load 0x3ffe8000, len 3280, room 12 tail 4 chksum 0x1d load 0x3ffe8cd0, len 6468, room 4 tail 0 chksum 0xe1 csum 0xe1 [System Ready, Vendor:www.ai-thinker.com] AT+GMR // check FW version 0018000902 OK AT+CIOBAUD? // check baudrate (redundant) +CIOBAUD:115200 OK AT+CWMODE=3 // working mode: AP+STA OK // second time (after power down) module returns just "no change" string, no OK reply AT+CWLAP // list available access points +CWLAP:(3,"UPC784xxx",-75,"70:54:d2:xx:xx:xx",1) +CWLAP:(0,"UPC Wi-Free",-74,"72:54:d2:xx:xx:xx",1) +CWLAP:(1,"dlinkgxxx",-70,"00:21:91:xx:xx:xx",1) +CWLAP:(0,"UPC Wi-Free",-84,"46:32:c8:xx:xx:xx",1) +CWLAP:(4,"Livebox-xxxx",-89,"68:1a:b2:xx:xx:xx",1) +CWLAP:(0,"Orange_FunSpot",-88,"6e:1a:b2:xx:xx:xx",1) +CWLAP:(4,"UPC117xxx",-86,"44:32:c8:xx:xx:xx",1) +CWLAP:(3,"xxxxxx",-57,"cc:b2:55:xx:xx:xx",3) +CWLAP:(3,"xxxxxxxxxxxxx",-90,"d8:5d:4c:xx:xx:xx",4) // ... // [lots of APs cut] // this beast lists more APs than my windows utility... // it looks like APs are sorted by channel and values are: // (security, "name", signal strength, MAC, channel) // where for security: 0 = open, 1 = WEP, 3 = WPA, 4 = WPA2 // ... +CWLAP:(4,"linksys",-55,"00:1c:10:xx:xx:xx",11) +CWLAP:(0,"FON_NETIA_FREE_INTERNET",-92,"00:12:2a:xx:xx:xx",12) +CWLAP:(1,"xxxxxx",-73,"d8:5d:4c:xx:xx:xx",13) AT+CWJAP="linksys","xxxxxxxxxxx" // connect (SSID, password) OK // IP address is obtained with DHCP // client host name is empty // client MAC address does not change after power down cycle // and seems to be unique (18:FE:34:xx:xx:xx) // after next power down cycle module connects automatically to last AP AT+CWJAP=? no this fun // LOL; it may brake your parser or state machine AT+CWJAP? +CWJAP:"linksys" OK
For a quick TCP client test I've grabbed my very old TCP server/terminal written with C++ Builder 6: BcbServer.zip. It listens on TCP 7778 port and displays received text.
AT+CIPMUX=0 // single connection mode OK AT+CIPSTART="TCP","192.168.1.11",7778 OK Linked +IPD,24:Connection established OK AT+CIPSEND=4 // 4 = length of text to send > test // > = prompt, "test" = actual text to send busy s... SEND OK AT+CIPCLOSE // disconnect OK Unlink
Source code of my web thermometer based on ATmega32 (that's overkill, but I had unused board from previous version of this thermometer with ISA eth card; ATmega8 would be sufficient after disabling few log lines, FLASH usage is just little over 8kB), ESP8266, SHT11 and MPXA6115A: thermometer.zip.
- built with WinAVR-20090313
- tested with ESP8266EX v0.9.2.2 AT Firmware.bin; quite possibly would not work with any other version
- make sure AVR and ESP8266 UART speeds are matching (use AT+CIOBAUD to preconfigure ESP8266 by connecting it via UART to PC first)
- POSTs every 5 minutes string with all measurements (temperature, relative humidity, pressure) to php script that parses it and stores into database
- connects with ESP8266 via hardware UART, 19200 bps
- uses software UART (tx direction only) with standard printf for debugging, 19200 bps
Scheme: ATmega32_ESP01.pdf. Note: not verified thoroughly (drawn after assembling device).
Kicad files: ATmega32_ESP01_Kicad.zip.
2014.11.01: added reset line control to restart module that stuck in "busy p..." state, thermometer_20141101.zip
2014.11.08: Thermometer_20141108.zip. Changed SoC mode from AP+STA (AT+CWMODE=3, access point + station) to STA only (AT+CWMODE=1). While mode 3 may seem most universal it creates possible security issues - enabling it creates by default open network (SSID: ESP_MACBYTES) with no encryption and authorization. With today's high number of WiFi-enabled devices running open network may also limit reliability and cause current consumption increase - it would be more sensible to not enabling access point mode until AT+CWSAP command with explicit encryption mode, channel, etc. is issued.
Note: for obvious reasons WiFi network SSID password and few other parameters (HTTP server IP/host, php script file name) have to be filled up in config.h and also output binary file is not included in archive.
Programming ESP8266 with GCC
VoIP/RTP pager with ESP-01