No announcement yet.

Data Logger Example

  • Filter
  • Time
  • Show
Clear All
new posts

  • Data Logger Example

    The information provided in the AutomationDirect knowledge base is provided "as is" without warranty of any kind. AutomationDirect disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall AutomationDirect or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if AutomationDirect or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion of limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.

    SD card datalogger for P1AM-100

    This example shows how to log data to an SD card using the SD library.

    The circuit:
    * SD card attached to SPI bus as follows:
    ** MOSI - pin 11
    ** MISO - pin 12
    ** CLK - pin 13
    ** CS - pin SDCARD_SS_PIN(28)


    Check out the code here:
    Last edited by ADC_CommTeam02; 03-02-2020, 10:44 AM.

  • #2
    Tried this sketch with a number of different formats on my 2Gb SD card, all Attempts fail with 'Initializing SD card...Card failed, or not present'
    Can you add some more information to this sketch.


    • #3
      Just tested and our example works fine here on our end with the microSD card we are using.

      1.) Have you tried using a different microSD card?
      2.) What brand & specs of the card you are using?

      You could try the built-in SD example which only requires a single line change.

      Examples > SD > CardInfo

      Change this line to use “SDCARD_SS_PIN”
      //const int chipSelect = 4;
      const int chipSelect = SDCARD_SS_PIN;


      • #4
        @ADC...I have successfully opened a file ("logFile.txt") on my microSD card.

        When the file is opened, is it a new file with nothing in it or does it append if the file exists?


        • #5
          This example is using the standard Arduino SD Library. The default behavior will create the file if it does not exist, and append each time that it is reopened. See the Library Reference for more information: