Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Logging serial data to an SD chip

  1. #1
    Junior Member
    Join Date
    Jun 2019

    Logging serial data to an SD chip

    I've been searching for a way to capture my serial port data to an SD chip on Teensy 3.5. I need all the information that is sent to the serial port to also be sent to a file on the SD, without doubling all of the print statements.

    I have explored several possibilities. The GeoTee library was one of those. GeoTee(?) (from GitHub) seems to output to the serial port just fine but not to the SD. I quickly gave that up. Perhaps I missed something there? I can write to the SD independently.

    I also looked at setting up a Print library but couldn't find how to reference the serial port. I dropped that too.

    Lately I started using Serial1 for directing my program data to, loop through its TX to RX pins, then relay the Serial1's RX to the SD as well as the serial port. With this technique, I'm having to add a ring buffer to Serial1's RX. I'm looking at a buffer size of 512 or 1024 bytes. My code is below.

    Is there a better approach for tee'ing outputs, such as to an SD as well as the serial port?

    Thanks, guys!


    // Main program and subroutines with print statements
    loop () {
      Serial1.print ( ... );
      Serial1.print ( ... );
      Serial1.print ( ... );
      distribPrint ();  // Distribute print output
    // Serial event to catch print statement output
    Serial1Event () {
      if (Serial1.available) {
        char c = (char) ();
        // Store to ring buffer
    // Distribute the output info to the serial port and SD chip
    distribPrint () {
      while (charAvail > 0) (
        char c = // Retrieve from ring buffer
        Serial.print (c);
        // Send c to SD write

  2. #2
    Senior Member
    Join Date
    Nov 2015
    Cold hollow VT
    On some of my projects I use the Sparkfun Open Log data logger. I listen in on the Rx line to the display monitor and capture all the data that gets sent out.

    No programming required and it just appends new data to the file on the micro SD.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts