ESP8266 Serial WIFI Module

ESP8266 Module

*Updated 1/17/2015

After trying several different WIFI options for the Arduino, I was pleased to discover this $5.00 option.

I purchased 4 of them from a local US supplier on eBay for speed of shipping. Here is the link to the seller I purchased them from... eBay. It arrived very quickly, which I'm always thankful for and they have a 100% feedback rating, which is something to be mindful of.

As you can see from the following image, there are 8 total pins available. We are only going to be using 6 of them to update the firmware and 5 of them for normal use.

During the course of getting these little guys to work, I visited many websites. All of them seem to have something to offer but none of them seemed to address all of the issues I had. I'll give it my best shot to cover them all.

First and foremost, we need to do some soldering. I had the best success by soldering the 4 middle pins in the up position and the outside 4 pins in the normal down position like the following...

This allowed the ESP8266 to be breadboard friendly and still allowed access to the other pins if needed.

Now we have to update the firmware. They seem to all come with version 00160901 (at least from my experience). As of this moment we can update them to 0018000902 (0.9.2.2) which includes a few more AT commands, stability and the ability to change the default baud rate from 9600 (after update) to anything else using AT+CIOBAUD=9600, 19200, 38400, 57600, 74880, 115200, 230400, 460800 or 921600.

In case you didn't know beforehand, you will need a USB2Serial, UartSBee or similar to update the firmware. I personally used a USB2Serial from Arduino, since I just happen to have it around to program an Arduino Mini, but that's another article.

In my case, the power coming from the USB2Serial (5 volt) wasn't proper so I simply soldered a couple AA batteries together in series to provide the 3 volts we need to power the ESP8266. If you have a good 3 volt power supply, it would be far easier than this to use it but its all I had at the time. Plug your + and - in to the breadboard power rails but leave one of the leads unplugged for now.

Next, plug your jumper wires into your breadboard as follows. It's not as complicated as it looks. Hooking up the GPIO 0 to GND will put the ESP8266 into Update Mode. Very important for updating the firmware.

Next, lets download and extract the firmware and the firmware updating tool. from the electrodragon.com website. They have a great deal of information about the ESP8266 and were the most help getting everything working for me.

*A word of caution about the firmware updating tool. On several occasions, this tool managed to blue screen my Windows 8.1 system. So before you use it, please make sure to have everything you are working on saved often.

I found that the order of which you perform the following steps tends to make a difference on your success or failure of updating the firmware. This is what worked for me.

First, plug in the PS (power supply or AA batteries) into your breadboard to power up your ESP8266. You should see a red power light almost immediately.

Next, plug your usb cord into your USB2Serial module and your computer. You should see a power led here also.

Double-click the XTCOM_UTIL.exe firmware update tool and you will see this...

Click Tools, then clicking Configure Device will give you the following window. Pick the proper COM port. I found mine (COM4) by opening my Arduino IDE interface and going up to Tools, Serial Port. But close the IDE before continuing in case it decides to take over the COM port and messing everything up.

By default the ESP8266 will use the baud rate of 115200 so leave this option alone for now. Click Open. This will open communications with the COM port and enable the bottom Connect button. Click it next. It will now attempt to talk with the ESP8266. Mine usually stopped at try 2 before making the connection. Assuming you got this far, you are doing well. If it goes all the way to 200 tries and fails, something is wrong with your setup. It could be almost anything but the wiring seems to be the most common issue. Make sure the TX on the USB2Serial is going to the RX on the ESP8266 and the RX on the USB2Serial to the TX on the ESP8266. Also verify the COM port. When all else fails, unplug the USB from your computer and the power from the PS. Plug the PS back in and then plug the USB back into your computer to reset everything.

Now that you are connected, leave this window open and move it to the side. Click API Test then Flash Image Download which will look like the following...

Browse for your bin firmware image you downloaded and leave the 0x00000 program address offset alone. Click Download. Within a few seconds you will notice it working. It will take about a minute to finish. Once its done, close the Flash Image Download window. Click the Close button on the Config Device window then exit out of it. And finally exit the XTCom utility.

You should now be using the 0018000902 (0.9.2.2) version but lets verify that.

Unplug the jumper wire from your ESP8266 that connects your CH_PD pin to GND. Unhook the PS from the breadboard for a moment and hook it back up, resetting your ESP8266 and hopefully booting up the new firmware and without it being in Update Mode anymore.

Now open up your Arduino IDE and verify that you are using the correct port that is talking to your USB2Serial module. Click the Serial Monitor button on the top right of the window and verify that your monitor is using a baud rate of 9600 and using Both NL & CR. You may have to close your serial monitor and re-open it to establish the new settings. Now you should be able to type AT into the textbox at the top and press enter. If everything is happy, the ESP8266 should reply back with OK.

Now type AT+GMR and press enter and it should respond with 0018000902. If you have got this far, you are doing great and far better than me the first time, or the 20th time. :)

 

Now lets get your Arduino hooked up and working with the ESP8288.

Something that took me a long time to wrap my head around is that your Arduino Uno (in my case) only has one TX and RX ports so you have to cheat a little by using our USB2Serial device again to monitor what is happening on our ESP8266. Lets do some wiring up. Its similar to the above wiring, but now we are going to include the Arduino Uno and use the USB2Serial for monitoring, not updating the firmware.

Once you have everything wired properly, plug both the USB2Serial and the Arduino Uno into your computer.

Copy the following sketch into your Arduino IDE and change the SSID and PASS to reflect your WIFI network.


#include <SoftwareSerial.h>
#define SSID "yourwifirouterssid"
#define PASS "yourwifirouterpassword"
#define DST_IP "97.74.215.61" //intheorystudios.com
SoftwareSerial dbgSerial(10, 11); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600); //changed to 9600 to talk to the updated ESP8266. This maybe differnet for you
Serial.setTimeout(5000);
dbgSerial.begin(9600); //can't be faster than 19200 for softserial
dbgSerial.println("ESP8266 Demo");
//test if the module is ready
Serial.println("AT"); //changed from AT+RST because it wasn't working
delay(1000);
if (Serial.find("OK")) //changed from ready to OK because AT+RST wasn't working
{
dbgSerial.println("Module is ready");
}
else
{
dbgSerial.println("Module have no response.");
while (1);
}
delay(1000);
//connect to the wifi
boolean connected = false;
for (int i = 0; i < 5; i++)
{
if (connectWiFi())
{
connected = true;
break;
}23
}
if (!connected) {
while (1);
}
delay(5000);
//print the ip addr
/*Serial.println("AT+CIFSR");
dbgSerial.println("ip address:");
while (Serial.available())
dbgSerial.write(Serial.read());*/
//set the single connection mode
Serial.println("AT+CIPMUX=0");
}
void loop()
{
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += DST_IP;
cmd += "\",80";
Serial.println(cmd);
dbgSerial.println(cmd);
if (Serial.find("Error")) return;
cmd = "GET / HTTP/1.0\r\n\r\n";
Serial.print("AT+CIPSEND=");
Serial.println(cmd.length());
if (Serial.find(">"))
{
dbgSerial.print(">");
} else
{
Serial.println("AT+CIPCLOSE");
dbgSerial.println("connect timeout");
delay(1000);
return;
}
Serial.print(cmd);
delay(2000);
//Serial.find("+IPD");
while (Serial.available())
{
char c = Serial.read();
dbgSerial.write(c);
if (c == '\r') dbgSerial.print('\n');
}
dbgSerial.println("====");
delay(1000);
}
boolean connectWiFi()
{
Serial.println("AT+CWMODE=1");
String cmd = "AT+CWJAP=\"";
cmd += SSID;
cmd += "\",\"";
cmd += PASS;
cmd += "\"";
dbgSerial.println(cmd);
Serial.println(cmd);
delay(2000);
if (Serial.find("OK"))
{
dbgSerial.println("OK, Connected to WiFi.");
return true;
} else
{
dbgSerial.println("Can not connect to the WiFi.");
return false;
}
}

*Very important, temporarily unplug the jumper wire from Pin 0 of your Arduino Uno (or similar device) before uploading your sketch or the Arduino IDE won't be able to talk to your Uno.

Next, change the port of your IDE to talk to your Arduino Uno COM port and upload the sketch. Once completed successfully, plug back in your Pin 0 jumper wire and switch your IDE to talk on the other COM port for your USB2Serial. Open the Serial Monitor, making sure of your baud rate and carriage return options.

And finally tap the reset button on your Uno. You should see some activity while the Arduino is talking to your ESP8266. It will be establishing communication with your WIFI network, going to the internet and downloading a copy of the website at the DST_IP address you have specified. If you see all of the code on the page, then you are good to go.

I hope this article helped. Thanks for reading and good luck!

 

Here are some other sites which helped me out a lot...

http://www.electrodragon.com/w/Wi07c

http://www.esp8266.com/

http://www.seeedstudio.com/blog/2014/09/11/getting-started-with-esp8266/

 

I built a more perminate way to update the firmware and check their status with this little guy...

The AMS1117 provides the proper voltage to make the ESP8266 happy but you do have to use a couple of 10uF capacitors to stabilize the voltage coming into the regulator and going out. The little jumper wire just allows me the freedom to flash the firmware while it is in and perform AT commands while it is out. It connects the ground to the GPIO 0 pin. And as always you have to use something like a USB2Serial module to connect the ESP8266 to your computer for programming.