SD Card Shield configuration on Arduino mega 2560 REV3?

You can wire the Adafruit shield to pins 50-53. You need to make sure the wiring is reliable.

I have used a Mega prototype board and soldered the SD module to the prototype board.

I am not sure you can accomplish what you want with two 115200 serial streams. Capturing one 115200 stream is about the limit for an Mega.

@fat16lib
Thanks so much for the guidance. I have made the HW wiring changes to the shield and wired up the LED to run the data logger example you had mentioned. I am able to create the Serial file on the card and the LEDs blink as stated in the readme file but the Serial file is empty. I changed it to a .txt with if (!file.open("SERIAL.txt", O_WRITE | O_CREAT | O_AT_END)) to see if that made a difference or not which it did not. I also changed the serial port on the logger to NewSerial1. I don't think that should matter should it? I have a wire from Sender board pin 1(TX0) to Logger board pin19 (RX1). The grounds are also tied together. I put a scope on the output of the sender and there is definitely data there. Not sure what to do next.

I have to make a little correction, actually the pin 53 HAS TO be defined OUTPUT.

In conclusion, for a Mega with Ethermet Shield:

pinMode(10, OUTPUT);
digitalWrite(10, HIGH);
pinMode(53, OUTPUT);

I have read of many who have had problems with Mega + Ethernet + SD, like me.
All of them were upgrading from One to Mega, and the same sketch wasn't working anymore.
After so many attempts and failures, I considered that:
-One uses pin 10, 11, 12, 13 and ICSP;
-Mega uses only ICSP.

Try to push the ICSP connectors, neglecting the laterals.
If it does, shorten the lateral pins.

Ciao,
Dritan

I don't see that there was ever a resolution to this thread. I was having the same problem. My SD card would not initialize when I switched to using the mega 2560 R3. I tried pin 53 and still nothing. According to http://arduino.cc/en/Hacking/PinMapping2560 the SS pin is pin 19 on the mega? I used pin 19 and that worked for me, my SD card works now.

The solutions:

  1. Use an SD card shield that connects the SD card (via voltage converter) to the ICSP header, instead of pins 10-13. All Arduino official shields (wifi,ethernet,wireless etc.) work this way
  2. In case your shield is hardwired to pins 10-13, enable software SPI mode by setting #define MEGA_SOFT_SPI 1 from #define MEGA_SOFT_SPI 0, or rewire it to MEGA's SPI pins.

Method 2, part 1 or 2 isn't as clean-cut as 1 since you are responsible for finding the line and changing it or wiring the pins.

I've been using sd cards with MEGA and arduino uno compatible boards I made myself for the past few years, Solution 1 works fine. I use arduino official shields.

@ liudr

Thank you very much.

Method 2 works great.

I have been trying to get the SD card work with my Uno Ethernet+SD shield, but unfortunately to no avail. When I use it with the Uno by placing it on top of it as it's supposed to, it works fine. However, when I connect it by wires to even the Uno, it doesn't work as well.

I would like to confirm that I'm doing everything correctly.

So, I use 6 wires in total for connecting the shield to the Mega:
gnd->gnd
5v->5v
4->53
11->51
12->50
13->52

I have tried both original SD library and the Adafruit one, but both didn't work.
The beginning of code, in the case of the Adafruit library, looks like this.

...
const int chipSelect = 4;    

