Go Down

Topic: Ethernet module startup.. (Read 797 times) previous topic - next topic

Frisky

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: [Select]


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

zoomkat

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

Perhaps that indicates a 1 min. delay somewhere in the code you didn't post.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Frisky

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

Code: [Select]

#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()
{
     
}


Frisky

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

zoomkat

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

Code: [Select]

#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() {

}
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Frisky

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

PaulS

Quote
I'm a dumb ass

You mis-spelled "I learned a valuable lesson".

Frisky

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

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy