Adafruit Industries, Essential service and business: NYC – Executive Order 202.6 - Read more.
0

Adafruit SD Card Data Logger Shield
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit SD Card Data Logger Shield

by jonathanwarecd34 on Sun Mar 15, 2020 2:37 pm

Hi, I bought an SD Card Data Logger Shield with my Metro 328, which didn't work upon my initial testing, and I am trying to use the shield with an actual Arduino Uno. I am using the RTClib example for the PCF8523, and it is giving me some really weird stuff. Here is the code.
__________________________________________________________________________________________________________________________________________
Code: Select all | TOGGLE FULL SIZE

// Date and time functions using a PCF8523 RTC connected via I2C and Wire lib
#include "RTClib.h"
#include <Wire.h>

RTC_PCF8523 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {

  while (!Serial) {
    delay(1);  // for Leonardo/Micro/Zero
  }

  Serial.begin(57600);
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (! rtc.initialized()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    rtc.adjust(DateTime(2020, 3, 15, 1, 24, 0));
  }
}

void loop () {
    DateTime now = rtc.now();

    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(" (");
    Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
    Serial.print(") ");
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();

    Serial.print(" since midnight 1/1/1970 = ");
    Serial.print(now.unixtime());
    Serial.print("s = ");
    Serial.print(now.unixtime() / 86400L);
    Serial.println("d");

    // calculate a date which is 7 days, 12 hours and 30 seconds into the future
    DateTime future (now + TimeSpan(7,12,30,6));

    Serial.print(" now + 7d + 12h + 30m + 6s: ");
    Serial.print(future.year(), DEC);
    Serial.print('/');
    Serial.print(future.month(), DEC);
    Serial.print('/');
    Serial.print(future.day(), DEC);
    Serial.print(' ');
    Serial.print(future.hour(), DEC);
    Serial.print(':');
    Serial.print(future.minute(), DEC);
    Serial.print(':');
    Serial.print(future.second(), DEC);
    Serial.println();

    Serial.println();
    delay(3000);
}


__________________________________________________________________________________________________________________________________________

Here is what the serial monitor is outputting.

[img]
thumbnail_20200315_132122.jpg
thumbnail_20200315_132122.jpg (63.15 KiB) Viewed 81 times

[/img]

jonathanwarecd34
 
Posts: 10
Joined: Fri Nov 08, 2019 5:42 am

Re: Adafruit SD Card Data Logger Shield

by adafruit_support_bill on Sun Mar 15, 2020 3:04 pm

Code: Select all | TOGGLE FULL SIZE
 Serial.begin(57600);

Make sure that your serial monitor is also set at 57600 baud.

adafruit_support_bill
 
Posts: 76615
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit SD Card Data Logger Shield

by jonathanwarecd34 on Thu Mar 19, 2020 4:13 pm

Thank you so much, Bill. That worked. Is there a specific reason that the baud rate is set to 57600?

Jonathan

jonathanwarecd34
 
Posts: 10
Joined: Fri Nov 08, 2019 5:42 am

Re: Adafruit SD Card Data Logger Shield

by jonathanwarecd34 on Thu Mar 19, 2020 5:44 pm

Hi, again. I am also having trouble with the CardInfo example in the Arduino IDE. Here is the code that I am compiling and uploading.

Code: Select all | TOGGLE FULL SIZE


/*
  SD card test

  This example shows how use the utility libraries on which the'
  SD library is based in order to get info about your SD card.
  Very useful for testing a card when you're not sure whether its working or not.

  The circuit:
    SD card attached to SPI bus as follows:
 ** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila
 ** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila
 ** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila
 ** CS - depends on your SD card shield or module.
       Pin 4 used here for consistency with other Arduino examples


  created  28 Mar 2011
  by Limor Fried
  modified 9 Apr 2012
  by Tom Igoe
*/
// include the SD library:
#include <SPI.h>
#include <SD.h>

// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;

// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
// MKRZero SD: SDCARD_SS_PIN
const int chipSelect = 10;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("\nInitializing SD card...");

  // we'll use the initialization code from the utility libraries
  // since we're just testing if the card is working!
  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card inserted?");
    Serial.println("* is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    while (1);
  } else {
    Serial.println("Wiring is correct and a card is present.");
  }

  // print the type of card
  Serial.println();
  Serial.print("Card type:         ");
  switch (card.type()) {
    case SD_CARD_TYPE_SD1:
      Serial.println("SD1");
      break;
    case SD_CARD_TYPE_SD2:
      Serial.println("SD2");
      break;
    case SD_CARD_TYPE_SDHC:
      Serial.println("SDHC");
      break;
    default:
      Serial.println("Unknown");
  }

  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
    while (1);
  }

  Serial.print("Clusters:          ");
  Serial.println(volume.clusterCount());
  Serial.print("Blocks x Cluster:  ");
  Serial.println(volume.blocksPerCluster());

  Serial.print("Total Blocks:      ");
  Serial.println(volume.blocksPerCluster() * volume.clusterCount());
  Serial.println();

  // print the type and size of the first FAT-type volume
  uint32_t volumesize;
  Serial.print("Volume type is:    FAT");
  Serial.println(volume.fatType(), DEC);

  volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
  volumesize *= volume.clusterCount();       // we'll have a lot of clusters
  volumesize /= 2;                           // SD card blocks are always 512 bytes (2 blocks are 1KB)
  Serial.print("Volume size (Kb):  ");
  Serial.println(volumesize);
  Serial.print("Volume size (Mb):  ");
  volumesize /= 1024;
  Serial.println(volumesize);
  Serial.print("Volume size (Gb):  ");
  Serial.println((float)volumesize / 1024.0);

  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  root.openRoot(volume);

  // list all files in the card with date and size
  root.ls(LS_R | LS_DATE | LS_SIZE);
}

void loop(void) {
}




In addition, here is a picture of what the serial monitor is outputting.
Attachments
Screenshot (141).png
Screenshot (141).png (171.64 KiB) Viewed 62 times

jonathanwarecd34
 
Posts: 10
Joined: Fri Nov 08, 2019 5:42 am

Re: Adafruit SD Card Data Logger Shield

by adafruit_support_bill on Thu Mar 19, 2020 6:29 pm

Have you formatted the card for a FAT32 file system?
This is the recommended formatter: https://www.sdcard.org/downloads/formatter_3/

adafruit_support_bill
 
Posts: 76615
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit SD Card Data Logger Shield

by jonathanwarecd34 on Mon Mar 23, 2020 11:45 pm

I did not see anywhere that I could choose FAT32 file system. The Card type is SDXC and I chose quick format. I tried the example, was unsuccessful.

jonathanwarecd34
 
Posts: 10
Joined: Fri Nov 08, 2019 5:42 am

Re: Adafruit SD Card Data Logger Shield

by adafruit_support_bill on Tue Mar 24, 2020 6:03 am

The Card type is SDXC

SDXC uses a proprietary exFAT format and is not supported by the SD library. I don't think that the SD association formatter handles them.

You can try Bill Greiman's SDFormatter here: https://github.com/greiman/SdFat/blob/m ... matter.ino

Otherwise, try an SD or SDHC card.

adafruit_support_bill
 
Posts: 76615
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit SD Card Data Logger Shield

by jonathanwarecd34 on Thu Mar 26, 2020 2:45 am

Do I just run that code in the Arduino IDE, or how do I do that?

jonathanwarecd34
 
Posts: 10
Joined: Fri Nov 08, 2019 5:42 am

Re: Adafruit SD Card Data Logger Shield

by adafruit_support_bill on Thu Mar 26, 2020 5:45 am

I believe that is an Arduino sketch. So you should be able to just run that in the IDE.

adafruit_support_bill
 
Posts: 76615
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.