我使用Arduino mego 2560和esp8266关注此http://iliaslamprou.mysch.gr/virtuino/esp8266_arduino_mega_connection_plan.png 并写下这段代码:
void setup() {
Serial.begin(9600);
Serial1.begin(115200);
}
void loop() {
Serial1.println("AT");
delay(1000);
Serial1.println("AT+CWMODE=1");
delay(1000);
Serial1.println("AT+CWJAP=\"SSSD\",\"PASSWORD\"");
delay(5000);
Serial1.println("AT+CIPSTART=\"TCP\",\"www.mywebsite.com\",80");
delay(1000);
Serial1.print("AT+CIPSEND=");
String postRequest ="GET /nhap.php HTTP/1.1\r\n\r\nHost:www.mywebsite.com\r\n\r\nConnection:close\r\n\r\n";
Serial1.println(postRequest.length());
delay(5000);
Serial1.println("GET /nhap.php HTTP/1.1");
Serial1.println("Host: www.mywebsite.com");
Serial1.println("Connection:close");
Serial1.println();
int check_down = 0;
String content = "";
while(Serial1.available()!=0)
{
check_down++;
content = content + String(char (Serial1.read()));
}
Serial.println(check_down);
//Serial.println(content);
Serial.println(content.substring(10,50));
delay(3000);
Serial1.println("AT+CIPCLOSE");
ShowSerialData();
delay(1000);
}
void ShowSerialData()
{
while(Serial1.available())
Serial.write(Serial1.read());
while (Serial.available())
Serial1.write(Serial.read());
}
我的网站:
<html>
<head></head>
<body>HELLO</body>
</html>
我想得到&#34; HELLO&#34;在arduino IDE的串行监视器上但是 我明白了:
AT + CIPCLOSE忙碌...
发送确定
+ IPD,156:HTTP / 1.1 200 OK SGET /nhap.php HTTP / 1.1主机:www.mywebsite.com连接:le
??? @@所以mega2560(9600)和esp8266(115200)之间有什么问题?