Sending bits to 000host via HTTP GET

hello people :slight_smile: !
i’m working on controling my Arduino Galileo via server.
My goal is to communicate between Android App and my Arduino via a server.
I succede to connect to my server , and i’m trying send Get requests and resecive an answer from it.

/*
check for connection

*/
#include <Ethernet.h>
#include <SPI.h>
char r;
int led = 13;
//-------------
byte mac[] = { 0x98, 0x4F, 0xEE, 0x00, 0x2A, 0xC7 };
 EthernetClient googleClient;
//char* ser = "http://www.eeproject.site50.net";
void setup()
{
 pinMode(led,OUTPUT);

 system("/etc/init.d/networking restart"); 

// Ethernet.begin(mac, ip);
 Serial.begin(9600);

 delay(2000);

 Serial.println("connecting...");

 if (googleClient.connect("www.eeproject.site50.net", 80)) {
   Serial.println("connected");
    digitalWrite(led, HIGH);
    // Make HTTP request 

googleClient.println("GET /hello.php?val=7 HTTP/1.0");    
googleClient.println("HOST: www.eeproject.site50.net");
googleClient.println();

   //Serial.println("Sent the http request");
 } 
 else {
   Serial.println("connection failed");
    digitalWrite(led, LOW);
 }
}
  void con(){
   if (googleClient.available()) {
   char c = googleClient.read();
   Serial.print(c);
 }

 if (!googleClient.connected()) {
   Serial.println();
   Serial.println("disconnecting.");
   googleClient.stop();
   for(;;)
     ;
 }
 }
void loop()
{
   con();
 }

/---------------------------
this is what i recive :connecting…
connected
HTTP/1.1 200 OK
Date: Mon, 06 Apr 2015 21:30:00 GMT
Server: Apache
X-Powered-By: PHP/5.2.17
Content-Length: 164
Connection: close
Content-Type: text/html

7it works!

/- ---------------------------------------------------------------

but when i try menualy send GET requests via serial monitor i get this:

the code:

/*
check for connection

*/
#include <Ethernet.h>
#include <SPI.h>
char r;
int led = 13;
//-------------
byte mac[] = { 0x98, 0x4F, 0xEE, 0x00, 0x2A, 0xC7 };
 EthernetClient googleClient;
//char* ser = "http://www.eeproject.site50.net";
void setup()
{
 pinMode(led,OUTPUT);

 system("/etc/init.d/networking restart"); 

// Ethernet.begin(mac, ip);
 Serial.begin(9600);

 delay(2000);

 Serial.println("connecting...");

 if (googleClient.connect("www.eeproject.site50.net", 80)) {
   Serial.println("connected");
    digitalWrite(led, HIGH);
    // Make HTTP request 

googleClient.println("GET /hello.php HTTP/1.0");    
googleClient.println("HOST: www.eeproject.site50.net");
googleClient.println();

   //Serial.println("Sent the http request");
 } 
 else {
   Serial.println("connection failed");
    digitalWrite(led, LOW);
 }
}
 void send(int a){
 googleClient.println("GET /hello.php?val=a HTTP/1.0");    
googleClient.println("HOST: www.eeproject.site50.net");
googleClient.println();
 Serial.print("Sent the http request with  ");
 Serial.println(a);
 }
 void con(){
   if (googleClient.available()) {
   char c = googleClient.read();
   Serial.print(c);
 }

 if (!googleClient.connected()) {
   Serial.println();
   Serial.println("disconnecting.");
   googleClient.stop();
   for(;;)
     ;
 }
 }
void loop()
{
 con();
 if(Serial.available() > 0){
   r=Serial.read();
  send(r);
 delay(1000);
  con();
 }
}

i enter the numbet 7 so i can send GET and recive an answer and i get this:

connecting…
connected
HTTP/1.1 200 OK
Date: Mon, 06 Apr 2015 21:35:45 GMT
Server: Apache
X-Powered-By: PHP/5.2.17
Content-Length: 163
Connection: close
Content-Type: text/html

it works!

Sent the http request with 7
Sent the http request with

Sent the http request with

/-----------------------------------------------------------------------------------
there is a way to send GET requests after the first connection,so i dont to connect and disconnect to the server?
or sending GET requests via serial monitor is wrong?

/---------------------- php code

<?php
 
echo $_GET["val"];
echo "it works!";
 
?>

many tanks :slight_smile:

This sounds like a cool project, and I hope you get it working.

While the following wouldn't do ALL that could be done the way you are trying to do things, is there anything that you WANT to do that it can't?....

In "outside world", an Android with an ordinary browser. Just enough to read this page, say. In "outside world", an actual user, with Android in hand, able to be "in charge" of when Arduino should do whatever GET makes it do.

An Arduino set up as a webserver on a LAN connected to a router connected to "the internet". (You don't need a static "outside world" IP address.)


If that would do all you want, then the stuff you can access from pages connected to Arduserver.com will give it to you.


If you want the "extra stuff" between Android and Arduino for, say, logging messages sent to Arduino, I suspect it can be done. Break your problem down into modules which can be built separately (and later merged into the final result), and repost a question about one of them.