PaulS:
The body of the message generally goes inside the tags, which follow the tag, inside the tags.
If this is not the case for you, you need to post all of your code, and some sample data returned by the client.
The html code that is received by the sketch is below. I've stripped out a lot of the extra stuff that is normally part of a standards-compliant site, to make it simpler to deal with once it is captured by the Arduino:
<html><head></head><body>. . . . . . body text goes here, less than 1200 characters total . . . . . . </body></html>
Here is the sketch:
/*
Media Circus 005
by Michael B. LeBlanc, NSCAD University
This sketch connects to a website using an Arduino Wiznet Ethernet shield.
Circuit:
- Ethernet shield attached to pins 10, 11, 12, 13
code from "Web client", created 18 Dec 2009 by David A. Mellis
*/
#include <SPI.h>
#include <Ethernet.h>
String theString;
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {
192,168,1,45 };
byte server[] = {
24,222,117,110 }; // nscad.dyndns.org
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
Client client(server, 8888);
//Client client(server, 80);
//int flag = 0;
void setup() {
// start the Ethernet connection:
Ethernet.begin(mac, ip);
// start the serial library:
Serial.begin(57600);
// give the Ethernet shield a second to initialize:
delay(1500);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect()) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /index.php?");
client.println();
}
else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
theString += c;
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
//for(;
// ;
theString = theString.replace("", "");
Serial.println(theString);
delay(10000); //wait 10 secs
}
}
One final note regarding memory: I'm running this on a Duemilanove. The binary sketch size is around 8058 bytes (with 30k available). Although it seems to me that there is plenty of headroom in terms of storage on the chip, could I be running into memory problems with the string function? Are there limitations on the size of the string?