1

Using an ESP8266 and using the following AT commands I can successfully get the webpage:

AT+CIPSTART="TCP","www.somewebsite.com",80
AT+CIPSEND=80
> GET http://www.somewebsite.com HTTP/1.0
<I get a bunch of HTML here>

So far so good. Now I have a php page on my website that takes a few parameters and updates a table in a database accordingly. So when I type:

http ://www.mywebsite.com/mypage.php?arg1=one&arg2=two

It successfully updates the table. Now when I try to use ESP8266 to do the same I get a DNS fail:

AT+CIPSTART="TCP","http://www.mywebsite.com/mypage.php?arg1=one&arg2=two",80
<get DNS fail here>

Even if I try the php page without the arguments I get DNS fail:

AT+CIPSTART="TCP","http://www.mywebsite.com/mypage.php",80
<get DNS fail here>

Does anyone know what's going on? Could it be that the php page is not on port 80? And if that's the case, how do I find out what port it's on?

By the way, if I do the same with an html page on my website it works just fine.

EDIT: When I try this:

AT+CIPSTART="TCP","www.mywebsite.com",80
> GET /mypage.php?arg1=one,arg2=two

I get this output:

Error 404 - Not Found

And when I try:

AT+CIPSTART="TCP","www.mywebsite.com",80
> GET http://www.mywebsite.com/mypage.php?arg1=one,arg2=two

I get the html code of www.mywebsite.com/index.html and not the php page.

I'm also not sure what the "HTTP/1.0" in the GET command does?

1
  • 1
    The argument is just supposed to be the domain name of the website. The rest of the URL goes after GET. Commented Mar 29, 2016 at 4:23

1 Answer 1

7

You don't put the URL on the AT+CIPSTART line, that just wants the name of the server. The rest of the URL goes after GET. Also, if your server does virtual hosting, you need to send a Host: header to tell it which server name to use.

AT+CIPSTART="TCP","www.mywebsite.com",80
> GET /mypage.php?arg1=one&arg2=two HTTP/1.1
> Host: www.mywebsite.com
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. I tried this and I get an error 404 page not found. I've added the commands I ran and the output to the original question.
I've updated the answer to include the Host: header, which is required to distinguish virtual servers.
Thanks for the great answer. It worked! I also found this command on stackoverflow (can't find the source so please post here if you do find it): <echo -en 'GET /mypage.php?arg1=one&arg2=two HTTP/1.1\r\nHost: www.mywebsite.com\r\n\r\n' | nc bluefoxnano.com 80'> to run in the terminal. This way you can send HTTP commands. I found it great for testing out the commands before programming the ESP8266.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.