Won't save to SD without Serial Connection

I'm trying to record some logs of date/time onto an SD card to work as a standalone device using a NANO, but I noticed that this only records when I have a serial connection to the computer.
Any ideas appreciated.

When the Nano is not connected to the PC, how is it powered? What kind of SD card reader/writer are you using? How is it connected to the Nano?

Thanks PaulS for your prompt assistance:

Nano is powered from a 5 volt power dc supply comprising a 18650 battery with an inbuilt TP4056 (or similar) regulator.

SD Card R/W is a LC Studio clone.

All connections are using hookup wires. After powering up I press reset to ensure clean startup.

Have also replaced NANO with a UNO and same problem exists.

To test further & while using the UNO & reverted back to basics of using the DATALOGGER example from the SD library.
When connected via the USB cable to PC program works as expected with a file DATALOG.TXT created on SD card and lines of data stored each time loop goes through its paces with debug info showing on Serial Monitor.

As I can't use the Serial Monitor when using the UNO without any connection to PC I remove SD card, format card then reinsert in SC drive.
Reconnect 5V supply, press reset, then wait a minute, disconnect power and remove SD Card to PC to see what happened.
Tried this several times & the SD card now has the required DATALOG.TXT file created BUT without no data.

I found the following post where someone else had a similar problem but didn't help me:
https://www.reddit.com/r/arduino/comments/384i6x/question_how_to

Bottom line is I'm wanting to run a datalogger in stand alone mode without any PC connected.

Further comments appreciated.

My first thought would be to look at the voltage the card is seeing when connected via usb and the voltage when powered by the li-po. Can you put 5v in via another battery to try and isolate the problem. Some cards are more sensitive to Spi levels than others and yours might be one of them. Best regards

Thanks for the advice from others I've identified my elcheapo LC Studio SD Card is voltage level sensitive especially when used with my NANO which is plugged into a NANO I/O Shield as follows:

Measured 5V supply to Gnd at SD Card, with my external battery reads 4.78 volts but when plugged into PC's USB port is 4.41V and 4.78V when plugged into a phone charger plugpack.
With the lower voltages data is saved to SC card OK but not with the higher supply voltage.

To improve data storage I added a 5 second delay in loop to give SD time to respond.

Found the following link that discusses signal voltage levels which would al be in proportion to supply voltages and recommends some changes to signal levels.
http://forum.arduino.cc/index.php?topic=205812.0

LC Studio SD Card - Modification.pdf (155 KB)

Final solution was to use Bi-Directional Logic Level Converter e.g. Bi-Directional Logic Level Converter Hookup Guide - SparkFun Learn.

The level converters were connected to only CS, MISO & MOSI.

Can't explain why but when also used on SCK it would not work at all. Using my CRO I could see a lot of higher frequency pulsing at correct voltage level (5V down 3.3V) but I'm thinking the much higher pulse rate could be the cause. Some posts elsewhere refer to capacitance from wiring at these high frequencies could be an issue with my long hookup wire connections being used.

Regards all who assisted or may be watching this post. :slight_smile: :slight_smile: :slight_smile:

Hi,

Thank you for your post, it helps me a lot. I also experience this situation yesterday on my SD card module.

Adapting the information from you regarding the not good ground to AMS1117. I measured the voltage at the output of AMS1117 and found that my SD module have a voltage of 4.x volt. I think this is the issue of my SD module. Hence, I connect the 3.3V from the arduino to 3.3V of SD module (remove the 5Volt connection). Then, it's working fine to me. The file can be written, no error pop up (I wrote the status of SD card to LCD1602).

Cause I do not have a card reader hence I did not open the file yet. Will confirm later.

Updated (14/11/2017)
After go home, I opened using card reader. It wrote properly and all the time frame from RTC also updated in my SD.