i am trying to log voltage & current of battery on SD card, the programme terminates before going thru complete loop of 20 readings each after 0.5Sec, if i remove current and voltage string from the code it prints ID upto 20 readings fine, but if i add voltage and/or current to string it stops randomly! some times after 6 readings some times after 13 etc.....
void loop()
{
File logFile = SD.open("LOG.csv", FILE_WRITE);
while (id<=20)
{
//Main battery Voltage
int voltage = analogRead(1);
//Sense Resistance/ Current Drawn
int current = analogRead(2);
//Create Data string for storing to SD card
String dataString = String(id)+ ", " +String(voltage)+", "+ String(current);
if (logFile)
{
logFile.println(dataString);
Serial.println(dataString);
}
else
{
Serial.println("Couldn't open log file");
}
//Increment ID number
id++;
delay(500);
}
logFile.close();
}