SD Card not being initialised on First Boot ( works ok on soft resets )


Ill try and add as much info as I can.

I have an arduino nano and an SD card reader ( )

I am using the PetitFS library to read ( I only do reads ) as I was getting too close to memory limits and was causing corruptions with the stack. The sd card is always inserted.

So, the SD card is conencted to a 5v line, which comes off a 7805 voltage regulator.

When the arduino is connected to the usb/computer the sd card inits fine, and works as expected.

When running from the external power supply ( 12v 1amp ) via the 7805, the sd card isnt read. however if i soft reset while powered, the sd card reads fine...

This suggests its a inrush power issue? I have tried to combat it by placing a 100uf cap between the vcc and gnd pins of the sd card - but this does not work.

Any suggestions? i'm loosing my hair!

If the Arduino is also being powered from the 5V supply, it's possible that SD card initialization is being attempted too quickly after powerup. When you connect to the computer through USB, the bootloader takes a while to handshake with the driver and see if there's any waiting business to take care of. But if powered directly from 5V, none of that takes place, and execution of the sketch begins immediately.

SD cards need some time to boot. Typically 250ms is allowed after power comes up before attempting to communicate with the card.

I'm just guessing here, but it would explain why it works ok if the Arduino is reset with the power still on. Anyway, it's easy enough to just delay(250) at the beginning of your sketch, and see if that fixes it.

Thanks for the reply…

I have 4 delay(1000); in various places before the sd card is init, so although i like the suggestion, im not sure its that.

That was my initial thinking before i tried the delays though.

Then I'm at a loss. You might try something other than PetiteFS to see if that makes a difference. Perhaps try some of the relevant SD examples such as CardInfo or ReadWrite, and see if they work properly on the 5V powerup. There are two things going on - intializing the SD Card, then reading from the file, which is a FAT function. It would be nice to know where the problem is occurring.

It's just hard to think of a hardware explanation, assuming the SD adapter's regulator puts out 3.3V as it should. In both the USB and 5V cases, you're powering the adapter's Vcc pin from the Nano's 5V pin - right?

yea, im at a loss too...

the vcc is powered by the 5v from the 7805, which also feeds the arduino vin.

I tried an adafruit micro-sd card break out too, but thats the same issue.

I have put a 4 second wait right at the start, but same issue :-(

As you suggest, my next option is the library - maybe SDFat - im quite limited on memory though as im running a stepper motor, and an i2c device.

My device is size restricted, although im trying to get it to compile with a Nano Every.

The Vin pin of a Nano is the input to the voltage regulator, which is a 5V regulator. You need at least 6.5V there for it to work properly. The 7805 output should feed the 5V pin of the Nano as well as the Vcc input of the SD card adapter. Maybe it's the Nano that's messing up, not the SD card.

I have not seen this however what I do is when in the setup code is to set up the I/O, send my hello message, then delay for about 5 seconds incase I get a serial flood. The 100uF will add to the "inrush problem", but helps in other respects. I am assuming both the SD card and Arduino are connected to the same 12V supply and all grounds are connected. Good Luck & Have Fun! Gil