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");}
}