THanks for the response. My goal is to use the code to find the high and low temps (and eventually chance of rain) and then change the color of some LEDs depending on the range. I've left the LED part out until I can figure out how to read in the right information.
I've tried searching for "High", "Low", "Forecast", which all appear (at least to me) in the source RSS feed. If I search for "Current Conditions" that does work.
Here is my code:
//Source:
// Read Yahoo Weather API XML
// 03.09.2012
// http://arduino-praxis.ch
#include <SPI.h>
#include <Ethernet.h>
#include <TextFinder.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x73, 0xC5 };
//byte ip[] = { 10, 0, 1, 101 };
byte gateway[] = { 10, 0, 1, 1 };
byte subnet[] = { 255, 255, 255, 0 };
// Server Yahoo
IPAddress server(87,248,122,181);
EthernetClient client;
TextFinder finder( client );
char place[50];
char hum[30];
void setup()
{
// Start Ehternet
Ethernet.begin(mac);
// Start Serial Port
Serial.begin(9600);
Serial.println("Setup...");
}
void loop()
{
if (client.connect(server, 80))
{
// Call Wetter-API
// w: ID from your City
// Alternate access
// http://weather.yahooapis.com/forecastrss?w=12893459&u=c
Serial.println("Connect to Yahoo Weather...");
//client.println("GET /forecastrss?w=12893459&u=c HTTP/1.0");
//client.println("HOST:weather.yahooapis.com\n\n");
client.println("GET /forecastrss/60660_f.xml HTTP/1.0"); //I read on another forum that this link might provide more data
client.println("HOST:xml.weather.yahoo.com\n\n");
client.println();
Serial.println("Connected...");
}
else
{
Serial.println(" connection failed");
}
if (client.connected())
{
// Humidity
if ( (finder.getString("<yweather:atmosphere humidity=\"", "\"",hum,4)!=0) )
{
Serial.print("Humidity: ");
Serial.println(hum);
}
else
{
Serial.print("No Humidity Data");
}
// Place/City
if ( (finder.getString("<title>Conditions for ", " ",place,50)!=0) )
{
Serial.print("City: ");
Serial.println(place);
}
// High Temperature
// if(finder.find("temp=") ) original
if(finder.find("Forecast:") )
{
long temperature = finder.getValue();
Serial.print("High Temp F: ");
Serial.println(temperature);
}
else
{
Serial.print("No Temperature Data");
}
// Low Temperature
// if(finder.find("temp=") ) original
if(finder.find("Low") )
{
long temperature = finder.getValue();
Serial.print("Low Temp F: ");
Serial.println(temperature);
}
else
{
Serial.print("No Temperature Data");
}
// END XML
}
else
{
Serial.println("Disconnected");
}
client.stop();
client.flush();
delay(60000);
}