ethernet shield connects then disconnects... need help asap

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
bryanmc1988
 
Posts: 6
Joined: Thu Dec 18, 2014 1:59 am

ethernet shield connects then disconnects... need help asap

Post by bryanmc1988 »

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...

Code: Select all

#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); 
  }
}

User avatar
Franklin97355
 
Posts: 23938
Joined: Mon Apr 21, 2008 2:33 pm

Re: ethernet shield connects then disconnects... need help a

Post by Franklin97355 »

Which Adafruit products are you using in this project? Do you know at what point in loop the connection disconnects? What is the output of your program on the serial monitor and your LCD?

User avatar
bryanmc1988
 
Posts: 6
Joined: Thu Dec 18, 2014 1:59 am

Re: ethernet shield connects then disconnects... need help a

Post by bryanmc1988 »

Which Adafruit products are you using in this project? Do you know at what point in loop the connection disconnects? What is the output of your program on the serial monitor and your LCD?


i'm using the ethernet shield, arduino mega 2560 with the 3.2" tft lcd touch screen with the lcd shield,

from what i can tell it disconnected once it runs the void loop once and when it trys to repeat again it doesnt connect or stays connected after that first loop, the output for serial monitor and lcd? what do you mean by this? which pins are being used for the lcd and the ethernet shield?

User avatar
Franklin97355
 
Posts: 23938
Joined: Mon Apr 21, 2008 2:33 pm

Re: ethernet shield connects then disconnects... need help a

Post by Franklin97355 »

the output for serial monitor and lcd? what do you mean by this?
I'm asking what shows up on the LCD screen and on the PC when connected to the Mega. You have print statements in your code and I would like to know what they print.
Do you have product numbers for the LCD shield? I don't see an Adafruit product with that size screen. Also the Mega and the ethernet shields are made by Arduino and you may find more help posting in their forums.

User avatar
bryanmc1988
 
Posts: 6
Joined: Thu Dec 18, 2014 1:59 am

Re: ethernet shield connects then disconnects... need help a

Post by bryanmc1988 »

this is what i get on the Serial Print ....


as you can see it runs though the void loop once then it returns with not connected with is disconnecting the connection...?


Image



i dont have the model number for the parts that i ordered it was a while back.... could be a small lcd screen not sure but i'm assuming its a 3.2" or it could be a 2.4" or something like that too

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”