Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, an initiative of Stroud Water Research Center designed to help people advance knowledge and stewardship of fresh water.
New to EnviroDIY? Start here

How to dump contents of file on SD card to serial

Home Forums Mayfly Data Logger How to dump contents of file on SD card to serial

Tagged: ,

Viewing 6 reply threads
  • Author
    • #15641

        I had a working sketch that allowed me to transfer the contents of a file on the SD card using bluetooth. I switched over to the Mayfly board and am now using code from the menu-a-la-carte; however, when incorporating the lines of code previously used to dump the file contents. I get an error indicating ‘reference to File is ambiguous’. I think this has something to do with how Loggerbase.h and SD.h name files. The lines of code to execute the file dump is contained in Void ShowData() in the sketch. Anyone able to do this for their own sketches?


      • #15665
        Scott Ensign

          Hi @Selbig. Here is a very simple sketch that prints a file from the microSD card to the serial monitor. It might be too rudimentary for your purposes, but thought I would share it here. Notice the line “// SD.remove(“datalog.txt”);” is commented out. Uncomment this line to DELETE the file specified instead of printing it to the serial monitor. I find it is helpful for my work to have this option available when I need it.


        • #15820
          Scott Ensign

            This sketch is also available here: https://github.com/ScottEnsign/SDoutput. I’d welcome input and refinement.

          • #15830

              Hi I’ve been thinking/working on something slightly similar when @ensign posted above.

              BTW I found the github.com/ScottEnsign/SDoutput hasn’t got the actual code, I think it probably needs a “git push” to send the code up.

              Seems to me the issue with the @selbig  original post #15641 above, is that the SD card is initialized in Logger, so  ShowData() needs to be an extension to LoggerBase.x : Class Logger {}

              From  @selbig post transfer-file-from-sd-card-to-ios-android-via-bluetooth  post I’ve been thinking about adding BT ……

              So I believe the Software Use Case  is:

              User approaches a Mayfly/BT logger, and with the BT enabled phone, connects to the Mayfly-BT logger, and downloads the readings, also verifies the logger time is accurate.

              This could be done with developing an App that possibly uses an embedded remote procedure call (eRpc). However its a lot of skills.

              Another version might be ; User approaches a Mayfly/BT logger, and with the BT enabled phone,  connects to the Mayfly-BT logger with a terminal app that uses the BT serial pass through, and then commands the Mayfly to downloads the readings with “LR” (list readings) . Another  separate  command can list the time Mayfly date/time (D?), and also set the Mayfly time with D YYMMDD HHMM.

              I have a system that I am thinking of this for,   inexpensive-diy-conductivity-sensor   that currently has  Boot Net (walk up and get data).

              Some baby steps in getting there, has been developing a Mayfly SerialCommand interface, and its just about there – see Arduino-SerialCommand  This solves a problem of how to check date in the field.

              Initially I developed an interface using a simple String to collect the serial user input data.  However using String led to a terrible bug, as the Mayfly Rx input is floating (Mayfly Issue#28) and so can cause random bursts of characters, which with String meant it periodically fractured the heap and lobotomized the ram. See eight-tips-to-use-the-string-class-efficiently.  The hardware fix for the Mayfly is to add a dongle to J2 “FTDI Programmer” port, with a 1M resistor pull down to the Rx pin3

              I’ve just switched to a serial command – and added the context for “LR” and “L?” to  tu_serialCmd.h

              The next stages are to get the file listing, and then to try the BT context with the Serial Command being processed from the BT serial interface.

              One other issue is that with the UART serial port 115200baud, the serial input is misread about 20% of the time – I’m guessing the baud rate doesn’t quite line up. I wouldn’t think this would happen with BT.



            • #15833

                So it worked for me. I took @ensign  basic structure, and added it as an extension in the Class Logger, and then attached it to the two SerialCommands LR and L?

                LoggerBase SD Class extension


                LoggerBase SD methods


              • #15834

                  Listing the active logger file, recorded by TeraTerm with time stamp,


                • #15835

                    Listing the directory with L? needs a bit of cleanup but looks like this

                Viewing 6 reply threads
                • You must be logged in to reply to this topic.