void setup()
{
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.print("\nInitializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin 
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output 
  // or the SD library functions will not work. 
  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);
  pinMode(53, OUTPUT);


  // we'll use the initialization code from the utility libraries
  // since we're just testing if the card is working!
  while (!card.init(SPI_HALF_SPEED, 53,51,50,52 )) {
...

Every time I open the serial monitor, it says that the initialization failed. However, if I let the Arduino function for a while and it spits out multiple failures, then occasionally it gives the following:

Card type: SD1
Could not find FAT16/FAT32 partition.
Make sure you've formatted the card

Of course, I have tried formatting the card. I feel that this partial progress might be an error in the library since it has given the same message even if the chipSelect pin assigned in the code is completely wrong.
I tried commenting out the lines about pin 10 as well. Is everything correct? Should I physically connect a wire to the pin 10 of the ethernet shield, since it's not connected to anything (I tried that as well, didn't work but suppose it doesn't hurt to ask)?

Which SD shield are you using? A link to the hardware might help.

growqx:
I have been trying to get the SD card work with my Uno Ethernet+SD shield, but unfortunately to no avail. When I use it with the Uno by placing it on top of it as it's supposed to, it works fine. However, when I connect it by wires to even the Uno, it doesn't work as well.

So, I use 6 wires in total for connecting the shield to the Mega:

So it works on the Uno when you place it on top. it doesn't work on the Uno when you use jumpers. Now you're trying to use jumpers on the MEGA?

What happens when you place it on top of the MEGA and only jump pins 11-13 to their 51-53 equivalents?

Also, if you ever do need to format the card, make sure you don't use quick format.

Hi, I am new to Arduino and I need the library SD, SPI for ATMega2560 R3, could someone give me a link to download and tutorial where download? Thank.

I try to use a 2560 R3 Arduino with a shield Data Logging V1.0. as follows:

I use 4 wires as follows:
Shield Mega
SD_CS D10 53
MOSI D11 51
MISO D12 50
SCK D13 52

I use the .h .cpp CardInfo.ino files from Adafruit dated 10.11.2014

https://github.com/adafruit/SD/archive/master.zip

The only changes made in Cardinfo.ino are:

// const int chipSelect = 4;
chipSelect const int = 53;

// pinMode (SS, OUTPUT);
pinMode (53, OUTPUT);

I don't understand this lines because, I don't use it!

pinMode(10, OUTPUT);
digitalWrite(10, HIGH);

The shield is plugged MEGA2560r3 it and it does not work.

It never recognizes the memory card (I have tried 3 differents)
Finally, is someone he managed to run it ? and what is the way???

Please, sorry for my bad english :-[

Hi friends
Does sombody knows why I getting wrong data saved on my SD?
I am working with uno and mega
and botch has same error
take a shot look in this video

this is the code I am using.
tks and best regards

#include <SPI.h>
#include <SD.h>

const int chipSelect = 10;
String dataString = "";

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  Serial.print("Initializando 'SD card'...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(chipSelect, OUTPUT);

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Falla SD, o no está presente");
    // don't do anything more:
    return;
  }
  Serial.println("SD Ok.");
}

void loop()
{
  // make a string for assembling the data to log:
  String dataString = "";

  // read three sensors and append to the string:
  for (int I = 1; I <= 10; I++) {
    dataString += String(I);
    if (I < 10) {
      dataString += ",";
    }
  }

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File dataFile = SD.open("datalog.txt", FILE_WRITE);

  // if the file is available, write to it:
  if (dataFile) {
    dataFile.println(dataString);
    dataFile.close();
    // print to the serial port too:
    Serial.println(dataString);
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");
  }
}

hello frnds....this is rahul i am a student of robotics. i want tell u that if u also student of
The coding will be easier. If it is just 8051, external ADC will be needed while arduino mega has its own ADC. More pins on arduino means more options to attach other peripherals, as in a LCD, wireless control etc. Clock Speed for mega is more than that of 8051.
guys if u want any type help about this

this site will make sure help u more and more

Hi,

I know this is an old topic - but still relevant.

I have been trying to get my gsm/sd shied to work with my mega 2560 with no luck.

This is the number one hit when searching - so I will post my solution here.

I turned out my problem was the power connection.

If you are using jumperwires to connect the shield - make sure to connect the 3.3v power supply.

I have only connected the 5v. supply.

And the make sure you connect the SPI correct

SPI Uno Mega
SS 10 53
MOSI 11 51
MISO 12 50
SCK 13 52

The pins noted above are what I thought would be the case.
However when the shield is also for a 5" or 7" display that does not seem to be the case because none of the 4 shield I have from different manufactures can access the SD card and nor can the SD card slot on the display itself.
The only other thing I can think is that the driver chip is missing even though when I ordered the shields I specified I needed access to the SD card and I was assured that it was correct.

I am using Adafruit Ultimate GPS Unit with Arduino MEGA 2560 with Ethernet shield W5100, I used the SD.h libarary, and SPI.h library along with Adafruit_GPS library and SoftwareSerial.h library.
I have connected teh GPS RX, and TX to A8, and A9. as I defined them in my software Serial object.4

I have mentioned the chipselect pin number 53.
and I have reserved pin 10 as an output.

and it worked.

I bought a sd card module some time ago, from a Chinese seller on Ebay. These modules are really cheap, I paid 2,03€ for it and that includes shipping to Belgium. You really wonder how they can do it. To try it out I connected the sd card module to my Arduino Uno and uploaded the data logger example sketch. This sketch reads the value of 3 analogue inputs and logs it to a file on the sd card. This worked out of the box. Then I tried doing the same with my Arduino Mega 2560 and it caused me some head scratching. I plugged my sensor shield on the mega, this shield has a break out connector for a sd card module. Unfortunately the pinout of this connector is not written on the board itself. After some googling I finally found a small drawing with the pinout of the connector.

https://destinyguruji.com/

#include #include

void setup() {
pinMode(53,OUTPUT);
digitalWrite(53,HIGH);
pinMode(10, OUTPUT);
digitalWrite(10, HIGH);
Serial.begin(9600);
if(SD.begin(53))
{
Serial.println("True");
}
else
{
Serial.println("False");
}

}

void loop() {
// put your main code here, to run repeatedly:

}

no errors, connected to speaker, can hear sound while connecting the pin but after connecting i cannot hear the sound. any solution plz