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