Sunteți pe pagina 1din 6

WiFi Serial Transceiver Module - Wiki

http://www.seeedstudio.com/wiki/WiFi_Serial_Transceiver_...

WiFi Serial Transceiver Module


From Wiki

Contents
1 Tutorial for ESP8266 Serial WiFi Module
1.1 Step-By-Step
2 Related Projects
2.1 WiFi Scanner -Know the WiFi Signal around you
2.2 Primary IoT Make with NodeMcu ->ESP8266<3 Share Your Awesome Projects with Us
4 Share Your Feedback on Seeed Wiki

Tutorial for ESP8266 Serial WiFi Module


In this tutorial, we'll use a seeeduino to control the ESP8266 WiFi module to request a
static page from the internet. This is a basic use of TCP socket, for other usage, please
refer to the AT command guide of the module.
Material list:

Seeeduino V3 (http://www.seeedstudio.com/depot/Seeeduino-V30-Atmega-328P-p-669.html) / Arduino Uno


ESP8266 Serial WiFi module (http://www.seeedstudio.com/depot/WiFi-Serial-Transceiver-Module-w-ESP8266-p-1994.h
UartSBee v4 (http://www.seeedstudio.com/depot/UartSBee-V4-p-688.html) / other USB to TTL converter

Note We used a software serial to print some debugging information as theres only one
hardware serial on seeeduino board. But the limitation of software serial is that it cant
communicate in a higher baud rate than 19200. So part of the output from ESP module will
be dropped because the baud rate 57600 of ESP module is higher than that of the software
serial. If you have a board with more than one hardware serial (e.g. Arduino Mega 2560),
the case will be easier.

Step-By-Step
Step 1: connect module as the following picture

TOP

1 of 6

11/15/15, 7:59 AM

WiFi Serial Transceiver Module - Wiki

http://www.seeedstudio.com/wiki/WiFi_Serial_Transceiver_...

Step 2: Programe the seeeduino board.


1. Open Arduino IDE and create a new sketch;
2. Parse the following code into the sketch editor (need modifying the SSID and PASS
macros into your own situation);
#include <SoftwareSerial.h>
#define SSID "xxxxxxxx"
#define PASS "xxxxxxxx"
#define DST_IP "220.181.111.85" //baidu.com
SoftwareSerial dbgSerial(10, 11); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(57600);
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+RST");
delay(1000);
if(Serial.find("ready"))
{
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; TOP

2 of 6

11/15/15, 7:59 AM

WiFi Serial Transceiver Module - Wiki

http://www.seeedstudio.com/wiki/WiFi_Serial_Transceiver_...

}
}
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;
}
}

Step 3: Open Serial Monitor and press the reset button of seeeduino board, youll see the
output.
At last, Happy Hakcing! :)
TOP

3 of 6

11/15/15, 7:59 AM

WiFi Serial Transceiver Module - Wiki

http://www.seeedstudio.com/wiki/WiFi_Serial_Transceiver_...

Related Projects
Recipe Community (http://www.seeedstudio.com/recipe/) is an awesome place where
makers share their amazing works here. Our makers have made a lot of awesome projects
with esp8266, check this out!

WiFi Scanner -Know the WiFi Signal around you

Build your own Wifi Scanner with few simple steps, all you need to do is prepare:
A NodeMcu Dev. Board
An I2C OLED.
Some cables
And most importantly, a HOT HEART ON ESP8266
So, why not make one for yourself? (http://www.seeedstudio.com/recipe/219-wifi-scannerknow-the-wifi-signal-around-you.html)

Primary IoT Make


TOP with NodeMcu ->ESP8266<-

4 of 6

11/15/15, 7:59 AM

WiFi Serial Transceiver Module - Wiki

http://www.seeedstudio.com/wiki/WiFi_Serial_Transceiver_...

An online Temperature&Humidity Monitor made with:


A NodeMcu Dev. Board
Grove - Temp&Humi Sensor
Some cables
Another easy trick, why not make one for yourself? (http://www.seeedstudio.com/recipe
/232-primary-iot-make-with-nodemcu-gt-esp8266-lt.html)

Na, not enough? More Awesome Projects with ESP8266 (http://www.seeedstudio.com


/recipe/index.php?m=Home&controller=Recipe&action=productDetail&id=6) .
Even more Awesome Projects On Recipe (http://www.seeedstudio.com/recipe/) .

Share Your Awesome Projects with Us


Born with the spirit of making and sharing, that is what we believe makes a maker.
And only because of this , the open source community can be as prosperous as it is today.
It does not matter what you are and what you have made, hacker, maker, artist and
engineers,
as long as you start sharing your works with others, you are being part of the open source
community and you are making your contributions.
Now share you awesome projects with us on Recipe (http://www.seeedstudio.com/recipe/) ,
and win a chance to become the Core User of Seeed.
TOP
Core Users, are those who show high interests and significant contributions in Seeed
5 of 6

11/15/15, 7:59 AM

WiFi Serial Transceiver Module - Wiki

http://www.seeedstudio.com/wiki/WiFi_Serial_Transceiver_...

products.
We cooperate with our Core Users in the development of our new product, which in
another word, the Core Users will have the chance to experience any new products of
Seeed before its official launch, and in return we expect valuable feedback from them
to help us improving the product performance and user experience.
Also, join the Core User Group, engage with other Core Users of Seeed and make
friends with like-minded people, could be a wonder experience for you.
And most importantly, in most of cases, if our Core Users have any good ideas
about making somethings new, something creative, as long as they provide us a
proposal of it, we'll offer hardware pieces, PCBA/CNC/3D Printing services, as well as
technical support, to help them achieve their projects.
Get more information about Core User please email to: recipe@seeed.cc

Share Your Feedback on Seeed Wiki


Now, to enhance user experience and improve learning platform, exciting task of waiting for
you. Seeed Wiki team are collecting feedback on our Wiki pages to perfect it. Please join
us.
Just tell me your suggestion, or complaints, even feelings via email:
ruiyun.liu@seeed.cc (mailto:ruiyun.liu@seeed.cc)
Retrieved from "http://www.seeedstudio.com
/wiki/index.php?title=WiFi_Serial_Transceiver_Module&oldid=106214"
This page was last modified on 25 June 2015, at 08:22.
This page has been accessed 105,121 times.

TOP

6 of 6

11/15/15, 7:59 AM

S-ar putea să vă placă și