ESP8266 with Arduino as a Web Client - Unable to read page
Posted: Tue Sep 20, 2016 9:16 am
I am trying to read a short text page of csv data from a web page using an ESP-01 and an Arduino.
I am not trying any libraries, I have been unable to make them work.
Is it true that the ESP-01 will not work as a web client?
I am using version 1.3.0.0 SDK 2.0.0 of the firmware.
The device connects fine to my network, and opens the connection OK, but I cannot get the data from the page.
Here is the relevent code:
and here is the output:
What am I doing wrong? I should have +IPD,some_number:data I think.
Many thanks
I am not trying any libraries, I have been unable to make them work.
Is it true that the ESP-01 will not work as a web client?
I am using version 1.3.0.0 SDK 2.0.0 of the firmware.
The device connects fine to my network, and opens the connection OK, but I cannot get the data from the page.
Here is the relevent code:
Code: Select all
void getData() {
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += DST_IP;
cmd += "\",80\r\n";
Serial.println(cmd);
dbgSerial.println(cmd);
delay(2000);
if (Serial.find("Error")) return;
cmd = "GET /cr200Data.txt HTTP/1.1\r\n";
cmd = cmd + "Host: xx.xx.xx.xx\r\n\r\n";
Serial.print("AT+CIPSEND=");
Serial.println(cmd.length());
Serial.write('\r\n'); // Append return to commands.
delay(2000);
//while (Serial.available()) {
// dbgSerial.write(Serial.read());
//}
if (Serial.find(">"))
{
dbgSerial.print(">");
Serial.println(cmd);
dbgSerial.println(cmd);
delay(5000);
if (Serial.find("+IPD")) {
dbgSerial.println("+IPD found");
}
while (Serial.available())
{
char c = Serial.read();
dbgSerial.write(c);
if (c == '\r') dbgSerial.print('\n');
}
dbgSerial.println("====");
delay(1000);
} else {
dbgSerial.write(Serial.read());
dbgSerial.println("connect timeout");
delay(2000);
}
Serial.println("AT+CIPCLOSE\r\n");
dbgSerial.println("End of getData");
}
and here is the output:
Code: Select all
AT+CIPSTART="TCP","xx.xx.xx.xx",80
>GET /cr200Data.txt HTTP/1.1
Host: xx.xx.xx.xx
====
End of getData
What am I doing wrong? I should have +IPD,some_number:data I think.
Many thanks