I am trying to log data from the OpenScale, but no matter what I try it won’t save all of the data onto the SD Card. I am trying to create a .csv to store the data from the scale and time. I have the I2C bus running in fast mode and am saving to a custom named file that’s created at each startup instead of the created LOG***** files. I initially tried creating a string with the time (int), comma (str), and data (float) and send that at once, but it would drop the data part fairly often, so now I am sending each part one at a time with a delay in between them.
Here is how I am currently trying to save it:
void WriteToSDCard(float reading){
//Writes data to patient file
SDCard.append(fileName);
int writeTime = (millis() - initTime) / 1000;
//String data = String(writeTime) + ", " + String(reading);
SDCard.print(writeTime);
delay(10);
SDCard.print(", ");
delay(10);
SDCard.println(reading);
delay(10);
SDCard.syncFile();
//WriteToLog(data);
}
Here is what it creates in the file:
12, 26.07
12, 29.55
12, 29.63
13, 30.31
13, 30.63
14, 30.7114, 31.30
15, 31.30
15, 31.30
16, 31.30
16, 31.38
17, 31.49
17, 31.61
18, 31.79
18, 32.03
19, 32.20
19, 32.20
20, 32.20
20,32.20
21, 33.69
21, 38.54
22, 38
22, 38.65
23, 38.79
23,38.97
24, 39.26
24, 39.71
25, 40.04
25, 40.43
26, 40.98
26, 41.50
27, 42.30
27, 42.30
28, 42.30
28, 42.30
29, 42.36
29, 42.43
30, 42.50
30, 42.50
31, 42.74
31, 42.79
32, 42.93
32, 42.93
33, 42.93
33, 43.29
34, 43.29
63, 43.32
63, 43.38
64, 43.40
64, 4
65, 43.51
65, 43.60
66, 43.67
66, 43.84
67, 43.84
67, 59.85
68, 59.85
68, 59.85
69, 59.85
69, 59.85
70, 59.85
70, 59.85
71, 59.85
71, 59.85
72, 59.85
72, 59.84
73, 59.82
73, 59.82
74, 59.81
74,59.80
75, 59.80
75, 50.97
76, 40.95
76, 37.69
77, 37.69
77, 37.69
78, 37.69
78, 37.69
79, 37.69
79, 37.69
80, 37.69
80, 37.69
81, 37.69
81, 37.
82, 37.94
82, 38.04
83, 38.11
83, 38.19
84, 38.24
84, 38.29
85, 38.29
85, 38.29
86, 38.29
86, 38.29
87, 38.29
87, 38.29
88, 38.29
88, 38.29
89, 38.29
89, 38.28
90, 35.73
90, 35.73
91, 35.73
91, 35.73
92, 35.71
92, 35.65
93, 35.62
93, 35.55
94, 35.50
94, 35
95, 35.41
95, 35.41
96, 35.41
96, 34.27
97, 29.46
97, 28.44
98, 28.44
98, 28.44
99, 28.44
99, 28.44
100, 28.44
100, 28.44
101, 28.44