I've been struggling to get an RSS reader to get text from Google weather following the example from "SimpleClientGoogleWeatherDHCP". I've been able to get integers pretty easily but I'm unable to get the text from the following xml page:
<current_conditions>
<temp_f data="36"/>
<temp_c data="2"/>
<wind_condition data="Wind: SW at 6 mph"/>
</current_conditions>
My code:
/*
* SimpleClientGoogleWeatherDHCP
* gets xml data from http://www.google.com/ig/api?weather=milwaukee,wi
* reads temperature from field: <temp_f data="66" />
* writes temperature to analog output port.
*/
#if ARDUINO > 18
#include <SPI.h> // needed for Arduino versions later than 0018
#endif
#include <Ethernet.h>
#include <EthernetDHCP.h> // uses DHCP code from: http://blog.jordanterrell.com/post/Arduino-DHCP-Library-Version-04.aspx
#include <TextFinder.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(26, 24, 22, 23, 25, 27, 29);
int backLight = 28; // pin 28 will control the backlight
byte mac[] = {
0x90, 0xA2, 0xDA, 0x00, 0x8F, 0xD3 };
byte server[] = {
209,85,229,104 }; // Google
Client client(server, 80);
TextFinder finder( client );
[glow=yellow,2,300]char cond[40];[/glow]
void setup()
{
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
lcd.begin(20,4);
lcd.setCursor(0,0);
lcd.print("I'm alive");
if(EthernetDHCP.begin(mac)) {
// begin method returns 1 if successful
lcd.setCursor (0,1);
lcd.print("got IP address, connecting...");
lcd.clear();
delay(500);
}
else {
lcd.clear();
lcd.print("unable to acquire ip address!");
while(true)
; // do nothing
}
}
void loop()
{
if (client.connect()) {
client.println("GET http://www.google.com/ig/api?weather=milwaukee,wi"); // google weather for London
client.println();
}
else {
lcd.println("I'm dead Jim");
}
if (client.connected()) {
finder.find("<temp_f data=");
int temperature = finder.getValue();
lcd.clear();
lcd.print("Temperature = ");
lcd.print(temperature);
delay(3000);
lcd.clear();
lcd.print("High Temp ");
finder.find("<high data=");
int temp = finder.getValue();
lcd.print(temp);
delay(3000);
lcd.clear();
lcd.print("Current Conditions ");
[glow=yellow,2,300]finder.find("<condition_data=");[/glow]
finder.get(cond,40);
lcd.setCursor(0,2);
lcd.print(cond);
}
else {
lcd.clear();
lcd.print("Oh intercourse the penquin");
}
client.stop();
client.flush();
delay(2000); //