Hello eneryone,
I have a small project - logging to sd 14 analog sensors sampling at 20-50ms. I have used sd library in the past (on slower sampling rates) and plan to use it for this project on a mega2560.
From what I read, there is a "latency" which may become (spec) 250ms.
Q: This latency may happen at a .write or only at a file.close ?
I had read the above mentioned example, but can;t say how it can be re-arranged to suit my "need". As a matter of fact I also see a "tie" with serialdata (not analog sensors) a not needed menu and so on.I understand that sdfat is faster, newer more complete but perhaps the effort to convert is much more than :
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
unsigned long milold1 = 0;
const int ADCpins[] = {A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13};
int SensorRead[15];
void setup(void)
{
pinMode(13, OUTPUT);
Wire.begin();
Serial.begin(115200);
delay(500);
}
void loop(void)
{
while (millis() - milold1 < 50) {
}
Serial.println(millis() - milold1);
milold1 = millis();
adc();
Transfer();
}
void adc(void) {
for (int x = 0; x < 14; x++) {
SensorRead[x] = analogRead(ADCpins[x]);
}
}
void Transfer(void) {
File dataFile = SD.open("datalog5.txt", FILE_WRITE);
if (dataFile) {
for (int x = 0; x < 14; x++) {
dataFile.write(SensorRead[x]);
}
dataFile.close();
}
}