In the previous post we’ve seen how to initiate ESP module & use AT commands.In this post TCP CLIENT mode operation is explained.
ESP8266 WIFI module has 3 modes of operation.
ST  – Station mode in which ESP acts as a device & connects to an existing Access point.
AP – Access Point mode where the ESP itself acts as AP & other devices like Mobile can connect to it.
Both – ST & AP both mode is allowed in ESP.The mode of operation is set by the AT command
AT+CWMODE = 1 for ST mode , 2 for AP mode & 3 for both.
As we’re testing ESP on STation mode , issue the command
AT+CWMODE=1
Image 7
To communicate with a webpage , we need to start a server with ESP module.You need to set multiple connections using command
AT+CIPMUX=1
This initiates the server for a Webserver.
Next we start the server at HTTP port 80 using command ,
AT+CIPSERVER=1,80
Image 8
To close the server the command is AT+CIPSERVER=0 followed by a Reset AT+RST
To get the STATION IP address ,
AT+CIFSR
The module returns the Station IP address , 192.168.1.3 .
If the CWMODE is set to 3 , you’ll get 2 IP address , one for AP & another for Station mode.We need the station IP address for Client mode operation.
Open your web browser & type in the address 192.168.1.3
The browser sends a HTTP GET request which is displayed on the putty window where ESP module is connected.The host IP address & the user agent (your web browser name) are displayed.
After you get OK  type in the command
AT+CIPSEND=0,30
This command is to send 30 characters through channel 0 .Use the channel number which is displayed as CONNECT while a request is received from the browser.
Image10
Now you get a  >  symbol , after which you’ve to type in 30 characters.
The module will wait till you type in 30 characters & finally displays SEND OK.
You’ve to type characters within the Timeout limit.Otherwise the link will be closed.
Image11
Now the characters are sent to the Web browser.
But the browser is still waiting for the channel to be closed.
Type in AT+CIPCLOSE=0
Here use the channel number ( 0) where the connection was established .
Image12
Once the channel is closed , you get the characters displayed on the browser.
HTML tags can be used to send characters
AT+CIPSEND=0,30
>

HELLO WORLD !!!!!

The above one displays characters using HTML tag type Heading 1.
Image 121
To close the server the command is AT+CIPSERVER=0 followed by a Reset AT+RST
For testing 2 way communication , open another instance of PUTTY .
Select connection type as TELNET & Port 80.
Type in the host address , which you get by AT+CIFSR command in ESP window.
Click on open.
Image 122
Type some characters inside TELNET window .You get these inside ESP window
+IPD,0,17:HELLO….
0 is the channel of communication & 17 is the number of characters received.
Image123
From within ESP window type AT+CIPSEND=0,20
ESP will wait till you type 20 characters.
On TELNET window the characters are received.
Image124
Watch this support video :
ESP WIFI Modules available at :