My previous post shows how I got life from my ESP8266 here: https://petestechprojects.wordpress.com/2014/11/30/esp8266-4-wifi-module-bring-up/
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
- Set my mode to “AT+CWMODE=3” to allow for both client and server mode (at least that is what I think it is).
- Scan for access points with AT+CWLAP command.
- Join the AP by sending AT+CWJAP=”[YourNetwork]”,”[YourPassword]”
- I used an AP with WEP encryption and it worked for me.
- I used an AP with WPA encryption and it doesn’t work for me. Need to debug later.
- Check that you get IP assignment from the router with AT+CIFSR
- I got to IP’s, 192.168.4.1 and 192.168.0.128.
- The first one (192.168.4.1) 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.
- The second one (192.168.0.128) 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.
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!!!!