Mega, xbee ,wireless SD shield


I am trying to realize a project involving a sending Mega, a receiving Mega, and data on an SD card to be read. First, I had the SD card in the Wireless SD shield on the sender (xbee series2). The card is initialized, the text file opened and displayed in the serial monitor as it should. ( Correct reception is a different issue). xbee is set up as sender, following the instructions by digikey, using x-ctu, ... )

I then put the SD card in the receiver to be opened, read, and processed following a certain command. (Following a switch setting a character is printed on Serial). Card does not initialize when inserted into the receiver's Wireless SD shield. The hardware differences consist in two additional arduino motor shields on the receiver, and the xbee series 2 shield set up as receiver.

Initializing code is taken and adjusted from the ReadWrite example in this site

pinMode(53, OUTPUT); // Mega
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");

  myFile ="Kalib.txt", FILE_WRITE);
   if (!myFile) {
     Serial.println("error opening *.txt");
    Serial.println(" x done.");
  // re-open the file for reading:
  myFile ="Kalib.txt");

I do not understand why it runs on the sender, but not on the receiver and would appreciate any hints about how to solve this issue



I do not understand why it runs on the sender, but not on the receiver

Well, you did say “The hardware differences consist in two additional arduino motor shields on the receiver”. That suggests, to me, that you might have a pin conflict. Specifically, which motor shields? Which pins do they use?

Its two adafruit motor shields V2.3 stacked onto a Mega 2560. The Arduino wireless SD shield carrying the digi international xbee Series2 is on top of those.

I tested my hardware a bit, took out the two motor shields, stacked the wireless SD shield to the other mega, took off the xbee, tried another SD card. At the end,with both SD shields it initializes on one Mega but not on the other.

The motor shields are stacked into the positions that are available on the uno(red), the SD shields additionally leave free the two upper left pins next to the usb B plug marked green(see attached figure).

A Hardware defect on the mega that’s not doing it seemed, so far, unlikely since anything else is working.
I will replace it on occasion and see.

Dok1.pdf (45.1 KB)

I changed the mega, it works with the ( new) mega without the motor shields, but not when they are stacked between the mega and the wireless SD shield. On adafruit and this website, I found the information required :

All 6 analog input pins are available. They can also be used as digital pins (pins #14 thru 19)

Digital pin 2, and 13 are not used.

Digital pin 11: DC Motor #1 / Stepper #1 (activation/speed control)
Digital pin 3: DC Motor #2 / Stepper #1 (activation/speed control)
Digital pin 5: DC Motor #3 / Stepper #2 (activation/speed control)
Digital pin 6: DC Motor #4 / Stepper #2 (activation/speed control)
These pins are in use only if the DC/Stepper noted is in use

Digital pin 4, 7, 8 and 12 are used to drive DC motors and Stepper motors via the 74HC595 serial-to-parallel latch
All these pins are in use if any DC motors or steppers are used

Digitals pin 9: Servo #1 control
Digital pin 10: Servo #2 control
These pins are used only if that particular servo is in use

Doc to wireless SD shield says it is using pins 4, 11, 12, and 13.

Indeed there exists a conflict concerning pins 4, 11, and 12.

So I need to look about how to resolve this. Any hints are of course welcome.