#if ARDUINO > 18 #include <SPI.h> // needed for Arduino versions later than 0018 #endif #include <Ethernet.h>
// see text for more on IP addressing
Client client(server, 80);
void setup()
{
Ethernet.begin(mac, ip); // start ethernet using the mac and IP address
Serial.begin(9600); // start the serial library:
delay(1000); // give the ethernet hardware a second to initialize
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.println("GET /search?q=arduino HTTP/1.1"); // the HTTP request
client.println();
} else {
Serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c); // echo all data received to the Serial Monitor
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;
;
}
}
It gives me output via serial:
connecting... // 30 sec delay....
connection failed
disconnecting.
I'm behind a router with this config:
router ip 192.168.0.1
subnet Mask 255.255.255.0
It is a two part deal. First, you will need to get the ip address for
utvikling.tollofsrud.no
That is your server ip. Then use this:
client.println("GET /test/test.php?string=601;650;680;9;705;650;680;9;1;0 HTTP/1.1"); // the HTTP request
Add: If you are using HTTP/1.1, you will probably need to specify a HOST in the header. If it is not your server, your web host may be using virtual domain hosting.
if (client.connect()) {
Serial.println("connected");
client.println("Host: utvikling.tollofsrud.no");
client.println("GET /test/test.php?string=601;650;680;9;705;650;680;9;1;0 HTTP/1.1"); // the HTTP request
client.println();
#if ARDUINO > 18 #include <SPI.h> // needed for Arduino versions later than 0018 #endif #include <Ethernet.h>
// see text for more on IP addressing
Client client(server, 80);
void setup()
{
Ethernet.begin(mac, ip); // start ethernet using the mac and IP address
Serial.begin(9600); // start the serial library:
delay(1000); // give the ethernet hardware a second to initialize
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.println("Host: http://tollofsrud.no");
client.println("GET /PHPFile2.php?watt=1814 HTTP/1.1"); // the HTTP request
client.println();
} else {
Serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c); // echo all data received to the Serial Monitor
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;
;
}
}
What I suggested:
client.println("Host: **utvikling.**tollofsrud.no");
What you used:
client.println("Host: **http://**tollofsrud.no");
Do not use the protocol!! No "http://".
EDIT: In my haste, I put the header info in backwards.
The Host should follow the GET.
client.println("GET /PHPFile2.php?watt=1814 HTTP/1.1"); // the HTTP request
client.println("Host: utvikling.tollofsrud.no"); // the URL of the requested site
client.println();
The Host parameter is supposedly required by HTTP/1.1. Many web hosts use virtual domain hosting, where several domains are accessed through one public IP. The Host field is used by the web server to determine which of virtual domains you want.