Hi,
for the last few hours, I tried to log data to the IMU. however, the firmware code that was on the sparkfun website didn’t log the data on to the SD card. Then wrote the following code to just log some data, which didn’t work either.
#include <SparkFunMPU9250-DMP.h>
// SD Library manages file and hardware control
#include <SD.h>
// config.h manages default logging parameters and can be used
// to adjust specific parameters of the IMU
#include “config.h”
// Flash storage (for nv storage on ATSAMD21)
#ifdef ENABLE_NVRAM_STORAGE
#include <FlashStorage.h>
#include <SPI.h>
#endif
void setup() {
// Open serial communications and wait for port to open:
LOG_PORT.begin(9600);
//Serial.begin(9600);
while (!LOG_PORT) {
; // wait for serial port to connect. Needed for native USB port only
}
}
void loop() {
LOG_PORT.println(“Initializing SD card…”);
// see if the card is present and can be initialized:
if(SD.begin(38))
{
LOG_PORT.println(“mission passed boss”);
delay(2000);
}
while (!SD.begin(38))
{
LOG_PORT.println(“Card failed, or not present”);
}
if(SD.begin(38))
{
LOG_PORT.println(“mission passed boss”);
delay(2000);
}
LOG_PORT.println(“kkkkkkk”);
// make a string for assembling the data to log:
String dataString = “kkkk”;
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
File dataFile = SD.open(“datalog.txt”, FILE_WRITE);
// if the file is available, write to it:
if (dataFile) {
dataFile.println(dataString);
dataFile.close();
// print to the serial port too:
LOG_PORT.println(dataString);
}
// if the file isn’t open, pop up an error:
else {
LOG_PORT.println(“error opening datalog.txt”);
}
}