Simple Communication through ESP8266 Wifi module


My previous post shows how I got life from my ESP8266 here:

Once I got life and updated to latest firmware, I changed my baud rate to 9600 by giving “AT+CIOBAUD=9600”.

Connecting to my Wifi AP

  1. Set my mode to “AT+CWMODE=3” to allow for both client and server mode (at least that is what I think it is).
  2. Scan for access points with AT+CWLAP command.
  3. Join the AP by sending AT+CWJAP=”[YourNetwork]”,”[YourPassword]”
    1. I used an AP with WEP encryption and it worked for me.
    2. I used an AP with WPA encryption and it doesn’t work for me.  Need to debug later.
  4. Check that you get IP assignment from the router with AT+CIFSR
    1. I got to IP’s, and
    2. The first one ( is the IP of the AP that the ESP8266 when operating as an AP (remember I set to CWMODE=3 in step one).  Not sure how to use it yet.
    3. The second one ( is the one my Dlink AP assigned to the ESP8266.  This is the one I know how to use for now.

Here is a log capture of my TeraTerm window.


+CWLAP:(3,”Home Network”,-86,”74:44:01:93:84:78″,10)





Setting up the ESP8266 as a server on Wifi network.

Now that I have the ESP8266 connected to my Dlink Wifi router, I want to communicate through it.  I found that I can use a simple Telnet client to talk to the ESP8266 after setting up the ESP8266 as a server.

Need for CIPMUX first

I spent a long time trying to determine why I couldn’t initiate the server on the ESP8966.  Googl’ing and stumbled on that the CIPMUX mode needed to be set first.  I used AT+CIPMUX=1 for multiple connections.  (I had problems later with with sending out data with mode 0 which is single connections.)

Starting and connecting to the Server

To start the server at port 8888….  AT+CIPSERVER=1,8888.  (Remember the IP address is found above when I gave the AT+CIFSR command.)

Once the server is started, I opened a Telnet window from TeraTerm like this….


Whala… I get “Link” out of the ESP8266 serial port.

Sending strings back and forth

Typing in the telnet window and hitting carriage return will send the string through Wifi -> ESP8266 -> Serial pins on 8266 -> FTDI cable -> TeraTerm on serial port at 9600 baud.  You should get something like this….


The 0 in the above string that shows up in the serial port is the channel.  If you have multiple clients hook up to it, this is how you tell who is “talking”.  This is also how you send back strings using the AT+CIPSEND command.  For example, if you want to send back “what was that?” to the client that send the jumble above…

In your serail port window, send AT+CIPSEND=0,16

This will bring up a “>” prompt.  The ESP8266 is waiting to send 16 characters.  Now type in “what was that?” and it should magically -> FTDI cable -> ESP8266 -> Wifi ->Telenet window.

Here is a screen shot of the full exchange (click on image so you can read the text)…


I installed a simple Telnet App on my Android tablet and could do exchanges to my ESP8266 from across the house.  Yupiieeee!!!!


14 thoughts on “Simple Communication through ESP8266 Wifi module

  1. Pingback: LED’s Control through TTY | PetesTechProjects

  2. Pingback: Mini Server on Arduino + ESP8266 | PetesTechProjects

    • I haven’t tried using the ESP8266 as a Wifi repeater. The only thing I have tried is to use the ESP8266 as access point in CWMODE=3. I could directly connect my Android tablet or phone to that ESP8266 (without using a Wifi router) and send and receive data to the connected Arduino.

      If it were possible, I would think you would still need to have some code on the Arduino that would echo data from one channel to the other. Interesting idea but from my experience with the ESP8266 so far, I think there would be a lot of stability issues since I am seeing a lot of ESP8266 resets when just trying to implement a very simple web server on the Arduino.


  3. Hello Peter,

    Thank you for this post. By following your description I could easily get the same reaction as you “I installed a simple Telnet App on my Android tablet and could do exchanges to my ESP8266 from across the house. Yupiieeee!!!!”.

    With kind regards,
    Wim Dossche


  4. It all works, but can I use the telnet strings in my arduino code?
    for example I want if i send ‘x’ to the ESP8266, I want to turn a led on.
    ( does’nt work when using ESP8266)

    Please tell we how this would be possible.
    Thanks in advance.


    • Casper,

      In my later posts, I am doing a lot more complicated serial communication controls. I have a routine that does use to read 1 character at a time and builds a string until reaching the CR/LF.

      Take a look at my post “LED’s Control through TTY“. My entire Arduino code is there. I read for key words from a TTY client and turn on LED’s when specific keywords are found. That should get you a good start.

      Good Luck,


  5. Hi Peter .
    Very good post . I learn a lot from your posts.
    have some thing not understand :
    The esp8266 setup server Ip adress is or ?
    is the AP and Server ip adress here same ?



    • zq,

      The ESP8266 can connect to a Wifi router (client mode) and operate as a Wifi access point simultaneously. is the IP address if you are connecting to the ESP8266 Wifi AP. You can use a client device to join the ESP8266 Wifi AP and then communicate to it at You don’t need to have any other Wifi AP or Wifi router this way. is the IP address that the ESP8266 was given by the router that I connected to (ESP8266 acting as client). That address will change depending on the router. If you have another device connected to the same Wifi router as the ESP8266 joined, you use the address to communicate with the ESP8266.

      Hope that helps clarify.



  6. hey thanks for the post great post.
    Can I establish communication between 2 esp’s by setting mode 3.
    Also can i change ssid and password of each chip.?
    If yes then how.
    please leave a reply.


    • Ashwini,

      I don’t recall where I found the original AT command list, but here is one that came up near the top of a Google search for “ESP8266 AT Commands”…. There you will find the command to set the SSID and password by using “AT+ CWSAP”. The table in the link should give you the details to set your SSID, password and some other parameters if you would like.

      I have not tried using 2 esp’s to communicate between each other, but I don’t see a reason why that wouldn’t work as long as you set up one to be the AP and the other connects up to it as a client. I would think you would just need to

      1. Set both ESP8266’s to “AT+CWMODE=3”
      2. Set up ESP8266#1 with a unique SSID …. ie: AT+CWSAP=MyTestESPn1,Hello
      3. Send command to ESP8266#2 to join ESP8266#1’s Wifi network… ie: AT+CWJAP=MyTestESPn1,Hello

      I didn’t test it but think that should work.

      Good Luck,


      • thanks peter.
        I got it. I tried it in nodemcu firmware and it works properly.
        Hav u work with modemcu. I want to sort the string in lua.
        i need proper syntax. If you know it or if u can try it please leave a reply.

        Thank u so much again….


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s