How to make an HTTP GET request for a web service with Arduino

4

With a request via GET for a web service with Arduino , using the following URL and passing a parameter

asked by anonymous 01.12.2015 / 13:29

1 answer

3

Try to reproduce the example described here: link

However, replace the following code snippet with your reality:

  if (client.connect(server, 80)) {
    Serial.println("connected");
    //Faz uma requisição HTTP
    client.println("GET /automacao/Sensor?valor=10 HTTP/1.1");
    client.println("Host: 192.168.0.1");
    client.println("Connection: close");
    client.println();
  } else {
    //Caso não seja possível obter uma conexao
    Serial.println("connection failed");
  }

Note that an HTTP request is being mounted for the server specified in the server variable and in the HTTP header (GET), the URL for which the request is to be made. The value of the sensor is fixed as 10 (remember, just an example).

I think that this example is very simple and with it you will know if everything works for the call Web Service, in other words, it is a simpler code with the purpose of isolating other parts.

    
01.12.2015 / 15:02