Printing To SD Card Instead Of Serial

I would like to get an accelerometer and SD card module for the Uno Rev3 I ordered. The accelerometer just has 3 analog pins (1 for each axis), and I would like to print those values every half a second to a txt file on the SD card. If possible, I would also like to put timestamps next to those values. I apologise if I have posted this in the wrong category or if it is a silly question. Thank you in advance.

1 Like

What actually is the question?

That is all possible.

To get the timestamp you may need an RTC module, or use an Arduino that can connect to the Internet.

Basically, I would like to press a button, which then outputs the accelerometer values to serial, and then when I press another button, it stops printing to serial monitor.

Instead of printing to serial, I would like to print those values to a txt file on the SD card.

What would be the best way to do this?

Very simple and straightforward. Once you have the SD module, install the SD library and experiment with the examples that come with it. Make sure that the SD module is compatible with 5V Arduino logic I/O (many are not).

Print the value of the millis() function as a time stamp, along with the three ADC readings all in one line.

@jremington Thanks for the help. I will try that once my Uno arrives in the mail. :+1:

void loop()
{
  // Every 30 seconds...

    // Get the analog readings

    // Get the time

    // Open the file  
    // Append everything to the SD card
    // Close the file
}

As @jremington said... get one thing working at a time... and slowly add more bits. There will be libraries and example code for each hardware component.

1 Like

This hook-up guide features an SD card module that has the required logic level converter for a 5V Arduino.

Yep I will do that and experiment with different libraries to help out. Thanks.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.