Pages: [1]   Go Down
Author Topic: Ethernet module startup..  (Read 701 times)
0 Members and 1 Guest are viewing this topic.
Chicago
Offline Offline
Full Member
***
Karma: 0
Posts: 113
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi
I'm writing and wondering if this is normal that when I run the code to setup the ethernet shield that it takes a minute to execute? I timed it and one minutes pases until the "connected and ip" shows up on serial monitor plus ledYell is on while ethernet is waiting too.

Code:

//  Ethernet Shield Settings.
//
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
//
// If you don't specify the IP address, DHCP is used (Only in Arduino 1.0 or later).
//
byte ip[] = {192, 168, 0, 10};

   void setup()
{
  pinMode(ledReady,OUTPUT);
  pinMode(ledAlert,OUTPUT);
  digitalWrite(ledAlert,LOW);
  pinMode(ledError,OUTPUT);
  digitalWrite(ledError,LOW);
  pinMode(ledYell,OUTPUT);
  digitalWrite(ledYell,ON);
  pinMode(ledPost,OUTPUT);
  digitalWrite(ledPost, LOW);
  Serial.begin(115200);
   
  Serial.println(F("Starting Ethernet in 1 min"));
  if (!Ethernet.begin(mac))  // Try to connect using DHCP
    Ethernet.begin(mac, ip); // Try to connect using a Static IP address.
   
  Serial.print(F("Connected to IP address: "));  // Print out the IP address.
  for (int i = 0; i < 3; i++)
    {
      Serial.print(Ethernet.localIP()[i], DEC);
      Serial.print(".");
    }
  Serial.println(F(" Ethernet ready"));
  Serial.println();
  digitalWrite(ledYell,OFF);


Thanks
Don
Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9685
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
Serial.println(F("Starting Ethernet in 1 min"));

Perhaps that indicates a 1 min. delay somewhere in the code you didn't post.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Chicago
Offline Offline
Full Member
***
Karma: 0
Posts: 113
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I  added that message as the begin of the wait period I'm experiencing.
This is my whole setup code.

Code:
#include "Arduino.h"
#include <SPI.h>
#include <Ethernet.h>
#include <Twitter.h>

//define led names
#define ledReady A5
#define ledAlert A4
#define ledError A3
#define ledYell A2
#define ledPost A0

//define led states
#define ON HIGH
#define OFF LOW

#define BoM 1

//  Ethernet Shield Settings.
//
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
//
// If you don't specify the IP address, DHCP is used (Only in Arduino 1.0 or later).
//
byte ip[] = {192, 168, 0, 10};
//

char message[141] = "";

//  Setup begins here.
//
void setup()
{
  pinMode(ledReady,OUTPUT);
  pinMode(ledAlert,OUTPUT);
  digitalWrite(ledAlert,LOW);
  pinMode(ledError,OUTPUT);
  digitalWrite(ledError,LOW);
  pinMode(ledYell,OUTPUT);
  digitalWrite(ledYell,ON);
  pinMode(ledPost,OUTPUT);
  digitalWrite(ledPost, LOW);
  Serial.begin(115200);
   
  Serial.println(F("Starting Ethernet in 1 min"));
  if (!Ethernet.begin(mac))  // Try to connect using DHCP
    Ethernet.begin(mac, ip); // Try to connect using a Static IP address.
   
  Serial.print(F("Connected to IP address: "));  // Print out the IP address.
  for (int i = 0; i < 3; i++)
    {
      Serial.print(Ethernet.localIP()[i], DEC);
      Serial.print(".");
    }
  Serial.println(F(" Ethernet ready"));
  Serial.println();
  digitalWrite(ledYell,OFF);
  digitalWrite(ledReady, HIGH);
}

void loop()
{
     
}

Logged

Chicago
Offline Offline
Full Member
***
Karma: 0
Posts: 113
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

BTW I'm using a SainSmart ATMega2560 board with a R3 ethernet shield from Radio Shack here in USA.
Don
Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9685
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try the below and see if an ip address is returned quickly.

Code:
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

void setup()
{
  Serial.begin(9600);

  // disable SD SPI if memory card in the uSD slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Serial.println("Starting w5100...");
  if(!Ethernet.begin(mac)) Serial.println("failed");
  else Serial.println(Ethernet.localIP());
}

void loop() {

}
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Chicago
Offline Offline
Full Member
***
Karma: 0
Posts: 113
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Zoomkat
I'm a dumb ass, Your code took a minute to fail also. I didn't have a ethernet cable plugged in since I was using static ip, I didn't think it mattered. With a ethernet cable your code and mine works in 5 seconds.
Thanks for the test code and the time you took to reply to me I appreciate it!
Thank you
Don
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 50243
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I'm a dumb ass
You mis-spelled "I learned a valuable lesson".
Logged

Chicago
Offline Offline
Full Member
***
Karma: 0
Posts: 113
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Paul
 I sure did "learn a valuable lesson" I'm having a lot of fun here.
Thank you to knowledgeable folks here on the forum.
Don
Logged

Pages: [1]   Go Up
Jump to: