so i am working on a weather data streaming from the website weather.gov to get temp and humidity reading then display it on my arduino mega 2560 tft 3.2 lcd screen but its not working out to good...
here is the code i been trying to run and at first its connecting at the void setup then when it gets to the void loop, it just disconnects for no reason
take a look at the code... i hope some one can help me with this issue... all wires are connected and not loose...
#include <UTFT.h> // used to interface with the TFT display
#include <UTouch.h> // used to interface with the touch controller on the TFT display
#include <avr/pgmspace.h>
#include <tinyFAT.h> // used to acess the SD card
#include <UTFT_tinyFAT.h> // used to read .raw images from the SD card
#include <SD.h> //Used to check for SD card
#include <SPI.h>
#include <Ethernet.h>
#include <TextFinder.h>
//LCD TOUCH PANEL and ITDB02 MEGA SHIELD v1.1
//(Mega Shield utilizes pins 5V, 3V3, GND, 2-6, 20-41, & (50-53 for SD Card))
UTFT myGLCD(SSD1289,38,39,40,41); //Uncomment this line for the SSD1289 TFT Screen
UTouch myTouch (6,5,4,3,2); //Pins Used for the Touch screen
UTFT_tinyFAT myFiles(&myGLCD); // start up an instance to read images from the SD card
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,115);
//IPAddress server(204,227,127,201); // weather.gov
char server[] = "weather.gov"; // name address for weather.gov
EthernetClient client;
TextFinder xml(client);
//Declare which fonts to be utilized
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
#define LARGE true
#define SMALL false
void setFont(boolean font, byte cr, byte cg, byte cb, byte br, byte bg, byte bb)
{
myGLCD.setBackColor(br, bg, bb); //font background black
myGLCD.setColor(cr, cg, cb); //font color white
if (font==LARGE)
myGLCD.setFont(BigFont); //font size LARGE
else if (font==SMALL)
myGLCD.setFont(SmallFont);
}
void setup() {
Serial.begin(9600);
SD.begin();
//Serial.println("FF Weather Station");
//Serial.println("connecting...");
myGLCD.InitLCD(LANDSCAPE);
myGLCD.clrScr();
myTouch.InitTouch(LANDSCAPE);
myTouch.setPrecision(PREC_MEDIUM);
file.setSSpin(53); // init SD card
file.initFAT(SPISPEED_VERYHIGH);
setFont(SMALL, 0, 0, 255, 0, 0, 0);
myGLCD.print("FF Weather Stn", 1, 1);
myGLCD.print("connecting...", 1, 13);
Serial.println("connecting...");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip);
}
delay(1000);
if (client.connect(server, 80)) {
myGLCD.clrScr();
setFont(SMALL, 0, 255, 0, 0, 0, 0);
myGLCD.print("Connected!", 1, 1);
Serial.println("Connected!");
client.println("GET /MapClick.php?lat=32.715328559000454&lon=-117.1572599319997&site=all&smap=1#.VJRtoXlgY HTTP/1.1"); //Make http request
client.println("Host: weather.gov");
client.println();
}
else {
myGLCD.clrScr();
setFont(SMALL, 255, 0, 0, 0, 0, 0);
myGLCD.print("connection failed", 1, 1);
Serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
if(xml.find("Humidity</span>")){
byte test = xml.getValue();
myGLCD.clrScr();
setFont(SMALL, 0, 255, 0, 0, 0, 0);
myGLCD.print("testing: ", 1, 1);
myGLCD.printNumI(test, 48, 1);
}
setFont(SMALL, 0, 0, 255, 0, 0, 0);
myGLCD.print("looking for data again in 5 sec", 1, 13);
Serial.println("looking for data again in 5 sec");
delay(5000); // check again in 5 seconds
}
else {
Serial.println();
Serial.println("not connected");
delay(1000);
}
}