Work with ESP8266: Initial setup, firmware update, Wi-Fi connection, sending and receiving data on a PC
I ordered the simplest board with ESP8266 - ESP-01, it looks like this:

In the old board revision, only VCC, GND, URXD and UTXD were plugged into the connector.
The latest revision added RST, GPIO0, GPIO2, and CH_PD.
In total, there are 11 modifications of the boards, differing in the number of pins and version:
ESP-01: PCB antenna, after matching the distance to do about the open 400 meters, easy to use.
ESP-02: SMD package for submission limit, the antenna can be drawn with the IPX header casing.
ESP-03: SMD package, the built-in ceramic antenna technology, all available IO leads.
ESP-04: SMD package, customers can customize the antenna types, flexible design, all the IO leads.
ESP-05: SMD package, only leads to serial and RST pin, small external antenna.
ESP-06: bottom mount technology, leads all the IO ports, with metal shielding shell, can be had FCC CEcertification, recommended.
ESP-07: Semi-hole chip technology, all the IO leads, with metal shielding shell, can be had FCC CE certified IPX external antenna, can also be built-in ceramic antenna.
ESP-08: with the ESP-07, except that the antenna is in the form of customers can define their own.
ESP-09: Ultra-small size package, only 10 * 10 mm, four-layer board technology 1M bytes! ..
ESP-10: SMD interface, narrow-body design, 10 mm wide, suitable for light with controller.
ESP-11: SMD interface, ceramic antenna, small volume.
Pinout of the ESP-01 connector: The

purpose of the outputs of the ESP-01 board is:
VCC, GND - board power supply (+ 3.3V);
URXD, UTXD - RS232 pins are tolerant to 3.3V
RST - Hardware reset (reset)
GPIO0, GPIO2 - GPIO
pins CH_PD - Chip enable, must be connected to + 3.3V for operation.
To switch to the firmware update mode, you need to apply a low level to GPIO0 and a high level to CH_PD.
To connect the ESP-01 board to a PC, I used a USB-to-RS232 converter on the FT232R with TTL 3.3V outputs, for example, this can be used .
ESP-01 power supply needs strictly 3.3V, so I had to use a DC-DC converter, you can use this one .
With basic firmware, the ESP-01 board is controlled by AT commands, so we need a terminal program, I used CoolTerm .
There are 2 options for using the module:
1. Using the ESP-01 board in conjunction with an additional microcontroller that will control the module via UART.
2. Write your own firmware for the ESP8266 chip and use it as a self-contained device.
Naturally, the 2nd option is more profitable, especially since the potential of the ESP8266 chip is quite large.
To begin with, we will try option No. 1, that is, control the ESP-01 board through RS232.
The connection diagram is very simple:
VCC output - board power (+ 3.3V);
GND's conclusion is general;
URXD, UTXD conclusions - connect to the USB-to-RS232 converter (in 3.3V mode)
CH_PD output - connect to the board power supply (+ 3.3V);
In the terminal (CoolTerm) we set the speed of the COM port 57600. It is necessary to install this speed, because if the ESP8266 chip has old firmware (but most likely it is), then it will work only at that port speed.
Click Connect, enter the AT command, OK should be returned. If so, then the board works, you can move on.

