1

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.

  • 2
    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. – Majenko Mar 27 at 13:38
  • 2
    You need to terminate the GET request with proper \r\n, and the http header as well. So it should be GET /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. – hcheung Mar 27 at 15:57
  • @garrettlynch, upvote for presenting the correct way of debugging connectivity issue between the arduino and the ESP8266 – jsotola Mar 27 at 22:38
  • @hcheung thanks, I've tried it with carriage returns and new lines as instructed. I'm getting +IPD,919:HTTP/1.0 400 Bad Request - I wonder if this is something to do with the AT+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 line GET /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. – garrettlynch Mar 28 at 6:43
  • 1
    you can't send a two or more line http request from Serial Monitor. it is not possible. the \r\n are not converted to line ends. they are sent as \ and r and \ and n – Juraj Apr 2 at 9:34
0

In my experience, the "busy" message appears when you try to start a new AT command or to send data before the ESP8266 is ready. You say that you are running this test with the commands in "a script" which suggests to me that there is no significant delay between lines.

You should either wait between commands until the EXP8266 responds (usually with "OK" or ">") or add a delay of a few seconds between commands.

| improve this answer | |
  • No I said "I've stripped it [my code] down to a script that passes serial monitor queries" - the AT commands are coming from the serial monitor and the prior commands have completed before the GET request is sent. I have moved beyond this, however, and am getting Bad Request responses now. Please see the edit to my question. – garrettlynch Mar 29 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.