SD shield doesn't work with battery

Hello arduino forum,

I try to make a GPS datalogger.
Evertything works fine when i test everything with the arduino connected with my pc.
From the moment i plug a battery to the arduino. the SD card reader/writer doesn't work anymore.
I am sure its not the code i made because i have the same problem when i use the example CardInfo what stays standard in de library.

the thing what happening is this:

SD card reader/writher connected with arduino, arduino connected to pc.
i upload the sd cardinfo code and next i try to read whats on the sd card.
This is working. the serial monitor say what it must say:

Initializing SD card...Wiring is correct and a card is present.

Card type: SDHC

Volume type is FAT32

Volume size (bytes): 3034054656
Volume size (Kbytes): 2962944
Volume size (Mbytes): 2893

from the moment i plug in a battery, so... now the arduino is connected to the pc and to the battery.
its not possible anymore to read the sd. the serial monitor now say this:

Initializing SD card...Wiring is correct and a card is present.

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

The arduino i use is a arduino mega 2560

i hope somebody can tell me whats wrong here.

Greetings,

Thom

Schijtpanda:
Evertything works fine when i test everything with the arduino connected with my pc.
From the moment i plug a battery to the arduino. the SD card reader/writer doesn't work anymore.
I am sure its not the code

You are probably right about the code but wrong about the SD. The post might be better named

"Battery doesn't work with SD shield"

It 's possible that the GPS is the real villain, and the SD is just the last straw. Now tell us what sort of battery you are using, and please don't say 9v PP3