I am writing a simple Arduino Ethernet program. The program sends an HTTP GET Request to the server and then the server echos "Hello World" and I should be able to receive it through the Arduino Ethernet and print it on the Serial monitor of the Arduino 1.0.4 IDE. Here are some useful information. I am using a XAMPP Server on Windows Server 2003. I have placed my PHP file in /xampp/htdocs/xampp and the file name is rec.php. The contents of rec.php is
<?php
echo "Hello World";
?>
This is the file content of the Arduino program
#include <Ethernet.h>
#include <SPI.h>
byte mac[] = {0x90, 0xA2, 0xDA, 0x00, 0x7E, 0xAE}
IPAddress server { 192, 168, 1, 223 };
IPAddress ipAddress { xxx,xxx,xxx,xxx };
IPAddress myDNS {8,8,8,8};
IPAddress myGateway{192,168,1,1};
IPAddress mySubnet{255,255,255,0};
EthernetClient client;
void setup()
{
Serial.begin(9600);
Ethernet.begin(mac, ipAddress, myDNS, myGateway, mySubnet);
delay(1000);
Serial.println("connecting");
if(client.connect(server, 80))
{
Serial.println("Connected");
client.println("GET /rec.php HTTP/1.1");
}
else
Serial.println("Not Connected");
}
void loop()
{
if(client.available())
{
char c = client.read();
Serial.println(c);
delay(1000);
}
else
{
Serial.println("Not Available");
delay(1000);
}
}
After I load the program on the Arduino I get this message on the Serial Monitor "HTTP/1.1 400 Bad Request". Any suggestion on how to solve that problem? and please keep your answers simple.