WiFiClient Not Working As Expected, Lots of Serial Rubbish
Posted: Mon Apr 13, 2015 5:54 am
I am using a copy of WiFiClient example to get data from a web page but I have three problems:
* There are lots of unwanted serial data output even if I haven't programmed them to display (only the last three should be displayed):
* The data sometimes comes (with extra data like 19 and 0 that is not sent by the webpage php) and sometimes there is no data (trying to pull data in 30 seconds delays) coming:
* After some time it's even get worse and can't even connect:
The modified code used:
Anybody with the same problems or have a solution?
* There are lots of unwanted serial data output even if I haven't programmed them to display (only the last three should be displayed):
.scandone
.add 0
aid 7
pm open phy_2,type:2 0 0
cnt
connected with GMRK, channel 6
dhcp client start...
.ip:192.168.2.53,mask:255.255.255.0,gw:192.168.2.1
.
WiFi Connected
IP address: 192.168.2.53
* The data sometimes comes (with extra data like 19 and 0 that is not sent by the webpage php) and sometimes there is no data (trying to pull data in 30 seconds delays) coming:
Connecting To turay.ddns.net
Requesting URL: /data.php
HTTP/1.1 200 OK
Date: Mon, 13 Apr 2015 10:37:03 GMT
Server: Apache/2.4.10 (Ubuntu)
Accept-Ranges: bytes
X-Powered-By: PHP/5.5.12-2ubuntu4.3
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html
19
Incoming Data From Server
0
Connection Closed
Connecting To turay.ddns.net
Requesting URL: /data.php
Connection Closed
Connecting To turay.ddns.net
Requesting URL: /data.php
Connection Closed
Connecting To turay.ddns.net
Requesting URL: /data.php
HTTP/1.1 200 OK
Date: Mon, 13 Apr 2015 10:39:39 GMT
Server: Apache/2.4.10 (Ubuntu)
Accept-Ranges: bytes
X-Powered-By: PHP/5.5.12-2ubuntu4.3
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html
19
Incoming Data From Server
0
Connection Closed
* After some time it's even get worse and can't even connect:
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
Connecting To turay.ddns.net
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
Connection Failed
Connecting To turay.ddns.net
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
Connection Failed
Connecting To turay.ddns.net
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
The modified code used:
Code: Select all
#include <ESP8266WiFi.h>
const char* SSID = "GMRK";
const char* PASS = "PASS";
const char* HOST = "turay.ddns.net";
const char* URL = "/data.php";
void setup()
{
Serial.begin(115200);
delay(10);
Serial.println("");
Serial.println("");
Serial.print("Connecting To ");
Serial.println(SSID);
WiFi.begin(SSID, PASS);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi Connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
void loop()
{
Serial.print("Connecting To ");
Serial.println(HOST);
WiFiClient Client;
if (!Client.connect(HOST, 80))
{
Serial.println("Connection Failed");
return;
}
Serial.print("Requesting URL: ");
Serial.println(URL);
Client.print(String("GET ") + URL + " HTTP/1.1\r\n" + "Host: " + HOST + "\r\n" + "Connection: close\r\n\r\n");
delay(10);
while(Client.available())
{
String Line = Client.readStringUntil('\r');
Serial.print(Line);
}
Serial.println();
Serial.println("Connection Closed");
Serial.println();
Serial.println();
delay(30000);
}
Anybody with the same problems or have a solution?