sd_card example is not working


#1

Hi there,

i’m experiencing troubles using the sd_card example from the ArdusatSDK library.

when I try to upload it, I get an error “sketch too big”…

I made a smaller version of it, using only one of the sensors. now I’m able to upload the sketch properly, but it mentions the lack of available memory …

code here

and when I check the Serial monitor I’m getting this error…

I connect everything following the steps from This tutorial.

What should I do?


#2

Hey Carlos!

We recently did a refactoring of our SDK, primarily because of the SD Card library requiring a lot of memory. How long ago did you download the SDK?


#3

about a month ago.

I will check now the refactored SDK and write an update of this issue.

Thanks a lot.


#4

All of the SD card logging was broken out into a separate SDK. So when you download the new SDK, you’ll need to also download the Logging SDK. Then the logging example provided with the Logging SDK should work.

Here is a link to the new SDK on GitHub: https://github.com/ArduSat/ArdusatSDK
And the Logging SDK on GitHub:
https://github.com/ArduSat/ArdusatSDK-Logging


#5

using the latest version of the example in the ArdusatSDK-Logging.

I’m still getting the same error.

however if I modify the sketch in order to use only the UV sensor, I get it functioning correctly.

Code


#6

Well the good news - I’m seeing the same problem on my end. The bad news - I’m seeing the same problem on my end. I’ll work on figuring out what’s going on. Thank’s for the heads up!

In the mean time, is there a work around? Or do you need all of the sensors logging data?


#7

in the meantime I can manage with one sensor, but I will appreciate some help making this work during this week.

OT: I’m trying to save a CSV file with an acceptable format for the experiment platform but I need to use the RTC Chip to convert Millis to a valid timestamp and I couln’t find any tutorial about it, so I would really appreciate some guidance integrating the RTC chip with the SD Board in one sketch.


#8

I had some luck with this code:

#include <Arduino.h>
#include <Wire.h>
#include <ArdusatSDK.h>
#include <ArdusatLogging.h>

const short READ_INTERVAL = 10000; // interval, in ms, to wait between readings
const short SD_CS_PIN = 10;

static char LOG_FILE_PREFIX[] = "MYLOG";
static bool LOG_CSV_DATA = true; // otherwise, binary data is logged

temperature_t temp;
luminosity_t luminosity;
uvlight_t uv_light;
acceleration_t accel;
magnetic_t mag;
gyro_t orientation;


void setup(void)
{
  Serial.begin(9600);

  if (!beginDataLog(SD_CS_PIN, LOG_FILE_PREFIX, LOG_CSV_DATA)) {
    Serial.println("Failed to initialize SD card. Stopping...");
    while (true);
  }

  beginAccelerationSensor();
  beginTemperatureSensor();
  beginInfraredTemperatureSensor();
  beginLuminositySensor();
  beginUVLightSensor();
  beginGyroSensor();
  beginMagneticSensor();
  
  /* We're ready to go! */
  Serial.println("");
}

void loop(void)
{
  readAcceleration(accel);
  readMagnetic(mag);
  readGyro(orientation);
  readInfraredTemperature(temp);
  readLuminosity(luminosity);
  readUVLight(uv_light);

  if (LOG_CSV_DATA) {
    logAcceleration("accelerometer", accel);
    logMagnetic("magnetic", mag);
    logGyro("gyro", orientation);
    logTemperature("temp", temp);
    logLuminosity("luminosity", luminosity);
    logUVLight("uv", uv_light);
  } else {
    binaryLogAcceleration(0, accel);
    binaryLogMagnetic(1, mag);
    binaryLogGyro(2, orientation);
    binaryLogTemperature(3, temp);
    binaryLogLuminosity(4, luminosity);
    binaryLogUVLight(5, uv_light);
  }

  delay(READ_INTERVAL);
}

This is the same sketch as the example (minus the comments), but I removed the bytesWritten integer. That only saved 2 bytes from the sketch and that was enough to get it working, but I’m hesitant to call it fixed. You can use this code, but I’m going to look into finding a better way to free up some space. The SD Card library is totally just a memory hog.

Concerning the Real Time Clock, the way it currently works is at the beginning of the data logging session the time from the RTC is logged at the top of the file in milliseconds. So every additional entry in the log file can be converted to a valid timestamp by adding the millis timestamp to the first RTC value logged at the beginning. And then there are a handful of tools out there for converting milliseconds to meaningful time.

Here’s a stack overflow response for doing it with Python:


#9

thanks a lot for the help!

I’ve made some modifications to the Ardusat Library, and now I’m able to directly use the CSV created in the SD in the experiment platform.

Greetings


#10

Oh wow! We’ve been interested in stream-lining the process of logging data to an SD Card and then uploading it to the Experiment Platform, but we just haven’t gotten around to it yet. Would you care to share your updates to the SDK?