SD Card not working on Arduino Mega

Hey Guys,

I'm trying to get my SD Card working on my original Arduino Mega Board. I did some research, but couldn't find the Problem.

I'm just using the CardInfo example. I haven't changed the code except for changing the CS Pin to 53.

When I'm looking at the Serial Monitor it reads:
"Initializing SD card...initialization failed. Things to check:

  • is a card inserted?
  • is your wiring correct?
  • did you change the chipSelect pin to match your shield or module?"

Other examples do something equivalent to this, like no SD card for example.

I do NOT use the ethernet shield. I know that there was an error for some with that ethernetet stuff, but I just have a simple SD Card Module connectet via Breadboard to the Mega.

I've connectet the pins like on this picture:
http://www.comm2excel.com/projects/pics/sd_card_module.png

has anyone an Idea why it's not working?

It's me again....

I've tried it again with an original Arduino Uno. It seems to work fine.

it's an 8Gig SDHC card. Formattet to FAT32.

So why the hell is it not working on my Mega? I've checked if the pins are connected correctly a few times. And yes they are. Is there anything missing in the code to run an Mega? I only know that i have to change the ChipSelect pin to the one wanted, wich I did. Otherwise i never used SD Cards before so I'm trying to learn about right now.

Please help me... Need that thing working soon, it's needed for a work project and I need the Mega board because of the more pins it offers.

Edit: Some crazy stuff is going on now. It will work if you remove the SD, put it back in and then reset the Mega. If you reset the Arduino again, it won't be able to read the SD again. You can try it as often as you want. It will only read that SD again, when you remove the SD, put it back in and then Reset the Mega. It wasn't that way on the Uno. Has someone got any Idea what the hell is going on there?

Sesselmann:
It's me again....

I've tried it again with an original Arduino Uno. It seems to work fine.

it's an 8Gig SDHC card. Formattet to FAT32.

So why the hell is it not working on my Mega? I've checked if the pins are connected correctly a few times. And yes they are. Is there anything missing in the code to run an Mega? I only know that i have to change the ChipSelect pin to the one wanted, wich I did. Otherwise i never used SD Cards before so I'm trying to learn about right now.

Please help me... Need that thing working soon, it's needed for a work project and I need the Mega board because of the more pins it offers.

Edit: Some crazy stuff is going on now. It will work if you remove the SD, put it back in and then reset the Mega. If you reset the Arduino again, it won't be able to read the SD again. You can try it as often as you want. It will only read that SD again, when you remove the SD, put it back in and then Reset the Mega. It wasn't that way on the Uno. Has someone got any Idea what the hell is going on there?

Does your SD card module have on-board level-shifters to convert the UNO 5V to 3.3V for the SD card?
Can you post a picture of it?

I just spotted the link to the picture. That module needs level-shifters. A CD4050B or 74HC4050 will do the trick. If a CD4050 is used, it must be a CD4050B, not just plain CD4050.
Here's a simple schematic:-
(I forgot the "B" in the schematic.)
SD Card Circuit.JPG

As shown in the diagram, the CD4050B or 74HC4050 can be powered by the 3.3V from the SD card module.
Edit: Oh, and needless to say, change the Arduino pin numbers to suit your board/setup.

The SD-Card uses the SPI interface which has different pins on the Mega.

SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS).
These pins support SPI communication using the SPI library.
The SPI pins are also broken out on the ICSP header,
which is physically compatible with the Arduino /Genuino Uno and the old Duemilanove and Diecimila Arduino boards.

1 Like

Whandall:
The SD-Card uses the SPI interface which has different pins on the Mega.

Good point. I didn't consider that maybe he was trying to use the same pins as on the UNO. Those SD modules still need external level-shifters, though. The inputs aren't 5V tolerant.

Edit: After re-reading the posts, I think he has the pins right though, or it wouldn't work at all on the Mega:-

It will work if you remove the SD, put it back in and then reset the Mega

Yes, of course I've plugged the SD Card to the right pins; I've also checked it several times. There was defenetly not the error.

Why would I need a level shifter for that? I mean I've tried now several programs, and while they don't work right or don't work at all on the Mega, the codes are running fine on the Uno.

After all those troubles I think the SPI Port of the Mega isn't working as it is supposed to. It wasn't used for projects before, it just arrived. So I've sended it back. (Even if the SPI actually wasn't the failure, the Digital 0-7 Pins where soldered really bad, so thats a reason alone to send it back).

When the new mega arrives, I'm giving response, if it's workin then.

Sesselmann:
Why would I need a level shifter for that?

That SD card module needs signals from the Arduino at 3.3V, not 5V. Some modules have onboard level shifters to convert from 5V to 3.3V, but not that one. Besides communication problems, you risk damaging the module.

Just because you 'got away' with doing it using the UNO, doesn't mean you were right. You were lucky.

Anyway, you know better, so there's no point in saying more. I won't reply here again. Good luck.