Hi,
I'm using the arduino with an ethernet shield (W5100). This worked fine on my regular internetconnection.
Now, I would like to use this with a satelite internet connection. This doesn't seem to work.
The difference with my regular connection is that the ping of this connection is very high (750ms).
I think the internetconnection itself works, beceause I get an IP, mac, ...
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,128);
EthernetClient client;
void setup() {
Serial.begin(9600);
Ethernet.begin(mac, ip);
Serial.print("IP Address : ");
Serial.println(Ethernet.localIP());
Serial.print("Subnet Mask : ");
Serial.println(Ethernet.subnetMask());
Serial.print("Default Gateway IP: ");
Serial.println(Ethernet.gatewayIP());
Serial.print("DNS Server IP : ");
Serial.println(Ethernet.dnsServerIP());
}
void loop() {
String temperatuurbinnen = connectAndRead("GET http://google.be/ HTTP/1.0");
if (!is_connected || temperatuurbinnen == 0) {
temperatuurbinnen = dht.readTemperature();
}
String connectAndRead(String value){
is_connected = false;
Serial.println("connecting...");
delay(2000);
if (client.connect("www.google.be", 80)) {
is_connected = true;
Serial.println("connected");
delay(500);
// Make a HTTP request:
client.println(value);
client.println();
return readPage(); //go and read the output
}
else{
return "connection failed";
}
}
String readPage(){
//read the page, and capture & return everything between '<' and '>'
stringPos = 0;
memset( &inString, 0, 32 ); //clear inString memory
while(true){
if (client.available()) {
char c = client.read();
if (c == '<' ) { //'<' is our begining character
startRead = true; //Ready to start reading the part
}else if(startRead){
if(c != '>'){ //'>' is our ending character
inString[stringPos] = c;
stringPos ++;
}else{
//got what we need here! We can disconnect now
startRead = false;
client.stop();
client.flush();
Serial.println("disconnecting.");
return inString;
}
}
}
}
}