Detect if SD card is removed or reinserted

Hi, i'm doing a data logger project using the sdfat library and i would like to detect if an SD card is removed and reinserted. My project requires me to continue logging the data once a new SD card is reinserted. However, the SD card module i'm using does not have the card detect pin/switch for me to check if SD card is present. Is there any way for me to detect if there's any SD card without having to use the card detect pin but only modify the code?

Thanks in advance!

Hi, Could you have a special file on the SD card, and repeatedly open/close the file at regular intervals ? When the file can't be opened you know the card is gone, when it works again you know the card is back.

You'll probably have to re-issue the Begin() call in order to read the card again.

If the physical card detect switch is present, just solder a wire to it, an read that.

// Per

Take a look at this thread on the same topic.

http://forum.arduino.cc/index.php?topic=239157.msg1716604#msg1716604

Thanks for all your replies!
I’m using the SD card module attached below.
It seems that it doesn’t have the card detect switch to read from…

However, my problem is that i don't have the card detect switch to read from.

Yes you do. Solder wires onto the right tags on the socket.

Sorry but what do you mean by right tags? Which one do i solder to?

Two of those connectors on that SD socket are the card detect switch. They are the end two but I am not sure what end.

Take a multimeter set on resistance and measure the resistance between the end two contacts at each end. Find out the ones that short out on insertion of a card.

I found the two ends that got short when i inserted an SD card! What i need to do now is to solder the two ends together right?

Matoo: What i need to do now is to solder the two ends together right?

No.

Do like here: http://www.me.umn.edu/courses/me2011/arduino/technotes/microswitch/switch.jpg

So one end of the contact to GND, the other to Arduino input pin (you can use internal pullup if you want to)

// Per.

Matoo:
I found the two ends that got short when i inserted an SD card!
What i need to do now is to solder the two ends together right?

No.
You want to wire one end to ground and the other end to an arduino pin set as an input with the internal pull up resistors enabled.
Then you read that pin to see if a card has been inserted.
It will read low with a card and high without the card.

Thanks for your explanation!! But, must it be specifically which one of the ends to the ground or any one of them will do? the internal pull up resistor must also be connected to 5V isit?

must it be specifically which one of the ends to the ground or any one of them will do?

Any will do.

the internal pull up resistor must also be connected to 5V isit?

Yes the internal pull up resistor is connected to 5V. Otherwise it would not be called a pull up resistor.