1

Im trying to get temperature from website from my ESP controller. i used the same requests using IE and Fiddler they are working very fine. im doing nothing wrong also from ESP point of view.

please find my esp request and response below.

AT+CIPSTART="TCP","http://myesp8266.comlu.com",80\r\n

CONNECT

OK

AT+CIPSEND=93\r\n

OK

>

GET http://myesp8266.comlu.com/temp_post.php?temps=15 HTTP/1.0\r\n

Host: myesp8266.comlu.com\r\n\r\n`

Recv 93 bytes

SEND OK

+IPD,574:HTTP/1.1 302 Found Date: Tue, 09 May 2017 02:20:31 GMT Server: Apache Location: https://www.000webhost.com/migrate? utm_source=000&utm_medium=rdr&utm_campaign=old_panel_off&static=true Content-Length: 299 Connection: close Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>302 Found</title> </head><body> <h1>Found</h1> <p>The document has moved <a href="https://www.000webhost.com/migrate? utm_source=000&amp;utm_medium=rdr&amp;utm_campaign=old_panel_off&amp;static=true">here</a>.</p> </body></html> CLOSED

when i use IE i receive the following for the request

http://myesp8266.comlu.com/temp_post.php?temps=15

response -> Notice: Undefined index: temperature in /storage/h9/116/1546116/public_html/temp_post.php on line 2 15 Temperature : Celcius

15 is what i expect and im receiving it good...

Below is the code from fiddler which im receiving good

send ->

GET http://myesp8266.comlu.com/temp_post.php?temps=15 HTTP/1.0 Host: myesp8266.comlu.com

response ->

HTTP/1.1 200 OK Date: Tue, 09 May 2017 02:08:40 GMT Content-Type: text/html; charset=UTF-8 Connection: close Server: awex X-Xss-Protection: 1; mode=block X-Content-Type-Options: nosniff X-Request-ID: ce6759371cbb05088c5c954aa35de737

<br /> <b>Notice</b>: Undefined index: temperature in <b>/storage/h9/116/1546116/public_html/temp_post.php</b> on line <b>2</b><br /> 15<p>Temperature : Celcius </p>

where is wrong?? tried in many possible ways. but no success with only ESP8266 remaining ways working good.

please help.

thank you

1 Answer 1

1

Your first AT command establishes a TCP connection, but includes http:// which it probably shouldn't as at this point it's not yet relevant (we're just opening a socket)

Incorrect AT command:

AT+CIPSTART="TCP","http://myesp8266.comlu.com",80\r\n

Corrected AT command:

AT+CIPSTART="TCP","myesp8266.comlu.com",80\r\n

The next problem is your get request

The host name should only be specified probably on the Host header also protocol isn't required on this line also the GET requests URL should be relative to the host I believe.

Your request:

GET http://myesp8266.comlu.com/temp_post.php?temps=15 HTTP/1.0\r\n Host: myesp8266.comlu.com\r\n\r\n

Corrected request:

GET /temp_post.php?temps=15 HTTP/1.0\r\n Host: myesp8266.comlu.com\r\n\r\n

Besides these 2 changes guessing that's a send length after AT+CIPSEND so may need to update that too it may even be possible to omit the length entirely.

Finally you've got a minor issue in temp_post.php which is throwing a notice you can fix this by either altering the error reporting levels or if you post some code I'll have a look :). Alternatively if you want a cheap and nasty fix prefix whatever variable is causing it with an @ ie @$myTemps['temperature'] (although definitely better to fix the issue)

Sign up to request clarification or add additional context in comments.

Comments

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.