Hi everyone,
I'm working on this project (a downtime tracker for one of my machine) utilizing NetDevilz PLX-DAQ v2.
My arduino has a simple LDR sensor attached to it with an RTC DS3231 module with it.
It records every second and with the help of PLX DAQ v2, it saves a .csv file into my personal computer every 15 minutes.
In order for it to save every 15 minutes, I set my code as so:
if ((now.dayOfTheWeek() == 5 && seconds >= 46800 && seconds <= 52199) || (now.dayOfTheWeek() == 0 && seconds >= 52200 && seconds <= 80999)) {
}
else {
if (seconds == 81899) { // save at 10:44.59pm
//Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (now.day()));
//Serial.println("CLEARDATA");
if ((future.day()) > (now.day())) {
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (future.day()) + "_01" );
}
else {
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (future2.month()) + "-" + (future.day()) + "_01" );
}
Serial.println("CLEARDATA");
}
if (seconds == 82799) { // save at 10:59.59pm
if ((future.day()) > (now.day())) {
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (future.day()) + "_02" );
}
else {
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (future2.month()) + "-" + (future.day()) + "_02" );
}
Serial.println("CLEARDATA");
}
if (seconds == 83699) { // save at 11:14.59pm
if ((future.day()) > (now.day())) {
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (future.day()) + "_03" );
}
else {
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (future2.month()) + "-" + (future.day()) + "_03" );
}
Serial.println("CLEARDATA");
}
if (seconds == 84599) { // save at 11:29.59pm
if ((future.day()) > (now.day())) {
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (future.day()) + "_04" );
}
else {
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (future2.month()) + "-" + (future.day()) + "_04" );
}
Serial.println("CLEARDATA");
}
if (seconds == 85499) { // save at 11:44.59pm
if ((future.day()) > (now.day())) {
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (future.day()) + "_05" );
}
else {
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (future2.month()) + "-" + (future.day()) + "_05" );
}
Serial.println("CLEARDATA");
}
if (seconds == 86399) { // save at 11:59.59pm
if ((future.day()) > (now.day())) {
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (future.day()) + "_06" );
}
else {
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (future2.month()) + "-" + (future.day()) + "_06" );
}
Serial.println("CLEARDATA");
}
if (seconds == 899) { // save at 12:14.59am
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (now.day()) + "_07" );
Serial.println("CLEARDATA");
}
if (seconds == 1799) { // save at 12:29.59am
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (now.day()) + "_08" );
Serial.println("CLEARDATA");
}
if (seconds == 2699) { // save at 12:44.59am
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (now.day()) + "_09" );
Serial.println("CLEARDATA");
}
if (seconds == 3599) { // save at 12:59.59am
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (now.day()) + "_10" );
Serial.println("CLEARDATA");
}
if (seconds == 4499) { // save at 01:14.59am
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (now.day()) + "_11" );
Serial.println("CLEARDATA");
}
if (seconds == 5399) { // save at 01:29.59am
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (now.day()) + "_12" );
Serial.println("CLEARDATA");
}
/////////////////////
//MAKAN TIME 1:30AM - 2:00AM
////////////////////
if (seconds == 8099) { // save at 02:14.59am
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (now.day()) + "_13" );
Serial.println("CLEARDATA");
}
if (seconds == 8999) { // save at 02:29.59am
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (now.day()) + "_14" );
Serial.println("CLEARDATA");
}
if (seconds == 9899) { // save at 02:44.59am
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (now.day()) + "_15" );
Serial.println("CLEARDATA");
}
if (seconds == 10799) { // save at 02:59.59am
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (now.day()) + "_16" );
Serial.println("CLEARDATA");
}
if (seconds == 11699) { // save at 03:14.59am
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (now.day()) + "_17" );
Serial.println("CLEARDATA");
}
if (seconds == 12599) { // save at 03:29.59am
Serial.println((String)"SAVEWORKBOOKAS,J2_" + (now.year()) + "-" + (now.month()) + "-" + (now.day()) + "_18" );
Serial.println("CLEARDATA");
}
This is just a short snipper but I hope you understand what I mean. Now instead of 15 minutes, I would like to save every 5 minutes or even lesser. But that would mean I'll have to write and edit a very tasking long list of codes as what I've done for 15 minutes (about 90).
My question and request for help is that is there a more efficient way to code and accomplish what I want as per my example code above?
Much thanks.