Getting started with the ESP8266

So I purchased a few $5 (or less) Wifi chips off of ebay, the ESP8266.  It has taken the maker world a little by storm, as it makes is super cheap to get wifi into a project.

You can use it as a standalone microprocessor, but to start I wanted just to use it as a serial communications to connect to a webpage.

Step 1:  Get the comms working

First I needed to know that my FTDI was working properly and actually communicating the serial info.  I ended up having it connected to my Mac, through the software serial of an Uno that I had programmed as a repeater, and then through the normal serial to my PC.  I could get characters fine one way (from PC to Mac) but going the other way it was garbage.  It was driving me nuts.

Then I connected the grounds of the FTDI chip and the Uno, and it worked just fine to get serial comms back and forth.  Boom!

Excited, I then disconnected the Uno software serial and connected the TX and RX from the FTDI to the ESP8266…. and it worked!

For my particular ESP8266, the settings on the serial monitor I needed were 9600 baud and both NL & CR.

Type in AT, and there it was:  OK.

Step 2: Talk to the chip

There are a number of tutorials that make it look very easy to communicate to the chip.

A great resource I found to help me through the steps and why you do certain things:  http://rancidbacon.com/files/kiwicon8/ESP8266_WiFi_Module_Quick_Start_Guide_v_1.0.4.pdf

Step 2:  Learn about the ESP

AT+RST resets the ESP.

Key here is to see the last line of the response:  ready.

My vendor is ai-thinker.com with version 0.9.2.4, and the Firmware version I have is 0018000902-AI03

AT+GMR gives the firmware version.

Step 4:  Connect to a wifi network

AT+CWMODE=3 enables the module to act as both a “Station” and an “Access Point”.

AT+CWLAP lists all the wifi networks that are available. Up came a list of the wifi networks… I had no idea there were so many.

To connect to the WIFI:  AT+CWJAP=”access_point_name”,”password”

List of AT commands:  http://wiki.iteadstudio.com/ESP8266_Serial_WIFI_Module#AT_Commands

Step 5: Connect to a website

First, enable if you can mutiplex or not.

AT+CIPMUX=1 if you want to have channels 0 to 4, or =1 if you just want one.

AT+CIPSTART=4,”TCP”,”GOOGLE.COM”,80

Have the channel number without quotes, the connection type and the domain in quotes, and then the port out of quotes.  This should respond with Linked, but sometimes is gives DNS Fail.  Not sure why.  It seems that trying it again later allows it to work.  If there is a syntax error, sometimes that is because the CIPMUX is wrong (i.e. you included the channel number when it was CIPMUX=0).

Step 6: Get a page from the website

First, prepare the ESP for a command:

AT+CIPSEND=4,18

This defines the channel and the length of the command to come.  After, the ESP should respond with a >

Enter:  GET / HTTP/1.0

Basically, this is asking to get the / directory, using the HTTP/1.0 protocol.  Make sure you have a \return and \new line on your terminal, and then feed another \return \new line after (basically, double it at the end).  If you could the above, you have 14 characters, plus 2 for the first \r\n and then another 2 for the second \r\n.

Doing this, I could get from Google.com fine (gave a pile of HTML), but when ever I tried to connect to a different page, it gave me a bad request.  I tried several times for several pages, but am now stuck.  Arg!

Leave a comment