Arduino Ethernet Shield and PHP

1

Hello I am developing a code for arduino + ethernet that triggers GET (PHP) methods, and PHP sends the data received from arduino to MySQL.

The code in php works fine, ethernet can connect to the server through port '8095' but can not trigger the GET parameters. I'm not sure if the problem is in the code, or in a network related area.

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
byte ip[] = {192,168,1,60};                         //IP DO ARDUINO (WEB CLIENT)
byte servidor[] = {192,168,1,8};                   //IP DO SERVIDOR 

EthernetClient cliente;

void setup() {   
            Serial.begin(9600);  
            Ethernet.begin(mac, ip);
         }

void loop() {

 if (cliente.connect(servidor, 8095))  //Se o arduino se conectar ao servidor
{
     cliente.print("GET /programas/Query.php?a=2"); //Envia  $_GET['a'] = 2;
     cliente.print(" HTTP/1.1");
     cliente.stop();
     Serial.println("Informação enviada com sucesso!"); 
} 
else {Serial.println("Falha na conexão");}
}
    
asked by anonymous 13.08.2017 / 05:02

1 answer

1

I found the answer to this problem in stackoverflow (English) the problem was in the HTTP1.1 framework

Below is the correct structure.

"GET /programas/Query.php?a=2\r\nHost: 192.168.1.8\r\n\r\n"
    
14.08.2017 / 17:22