Skip to content

Commit

Permalink
Update Datalogger1.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash2772 authored Jun 15, 2021
1 parent 0121064 commit 012701e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Datalogger1.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const int CSPin = 4;
const int baseNameSize = sizeof(baseName) - 1;
char fileName[] = baseName "00.txt";
unsigned long t;
unsigned long Previous_time = 0;

void setup() {
Serial.begin(9600);
Expand Down Expand Up @@ -40,6 +41,21 @@ void loop() {
t = millis();
data += String(t) + ", " ;

if (millis() - Previous_time >= 30000) {
Previous_time = millis();
while (SD.exists(fileName)) {
if (fileName[baseNameSize + 1] != '9') {
fileName[baseNameSize + 1]++;
} else if (fileName[baseNameSize] != '9') {
fileName[baseNameSize + 1] = '0';
fileName[baseNameSize]++;
} else {
Serial.println("Can't create file name");
return;
}
}
}

File dataFile = SD.open(fileName, FILE_WRITE);
if (dataFile) {
dataFile.println(data);
Expand Down

0 comments on commit 012701e

Please sign in to comment.