Data logger

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jerryPugh
 
Posts: 23
Joined: Wed Jul 11, 2018 8:01 pm

Data logger

Post by jerryPugh »

When I run this sketch I get "card failed or not present" I have a good card in place.

Code: Select all

/*
  SD card datalogger

 This example shows how to log data from three analog sensors
 to an SD card using the SD library.

 The circuit:
 * analog sensors on analog ins 0, 1, and 2
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)

 created  24 Nov 2010
 modified 9 Apr 2012
 by Tom Igoe

 This example code is in the public domain.

 */

#include <SPI.h>
#include <SD.h>

const int chipSelect = 4;

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("Initializing SD card...");

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");
}

void loop() {
/*  // make a string for assembling the data to log:
  String dataString = "";

  // read three sensors and append to the string:
  for (int analogPin = 0; analogPin < 3; analogPin++) {
    int sensor = analogRead(analogPin);
    dataString += String(sensor);
    if (analogPin < 2) {
      dataString += ",";
    }
  }

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File dataFile = SD.open("datalog.txt", FILE_WRITE);

  // if the file is available, write to it:
  if (dataFile) {
    dataFile.println(dataString);
    dataFile.close();
    // print to the serial port too:
    Serial.println(dataString);
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");
  }
*/}
Last edited by adafruit_support_bill on Thu Jul 12, 2018 1:14 pm, edited 1 time in total.
Reason: Please use [code] tags when submitting code to the forums

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Data logger

Post by adafruit_support_bill »

Please post photos showing your soldering and connections.

User avatar
jerryPugh
 
Posts: 23
Joined: Wed Jul 11, 2018 8:01 pm

Re: Data logger

Post by jerryPugh »

Sorry I can't figure out how to post my photos. Also, what connections are you talking about?

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Data logger

Post by adafruit_support_bill »

Sorry I can't figure out how to post my photos
To post photos, use the "choose file" and "add the file" buttons below the edit window. There is a 1 meg limit. 800x600 is a good size.
Also, what connections are you talking about?
Any connections you might have. Based on your initial post, we have no idea what your configuration is beyond an SD card.

User avatar
jerryPugh
 
Posts: 23
Joined: Wed Jul 11, 2018 8:01 pm

Re: Data logger

Post by jerryPugh »

See attached photos. I didn't have any wiring for the project.
Attachments
IMG_1624.JPG
IMG_1624.JPG (128.06 KiB) Viewed 204 times
IMG_1623.JPG
IMG_1623.JPG (115.64 KiB) Viewed 204 times
IMG_1622.JPG
IMG_1622.JPG (123.86 KiB) Viewed 204 times

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Data logger

Post by adafruit_support_bill »

The solder looks mostly pretty good. It may be the lighting, but pin 11 looks a little suspicious. Make sure that the solder has flowed onto the header pin.
http://learn.adafruit.com/adafruit-guid ... n-problems

Which Arduino are you using for your project?

User avatar
jerryPugh
 
Posts: 23
Joined: Wed Jul 11, 2018 8:01 pm

Re: Data logger

Post by jerryPugh »

Uno

User avatar
jerryPugh
 
Posts: 23
Joined: Wed Jul 11, 2018 8:01 pm

Re: Data logger

Post by jerryPugh »

and I checked pin 11. It has a good solder connection.

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Data logger

Post by adafruit_support_bill »

Run the CardInfo sketch from the SD library and post the results here.

User avatar
jerryPugh
 
Posts: 23
Joined: Wed Jul 11, 2018 8:01 pm

Re: Data logger

Post by jerryPugh »

I ran the cardInfo sketch. It gave the same error message. It also said to check that I had set the correct chip select. When I changed
the chip select from 4 to 10 it worked. So did the other sketch.

Thank you for your help. And, sorry about the two threads, I am new to forums.

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Data logger

Post by adafruit_support_bill »

Good to hear you got it working. Thanks for the follow-up.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”