Hi guys, after 2 hard nights of attempts, I would like some light to my mind :o
My code is simples but the quantity of variables wrote in the SD is a some "large" .
For start and explain better my problem, I have 11 variables but 4 are 2d array (6x9) and 4 array 1d. In other words I will write 96 values of variables into sdcard.
go to the code :)....
I write the values(for my test stupid values i+j) in the following lines:
Code brief:
...
Serial.println("===========WRITING=============");
for(int i=1; i<=QUANTIDADE_SENSOR; i++){
for(int j=1; j<=QUANTIDADE_MAXIMA_ESTAGIO; j++){
Serial.println(i+j);
myFile.println(i+j);
}
}
Serial.println("==============================");
...
and read in this part:
Code brief:
...
Serial.println("===========READING=============");
for(int i=1; i<=QUANTIDADE_SENSOR; i++){ // BUSCANDO TODOS OS quantidadeDiasEstatio
Serial.println("SENSOR: ");
Serial.println(i);
for(int j=1; j<=QUANTIDADE_MAXIMA_ESTAGIO; j++){
Serial.print("ESTAGIO: ");
Serial.print(j);
Serial.print(" : ");
naoTerminou = true;
while(naoTerminou){
arrayChar[count] = myFile.read();
if(arrayChar[count] == 10){
Serial.print(atoi(arrayChar));
Serial.print(" | ");
quantidadeDiasEstatio[i][j] = atoi(arrayChar);
count = 0;
arrayChar[0] = '\0'; //ZERANDO O ARRAY PARA RECEBER O PRÓXIMO VALOR
naoTerminou = false;
}else{
count++;
}
}
Serial.println(quantidadeDiasEstatio[i][j]);
}
}
Serial.println("===============================");
...
RESULT OF SERIAL.PRINTLN:
===========LEITURA=============
SENSOR:
1
ESTAGIO: 1 : 2 | 2
ESTAGIO: 2 : 3 | 3
ESTAGIO: 3 : 4 | 4
ESTAGIO: 4 : 5 | 5
ESTAGIO: 5 : 6 | 6
ESTAGIO: 6 : 7 | 7
ESTAGIO: 7 : 8 | 8
ESTAGIO: 8 : 9 | 9
ESTAGIO: 9 : 10 | 10
SENSOR:
2
ESTAGIO: 1 : 3 | 3
ESTAGIO: 2 : 4 | 4
ESTAGIO: 3 : 5 | 5
ESTAGIO: 4 : 6 | 6
ESTAGIO: 5 : 7 | 7
ESTAGIO: 6 : 8 | 8
ESTAGIO: 7 : 9 | 9
ESTAGIO: 8 : 10 | 10
ESTAGIO: 9 : 11 | 11
SENSOR:
3
ESTAGIO: 1 : 4 | 4
ESTAGIO: 2 : 5 | 5
ESTAGIO: 3 : 6 | 6
ESTAGIO: 4 : 7 | 7
ESTAGIO: 5 : 8 | 8
ESTAGIO: 6 : 9 | 9
ESTAGIO: 7 : 10 | 10
ESTAGIO: 8 : 11 | 11
ESTAGIO: 9 : 12 | 12
SENSOR:
4
ESTAGIO: 1 : 5 | 5
ESTAGIO: 2 : 6 | 6
ESTAGIO: 3 : 7 | 7
ESTAGIO: 4 : 8 | 8
ESTAGIO: 5 : 9 | 9
ESTAGIO: 6 : 10 | 10
ESTAGIO: 7 : 11 | 11
ESTAGIO: 8 : 12 | 12
ESTAGIO: 9 : 13 | 13
SENSOR:
5
ESTAGIO: 1 : 6 | 6
ESTAGIO: 2 : 7 | 7
ESTAGIO: 3 : 8 | 8
ESTAGIO: 4 : 9 | 9
ESTAGIO: 5 : 10 | 10
ESTAGIO: 6 : 11 | 11
ESTAGIO: 7 : 12 | 12
ESTAGIO: 8 : 13 | 13
ESTAGIO: 9 : 14 | 14
SENSOR:
6
ESTAGIO: 1 : 7 | 7
ESTAGIO: 2 : 8 | 8
ESTAGIO: 3 : 9 | 9
ESTAGIO: 4 : 10 | 10
ESTAGIO: 5 : 11 | 11
ESTAGIO: 6 : 12 | 12
ESTAGIO: 7 : 13 | 13
ESTAGIO: 8 : 14 | 14
ESTAGIO: 9 : 15 | 15
As above, the atoi function and the variable, that receive the value, write and receive the correct values. OK!
BUT, this is my problem:
After call this functions, I call a new test, inserting 2 news recursive functions for confirm ,again, the values:
void loop()
{
criacaoBackup(); //MAKE BACKUP SDCARD
restauracaoBackup(); //RESTOR BACKUO OF SDCAR
//NEW TEST OF VALUES
for(int i=1; i<=6; i++){
Serial.print("SENSOR ");
Serial.println(i);
for(int j=1; j<=9; j++){
Serial.print("ESTAGIO ");
Serial.print(j);
Serial.print(" : ");
Serial.println(quantidadeDiasEstatio[i][j]);
}
}
delay(100000);
}
And the result is:
ENSOR 1
ESTAGIO 1 : -13107
ESTAGIO 2 : 16696
ESTAGIO 3 : -28836
ESTAGIO 4 : 16714
ESTAGIO 5 : 20971
ESTAGIO 6 : 16732
ESTAGIO 7 : 5243
ESTAGIO 8 : 16750
ESTAGIO 9 : -10486
SENSOR 2
ESTAGIO 1 : 16767
ESTAGIO 2 : 4
ESTAGIO 3 : 5
ESTAGIO 4 : 6
ESTAGIO 5 : 7
ESTAGIO 6 : 8
ESTAGIO 7 : 9
ESTAGIO 8 : 10
ESTAGIO 9 : 11
SENSOR 3
ESTAGIO 1 : 4
ESTAGIO 2 : 5
ESTAGIO 3 : 6
ESTAGIO 4 : 7
ESTAGIO 5 : 8
ESTAGIO 6 : 9
ESTAGIO 7 : 10
ESTAGIO 8 : 11
ESTAGIO 9 : 12
SENSOR 4
ESTAGIO 1 : 5
ESTAGIO 2 : 6
ESTAGIO 3 : 7
ESTAGIO 4 : 8
ESTAGIO 5 : 9
ESTAGIO 6 : 10
ESTAGIO 7 : 11
ESTAGIO 8 : 12
ESTAGIO 9 : 13
SENSOR 5
ESTAGIO 1 : 6
ESTAGIO 2 : 7
ESTAGIO 3 : 8
ESTAGIO 4 : 9
ESTAGIO 5 : 10
ESTAGIO 6 : 11
ESTAGIO 7 : 12
ESTAGIO 8 : 13
ESTAGIO 9 : 14
SENSOR 6
ESTAGIO 1 : 7
ESTAGIO 2 : 8
ESTAGIO 3 : 9
ESTAGIO 4 : 10
ESTAGIO 5 : 11
ESTAGIO 6 : 12
ESTAGIO 7 : 13
ESTAGIO 8 : 14
ESTAGIO 9 : 15
As above, I don't know WHY the same values are not show again.
Does exist some particular way of arduino care this values?
Thanks for any tip, trick , help and etc. ![]()