-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
Hello
I am trying to implement the data logger on the ESP32.
this is my part of the code.
myFile = SD.open("/logs/Battery.csv", FILE_WRITE);
myFile.printf("%02d-%02d-%02d ", now.date(), now.month(), now.year());
myFile.printf("%02d:%02d:%02d ", now.hour(), now.minute(), now.second());
myFile.printf(",");
if (sinput.startsWith("Battery")){
String Battery = getValue(sinput, ',', 1);
myFile.println(String(Battery));
// close the file:
myFile.close();
}
} else {
// if the file didn't open, print an error:
DBG_OUTPUT_PORT.println("error opening Battery.csv");
}
The specific code did work good with the ESP8266, but with the ESP32 it only update the first line of the CSV file but do add other lines, it just replace the first line each time...
All the examples I did find in google show that the command myFile.println(String(Battery)); (with the "ln") should add a new line, but it only replace the first line each time.
What do I do wrong? why doesnt it work the same as it did with the ESP8266?