Skip to content

Instantly share code, notes, and snippets.

@acodesmith
Created September 18, 2012 03:13
Show Gist options
  • Save acodesmith/3741030 to your computer and use it in GitHub Desktop.
Save acodesmith/3741030 to your computer and use it in GitHub Desktop.
Connection to tide data for art chart
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(69,89,21,95); //acodesmith.com
EthernetClient client;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;;)
;
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
client.print("GET http://acodesmith.com/noaaData/gather/");
client.println(" HTTP/1.1");
client.println("Host: www.acodesmith.com");
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
delay(10000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment