I just started working with Arduino and coming from more rudementary platforms like PIC and STM, I am amazed by the intuitive and easy handling of the hard- and software.
Anyway, I am still stuck already
I am using an Arduino Mega 2560 with an Ethernet Shield.
My first sketch looks like this:
// Including libraries:
#include <SPI.h>
#include <Ethernet.h>
#include <Streaming.h>
#include <MemoryFree.h>
#include <SkaarhojPgmspace.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x6B, 0xB9 };  // <= SETUP! MAC address of the Arduino
IPAddress clientIp(192, 168, 10, 101);         // <= SETUP! IP address of the Arduino
IPAddress switcherIp(192, 168, 10, 100);        // <= SETUP! IP address of the ATEM Switcher
// Include ATEMbase library and make an instance:
// The port number is chosen randomly among high numbers.
#include <ATEMbase.h>
#include <ATEMstd.h>
ATEMstd AtemSwitcher;
void setup() {
 randomSeed(analogRead(5)); // For random port selection
Â
 // Start the Ethernet, Serial and UDP:
 Ethernet.begin(mac,clientIp);
 Serial.begin(9600);
 Serial << F("\n- - - - - - - -\nSerial Started\n");
 Serial.println(Ethernet.localIP());
 // Initialize a connection to the switcher:
 AtemSwitcher.begin(switcherIp);
 AtemSwitcher.serialOutput(0x80);
 AtemSwitcher.connect();
 // Shows free memory:Â
 Serial << F("freeMemory()=") << freeMemory() << "\n";
}
void loop() {
 // Check for packets, respond to them etc. Keeping the connection alive!
  AtemSwitcher.runLoop();
}
The output I am getting from the serial monitor after compiling and flashing to the Arduino is this:
- - - - - - - -
Serial Started
0.216.216.216
Obviously the Ethernet Shield does not obtain the IP adress I am intending it to obtain.
I already connected an external 12V power supply in addition to the USB cable to rule out a lack of current and measured the connection from the Arduino to the Ethernet Shield for every pin (including ICSP).
The MAC Adress I am using is made up, for there is no sticker on the Ethernet Shield allthough it looks like one has been there once but was removed. But that should not be a problem, does it?
Every bit of help will be very much appreciated!
Cheers
Mark
I suggest to create a new test sketch, and test only the Ethernet and IP things for now.
Start with Serial.begin, and print a message, so you know that the sketch has started.
Then do Ethernet.begin() and check the return value as in the example.
After that, print the Ethernet.LocalIP.
Start without the IP number. So you will use DHCP, with: "Ethernet.begin(mac) ;"
Some routers block a range of mac numbers, try a few others. There are online mac number generators.
If DHCP works, try your own static clientIP number.
Some routers might block the Arduino IP if the Arduino sketch has not normal behaviour.
thank you for your reply!
I forgot to mention, that the Arduino is used in a closed network with just the Arduino, a laptop and a video switch connected by a network switch. So there is no DHCP server present.
I still tried the example you described and connected the Arduino to the companys network wich provides DHCP.
If I only enter a MAC adress (tried 3 different ones), the code hangs at "Ethernet.begin(mac);".
If I enter MAC and IP adress, I the code runs through and returns a wrong IP adress as before. Interesting might be, that the returned IP changed from 0.216.216.216 (with my example) to 0.218.218.218 (with your example). Don't realy know, what that's supposed to mean...
Maybe the router is blocking the arduino for some reason, but even then I should be able to assign a valid IP or not?
// disable the SD card by switching pin 4 high
// not using the SD card in this program, but if an SD card is left in the socket,
// it may cause a problem with accessing the Ethernet chip, unless disabled
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
// Stop SS from floating
pinMode(SS, OUTPUT);
digitalWrite(SS, HIGH);
Also does it work when you press reset and it restarts?
sorry for the delayed answer, but I was sick the last days and will be back in the office tomorrow.
Nevertheless thank you a lot for your help so far!
I am actually not using an SD card, but I will still try to disable the card reader as suggested.
Also by now I have nothing connected to any digital I/O pins or any other pins for that matter.
And resetting the Arduino by pressing on of the reset switches (on the Arduino or the Ethernet Shield) does not change the results at all.
I will keep you posted about the results of my tests with disabled card reader and non floating SS. (By the way, what's SS?)
Ok, I tried the code snippet suplied by keithsw1111, so my code looks like this:
#include <SPI.h>
#include <Ethernet.h>
// MAC address for your controller
byte mac[] = { 0x00, 0x53, 0xAD, 0x9B, 0xF9, 0xDF };
IPAddress ip(192, 168, 10, 101);
// 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()
{
 // start the serial library:
 Serial.begin(9600);
 Serial.println("serial started.");
Â
 // disable the SD card by switching pin 4 high
 // not using the SD card in this program, but if an SD card is left in the socket,
 // it may cause a problem with accessing the Ethernet chip, unless disabled
 pinMode(4, OUTPUT);
 digitalWrite(4, HIGH);
Â
 // Stop SS from floating
 pinMode(SS, OUTPUT);
 digitalWrite(SS, HIGH);
Â
 // start the Ethernet connection:
 Ethernet.begin(mac,ip);
 // print your local IP address:
 Serial.println(Ethernet.localIP());
}
void loop()
{
}
The result is still the same:
serial started.
0.216.216.216
Is it possible, that the Ethernet Shield is not compatible with my arduino or something like that?
Here are some pictures of the hardware on my desk:
Softwarewise I am using Arduino IDE 1.7.7 under Win7 on a 64bit system.
@zoomkat:
I am not shure I understand your question. I do not expect anything to suppliy an IP adress, because I am supplying one in my code. But the Ethernet Shield does not adopt it!
hoshymann:
Is it possible, that the Ethernet Shield is not compatible with my arduino or something like that?
Softwarewise I am using Arduino IDE 1.7.7 under Win7 on a 64bit system.
That's an Ethernet Shield 2, not an Ethernet Shield. It uses a W5500 Ethernet controller instead of the W5100 Ethernet Controller that the Ethernet Shield uses. So you need to change the line:
Oh man, I am so incredibly stupid!
I did not think there was a defferent library for a newer version.
Thank you so much for helping me out here!
Problem solved!
Glad I could help. Just FYI the Arduino IDE 1.7.7 is not arduino.cc(this website)'s IDE, it's arduino.org(different company)'s IDE. If you decide to switch to using arduino.cc's IDE which, despite the lower version number(long story but it doesn't mean it's behind 1.7.7), is actually under much more active development with a much stronger community(check out the arduino.org forum if you don't believe me), you will need to install the Ethernet2 library or one of the other Ethernet libraries that support the W5500 such as:
Ok, sounds good. So far the IDE does already anoy me in some points, so it may be a good idea to try an alternative.
I only recently heared about the two companys behind .org and .cc and my hardware says "arduino.org" printed on it. Will there be problems with compatibility despite the need to install the additional lib you mentioned?
The Arduino.cc and Arduino.org are spending money on a law suit who may use the name "Arduino". Will the trouble be over after the law suit has finished in a few years ? I hope so, but it might go on after that. Open Source and Open Hardware at its worst.
The Mega 2560 is a standard board in both IDEs so it should work just fine in the arduino.cc IDE. If you want to keep using the Ethernet2 library just copy the Ethernet2 folder from the libraries folder inside the Arduino install folder to your sketchbook/libraries folder and that will make the library available from both IDEs once you have configured your sketchbook location. If you download any of the install links other than the Windows Installer one you should be able to have both IDEs installed at the same time and use either one but I can't say for sure because I've never used 1.7.7. One benefit of using arduino.cc's IDE is that it's much easier to get help on this forum and the people here are much more familiar with arduino.cc's software.
The Arduino.cc and Arduino.org are spending money on a law suit who may use the name "Arduino".
hoshymann was asking about compatibility problems with their arduino.org Mega 2560 and Ethernet Shield 2 and the arduino.cc IDE. That really has nothing to do with the lawsuit(ok, there was the "uncertified board" warning but that's been removed since v1.6.2 and was never an actual compatibility issue). The issue with the Ethernet Shield 2 is caused by it using a different(newer and better) chipset and not by it being manufactured by arduino.org. I have also listed 2 non-arduino.org libraries above that should support that shield just fine.