Firmware update procedure
We enter the AT + GMR command - checking the AT and SDK versions, in response it gives 0016000902, where 0016 is the SDK version, 0901 is the AT version
Currently (06.11.2014) firmware 0018000902 is already available (SDK version - 0018, AT version - 0902)
Now you can and need to update the firmware:
1. Download the XTCOM utility from here .
2. Download the firmware ESP_8266_v0.9.2.2 AT Firmware.bin from here
3. Turn off the power to the board, connect the GPIO0 pin to a common wire, turn on the power.
4. Run XTCOM_UTIL.exe, go to Tools -> Config Device, select the COM port to which the board is connected, set the port speed to 57600, click Open, then Connect, the program should say “Connect with target OK!”, Close the settings window. Go to the API TEST menu, select (4) Flash Image Download, specify the path to the file "ESP_8266_v0.9.2.2 AT Firmware.bin", leave the address 0x00000, click DownLoad. The firmware download should start, at the end a message will be displayed.
5. Turn off the power to the board, disconnect the GPIO0 pin from the common wire, turn on the power, start the terminal (ATTENTION! Change the port speed to 9600), check the readiness of the board with the AT command and the firmware version with the AT + GMR command.
After upgrading to version 0018000902, the default speed of the COM port will change from 57600 to 9600, but this speed can now be set in the new firmware with the AT + CIOBAUD command. We look AT + CIOBAUD =? available speeds and set the command AT + CIOBAUD = 115200 speed 115200, in response should give OK. We give a command to restart: AT + RST. We change the port speed in the terminal program to 115200.
Example:
AT
OK
AT+CIOBAUD=? +CIOBAUD:(9600-921600)
OK
AT+CIOBAUD=115200 BAUD->115200
OKConfiguring Wi-Fi connection
Now let's try to connect our ESP-01 board to a Wi-Fi access point.
We execute the following commands:
1. Set the Wi-Fi mode of operation with the command:
AT + CWMODE =The following modes are available: 1 - STA, 2 - AP, 3 - BOTH
Example:
AT+CWMODE=1
OK2. We look at the list of access points with the command: AT + CWLAP Example
AT+CWLAP +CWLAP:(3,"WiFi-DOM.ru-0474",-85,"c8:d3:a3:30:17:40",8)
+CWLAP:(4,"Intersvyaz_516C",-89,"2c:ab:25:ff:51:6c",10)
+CWLAP:(4,"pletneva",-96,"f8:1a:67:67:2b:96",11)
+CWLAP:(4,"Test",-69,"64:70:02:4e:01:4e",13)
OKIn parentheses it is indicated: SECURITY, SSID, RSSI, BSSID, CHANNEL SECURITY can take the values:
0 - OPEN, 1 - WEP, 2 - WPA-PSK, 3 - WPA2-PSK, 4 - MIXED (WPA-WPA2-PSK)
3. We connect in our AP team:
AT + CWJAP = "SSID", "PASSWORD"Example:
AT+CWJAP="Test","habrahabr"
OK
Connection lasts 2-5 seconds, after which OK if successful. 3. Let's see what IP address our board received with the command: AT + CIFSR
AT+CIFSR 192.168.1.104
OKDisconnecting from the access point is done with the AT + CWQAP command. The address is received, you can move on.
The ESP-01 board can act as a Soft-AP; to enable this mode, we execute the following commands:
1. Disconnect from the access point: AT + CWQAP.
2. Change the Wi-Fi mode of operation with the command: AT + CWMODE = 2
3. Create your AP with the command:
AT + CWSAP = "SSID", "PASSWORD", CHANNEL, SECURITYExample:
AT+CWSAP="Test2","habrahabr",10,4
OK4. We try to connect to our AP from a computer. Let's see the result: 
As you can see in the picture, the speed is only 54 Mb / s and DNS server addresses bother me, I think they are clearly Chinese, you can’t put your own through AT-commands.
The AP address can be found with the command: AT + CIFSR
Example:
AT+CIFSR 192.168.4.1
OKThe list of our AP clients can be viewed with the command: AT + CWLIF Example:
AT+CWLIF 192.168.4.101,f4:ec:38:8d:05:62
OKSetting the TCP server mode
On the ESP-01 board, you can run a TCP server for receiving and sending data, or it can act as a TCP client for receiving and sending data to the server.
To start the TCP server, execute the following commands:
1. Set the transfer mode with the command
AT + CIPMODE =mode = 0 - not data mode (the server can send data to the client and can receive data from the client)
mode = 1 - data mode (the server cannot send data to the client, but can receive data from the client)
Example:
AT+CIPMODE=0
OK2. We establish the possibility of multiple connections: AT + CIPMUX =mode 0 - single connection
mode 1 - multiple connection
Can I check the connection mode with the AT + CIPMUX command?
Example:
AT+CIPMUX=1
OK
AT+CIPMUX? +CIPMUX:1
OK3. Start the server on port 8888: AT + CIPSERVER =mode 0 - to close server[, ]
mode 1 - to open server
Example:
AT+CIPSERVER=1,8888
OKNow you can connect to the ESP-01 and send-receive any data. To connect, we will use the SocketTest utility .
Run java -jar SocketTest.jar, on the Client tab, enter the address and port ESP-01, click Connect. If the connection is successful, then the Link message will appear in the terminal and the Message line and the Send button will become active in SocketTest.
You can view the list of active connections to ESP-01 using the AT + CIPSTATUS command
Example:
AT+CIPSTATUS STATUS:3
+CIPSTATUS:0,"TCP","192.168.1.100",44667,1
OKYou can close the active connection with the command AT + CIPCLOSE =or all AT + CIPCLOSE connections without parameters.
Example:
AT+CIPCLOSE=0
OK
Unlink4. We send data from ESP-01 to the PC. For the Single connection mode (+ CIPMUX = 0), sending is as follows:
AT + CIPSEND =For the mode Multiple connection (+ CIPMUX = 1), the sending goes like this:
AT + CIPSEND =After executing AT + CIPSEND, you need to enter text, completion of input and sending is done by Enter.,
Example:
AT+CIPSEND=0,16 > Ping Habrahabr SEND OK
5. Send a test message from the PC: 
A line appears in the terminal
+ IPD, 0.16: Ping HabrahabrMessage accepted.
The format of the received data is as follows:
For Single Connection mode (CIPMUX = 0):
+ IPD,For Multiple Connection mode (CIPMUX = 1)::
+ IPD,, :
Setting the TCP client
mode Now we change the roles, PC - server, ESP-01 - client, try:
1. Restart the AT + RST board
2. Set the transfer mode with the command
AT + CIPMODE =mode = 0 - not data mode (the client can send data to the server and can receive data from the server)
mode = 1 - data mode (the client cannot send data to the server, but can receive data from the server)
Example:
AT+CIPMODE=0
OK3. Set the connection mode to Multiple connection: AT + CIPMUX = 1 4. On the PC in SocketTest, start the server on port 8888
5. Run the client on ESP-01
For Single connection mode (+ CIPMUX = 0), the format is
AT + CIPSTART =For Multiple connection mode (+ CIPMUX = 1), the format is, ,
AT + CIPSTART =Possible parameter values:, ,
id = 0-4
type = TCP / UDP
addr = IP address
port = port
Example:
AT+CIPMUX=1
OK
AT+CIPSTART=0,"TCP","192.168.1.100",8888
OK
Linked6. We send data from ESP-01 to the PC. For the Single connection mode (+ CIPMUX = 0), sending is as follows:
AT + CIPSEND =For the mode Multiple connection (+ CIPMUX = 1), the sending goes like this:
AT + CIPSEND =After executing AT + CIPSEND, you need to enter text, completion of input and sending is done by Enter.,
Example:
AT+CIPSEND=0,16 > Ping Habrahabr SEND OK
Example of sending and receiving data:

Useful documentation:
Description of AT commands (In Chinese)
Specification for the ESP8266 chip (In Chinese)
Specification for the ESP8266 chip (in English)
Conclusion:
As we can see, the board successfully copes with the tasks, namely, the connection to Wi-Fi as a client, it can act as a Soft-AP, on the board you can raise a TCP server for receiving and sending data, or you can be a TCP client.
In this article, we examined working with the ESP-01 board via RS232, the PC was the control controller, you can easily connect the Arduino board or any microcontroller with UART and send and receive data via Wi-Fi network between the controllers or the PC.
In the next article (as karma allows) I will try to talk about the principles of writing my own firmware for the ESP8266 chip, thereby the ESP-01 board will be completely autonomous, it will not need an additional controller to control all parameters. We will try to connect various peripheral devices to the board.
I will be glad to answer questions, although I have not yet learned the ESP-01 board until the end.