i write a code for Arduino + SIM800 for connecting to server. but it don't work!

delay( 1000 );
SerialGsm.print( "GET http://sasasas.ir.ir/hadi/signal.php?value=10" );
delay( 10000 );

all thing is true but "GET" can not retrun "OK". it is arduino response:



Call Ready

SMS Ready AT+CSTT="mtnirancell"


OK AT+CIFSR AT+CIPSTART="TCP","sasasas.ir",80



GET http://sasasas.ir/hadi/signal.php?value=10

"get" dont have response.what is wrong in this code?

  • Learn the proper format of a GET request.
    – Majenko
    Jun 25 '19 at 22:14

Firstly you only have half of the first line of a GET request. Secondly the half you do have is badly formatted.

A GET request does NOT look like this:

GET http://jalambadani.ir/hadi/signal.php?value=10

A GET request DOES look like this:

GET /hadi/signal.php?value=10 HTTP/1.1
Host: jalambadani.ir
Connection: close
[extra blank line]

If you don't send the correct data you can't expect to get any response back. You should learn the basics of what you are trying to do instead of just throwing random text a a web server.

Here is a full transcript of a GET request to your URL:

$ telnet jalambadani.ir 80
Connected to jalambadani.ir.
Escape character is '^]'.
GET /hadi/signal.php?value=10 HTTP/1.1
Host: jalambadani.ir
Connection: close

HTTP/1.1 200 OK
Date: Tue, 25 Jun 2019 22:47:07 GMT
Server: Apache/2
X-Powered-By: PHP/5.6.35
Upgrade: h2,h2c
Connection: Upgrade, close
Vary: User-Agent
Content-Length: 31
Content-Type: text/html; charset=UTF-8

New record created successfullyConnection closed by foreign host.

In code that would be:

delay(1000); // I hate that. Look for a proper OK instead.
SerialGsm.print("GET /hadi/signal.php?value=15 HTTP/1.1\r\n");
SerialGsm.print("Host: jalambadani.ir\r\n");
SerialGsm.print("Connection: close\r\n");
  • thank you for your answer. i am electrical student and i don,t know about http...but i will try learn it. i test your answer but it don,t work yet:| "GET" don,t answer to me.@Majenko Jun 25 '19 at 22:42
  • PHP has nothing to do with it. You are talking in HTTP.
    – Majenko
    Jun 25 '19 at 22:44
  • Did you try majenko's suggestion - which looks like it does work - running against your server - using telnet?? Once you see how that works translate that to your arduinon code. Don't reach for the final solution in the first attempt if it is too far away. Take it one step at a time. Copy majenko's telnet example -> learn the protocol. Then transfer the protocol to your app.
    – GMc
    Jun 25 '19 at 22:54
  • yes i use of majenko's suggestion. SerialGsm.print("AT+CIPSEND=50\r\n"); delay( 3000 ); receive_message(); SerialGsm.print( "GET /hadi/signal.php?value=15 HTTP/1.1" ); delay( 3000 ); receive_message(); not work. Jun 25 '19 at 23:05
  • 1
    Depending on the system println could end with \n, \r or \r\n. Better to be explicit here. Jun 26 '19 at 6:40

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.