I am trying to send a GET request from an Arduino Uno connected to an ESP8266 through SoftwareSerial. I can't get it working directly in the code so I've stripped it down to a script that passes serial monitor queries like so:
#include <SoftwareSerial.h>
const byte rxPin = 2;
const byte txPin = 3;
// We'll use a software serial interface to connect to ESP8266
SoftwareSerial esp8266 (rxPin, txPin);
void setup()
{
Serial.begin(115200);
esp8266.begin(115200);
delay(1000);
}
void loop()
{
if (esp8266.available()) Serial.write(esp8266.read());
if (Serial.available()) esp8266.write(Serial.read());
}
I setup and connect the ESP8266 to my router like so from the serial monitor:
AT+RST
AT+CWMODE=3
AT+CWJAP="rwifi name","wifi password"
AT+CIFSR
AT+CIPMUX=0
AT+CIPSTART="TCP","www.abcdefg.com",80
AT+CIPSEND=61
GET /in-progress/ab/i.php?c=20 HTTP/1.0 Host: www.abcdefg.com
Everything works fine up until the CIPSEND, the GET request part, and the serial monitor output the following:
AT+CIPSEND=61
OK
> i.php?c=20 HTTP/1.0
busy s...
Recv 61 bytes
SEND OK
I know there is a 64 byte limit for the serial monitor. my GET is 61 bytes. I'm getting bytes back but not the content from the page (it should be the word "yes") and not even a content from a 404 page. Web side my php page is a counter that adds 1 to a number in a txt file - it doesn't increment (it does work if I call it from the web browser).
Where I am going wrong here with my CIPSEND? It looks like it is correctly formed to me.
-----edit-----
Based on comments below this is the latest GET request I have tried:
AT+CIPSEND=73
GET /i.php HTTP/1.1\r\nHost: www.abcdefg.com\r\nConnection: close\r\n\r\n
I have shortened my pathway to the php file as much as possible, added the carriage returns and newlines between request and each header, added the double carriage return and newline at the end. The request now returns +IPD,919:HTTP/1.1 400 Bad Request
. This error 400 is not logged on my website.
GET /in-progress/ab/i.php?c=20 HTTP/1.0 Host: www.abcdefg.com
is not a valid GER request. Headers go on separate lines separated by \r\n.\r\n
, and the http header as well. So it should beGET /in-progress/ab/i.php?c=20 HTTP/1.0\r\nHost: www.abcdefg.com\r\nConnection: close\r\n\r\n
. I have an example on my github you might want to take a look.+IPD,919:HTTP/1.0 400 Bad Request
- I wonder if this is something to do with theAT+CIPSEND=bytecount
I'm sending. I'm unclear as to what the count is of. The documentation states it's the "length of the data that will be sent". Does that mean just the pathway sent (i.e./in-progress/ab/i.php?c=20
) or does it include everything else in the lineGET /in-progress/ab/i.php?c=20 HTTP/1.0\r\n
? I've dug through your libraries code and as far as I can tell you are counting the whole line.