Newbie - MEGA 2560 r3 + Ethernet R3 Shield

Hi Guys,

I have been looking round the forum and general internet to find a solution. I hope that this hasnt been answered before, but nothing came up in the search

I have connected the Ethernet shield to the MEGA but I cannot get a connection to the network using any of the Example codes in the IDE 1.0.3 - Both units have been purchased in the last two weeks so should be the latest versions.

Is there something I am doing wrong - all code compiles and gets sent correctly to the board.

Things I have tried:
I make sure that the MAC address is correctly assigned (I have tried assigning a made up one as well but no joy)

Setting static IP and DHCP assigned ones - no joy

removed SD card

I have seen a couple of posts regarding pins and patching them to other connections but surely the R3 shields should work directly with a mega R3 board without having to do this (the idea of a shield?)

Any ideas

Are you absolutely sure that the MAC address matches the device? Try using the TELNET Client example. Does ipconfig /all give you any more info? I've got a clone MEGA and the Arduino Ethernet shield comes dangerously close to the electrolytic cans (ground?) over by the power connector pins. I'm using my MEGA clone in a production environment, or I'd give it a try.

Please show us your code.
Did you set pin 53 as output ?

// Set SPI SS pin as output.
// It is not used but it needs to be output for the SPI.
pinMode(53, OUTPUT);        // Only for the Mega

Use DHCP and what is the IP address ?

Serial.println(Ethernet.localIP());

Hi Erdin,

thanks for the Reply.

I am using the standard DHCPAddressPrinter that comes with the software. I have added your SPI code but still no joy.

/*
  DHCP-based IP printer
 
 This sketch uses the DHCP extensions to the Ethernet library
 to get an IP address via DHCP and print the address obtained.
 using an Arduino Wiznet Ethernet shield. 
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 
 created 12 April 2011
 modified 9 Apr 2012
 by Tom Igoe
 
 */

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

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {  
  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };

// Initialize the Ethernet client library
// with the IP address and port of the server 
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
  // Set SPI SS pin as output.
  // It is not used but it needs to be output for the SPI.
  pinMode(53, OUTPUT);        // Only for the Mega  
  
  pinMode(53, OUTPUT);  
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  // this check is only needed on the Leonardo:
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for(;;)
      ;
  }
  // print your local IP address:
  Serial.print("My IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print("."); 
  }
  Serial.println();
}

void loop() {

}

Here is a test sketch to determine if the SPI is working ok.

It should work ok with the SD card in the slot. Does it work ok on your setup?

Ok.

Tried that code and in the serial window I get

Starting W5100
0.0.0.0

It repeats if I press any of the reset buttons

Then you have either an SPI fail or w5100 fail. Check the connector pins closely, especially the ICSP pins. That is how the SPI data lines get to the Mega.

Ok,

I have just had a look at the two boards and I noticed this (see attached picture)

Now it's time to test my soldering skills out!!!

Fingers crossed that this fixes the problem!

When I first put an ethernet shield on a mega, I had the pin alignment on one side off by a pin. A close inspection of correct pins in the correct holes solved the issue.

Bingo - or should I say PING!!

Thanks guys for all the help :wink: Still surprised that this got through the QA stage of manufacture (or do they not test a shield against it?)

Time to get a smaller soldering tip, but initial testing says that the join is good :smiley:

Pinging 192.168.100.36 with 32 bytes of data:
Reply from 192.168.100.36: bytes=32 time=352ms TTL=1
Reply from 192.168.100.36: bytes=32 time<1ms TTL=128
Reply from 192.168.100.36: bytes=32 time<1ms TTL=128
Reply from 192.168.100.36: bytes=32 time<1ms TTL=128

Now I can try some stuff out -

I've not seen that before. It appears it is not soldered, also not trimmed? I don't know about QA. It is not mil spec, so they do not test every part. But you think they would have caught that.

Still surprised that this got through the QA stage of manufacture (or do they not test a shield against it?)

The board has "made in italy", so what are the expectations?

SurferTim:
I've not seen that before. It appears it is not soldered, also not trimmed?

I think it was the first time the shield was attached it pushed the pin through, I just didn't notice! Looks like the solder hole was never filled (it is now :slight_smile: )

That makes sense. It was aligned (not soldered) until you attached the shield. Good deal on the repair. :slight_smile: