1
Hello I am developing a code for Arduino + ethernet that triggers GET (PHP) methods, and PHP sends the received data from Arduino to Mysql.
The code in php works perfectly, the ethernet can connect to the server by port '8095' but can not trigger the GET parameters. I’m not sure if the problem is in the code, or in an area related to the network.
#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");}
}
First, don’t post your codes in image form; [pt.so] supports them in both the question and the answer, then edit your question accordingly. Second, wouldn’t it be lack of HTTP headers? Or just the line break indicating that all headers have been sent.
– Woss
I tried but unfortunately it didn’t work, Arduino can connect to webserver (Apache) but can not execute the GET parameters hosted on this server.
– Carlos Varner
Have some server return after the request?
– Woss
No, nothing happens... If the code worked PHP would send the value '2' to a table in a Mysql database, but this does not happen. .
– Carlos Varner