0

So I have just begun testing my Wireless SD Shield from Arduino with my Arduino UNO. Upon running my the basic CardInfo sketch, it uploads and displays data, but far more than expected. The SD Card is entirely empty, as in, if I plug it into my computer, there are no files on it. However, this is the Serial Monitor Output I receive:

Part 1

Part 2

The reason I have included screenshots rather than copy and pasting the output, is that if I try and copy and paste, it does not copy all of the Files Found on the card, it only copies the first 8 lines.

Any help would be greatly, appreciated!

This code does not compile for me and gives me an avrdude error which I believe is due in some part to the above pictures:

//Program by Jeremy Blum
//www.jeremyblum.com
//SD Card Demonstration
//Based on Example by Tom Igoe

#include <SD.h>

//Set by default for the SD Card Library
//MOSI = Pin 11
//MISO = Pin 12
//SCLK = PIN 13
//We always need to set the CS Pin
int CS_pin = 4;

void setup()
{
  Serial.begin(9600);
  Serial.println("Initializing Card");
  //CS Pin is an output
  pinMode(CS_pin, OUTPUT);


  if (!SD.begin(CS_pin))
  {
      Serial.println("Card Failure");
      return;
  }
  Serial.println("Card Ready");

}

void loop()
{
  String dataString = "Hello";

  //Open a file to write to
  //Only one file can be open at a time

  File dataFile = SD.open("log.txt", FILE_WRITE);
  if (dataFile)
  {
    dataFile.println(dataString);
    dataFile.close();
    Serial.println(dataString);
  }
  else
  {
    Serial.println("Couldn't open log file");
  }
  delay(5000);
}

Whereas, this code does:

#include <SD.h>         //SD Card Library
#include <Wire.h>       //I2C Library
#include <DallasTemperature.h>
#include <OneWire.h>

OneWire oneWire(2); // initiate pin connected to DS18B20
DallasTemperature sensors(&oneWire); // pass oneWire as parameter to Dallas Temp. library

//SPI SD Card Pins
  //MOSI = Pin 11
  //MISO = Pin 12
  //SCLK = PIN 13
  int CS_pin = 4;
//  int pow_pin = 8;

//Light Sensor Pins
  int light_pin = 0;

float refresh_rate = 500;  //Dataloger Refresh Rate
float id = 0;


void setup()
{
  Wire.begin();
  Serial.begin(9600);
  sensors.begin(); // initiate the sensors on the DS18B20
  Serial.println("Initializing Card");
  //CS Pin is an output
  pinMode(CS_pin, OUTPUT);

//  //SD Card will Draw Power from Pin 8, so set it high
//  pinMode(pow_pin, OUTPUT);  
//  digitalWrite(pow_pin, HIGH);

  //Initialize Card
  if (!SD.begin(CS_pin))
  {
      Serial.println("Card Failure");
      return;
  }
  Serial.println("Card Ready");


  //Write Log File Header
  File logFile = SD.open("LOG.csv", FILE_WRITE);
  if (logFile)
  {
    logFile.println(", , , ,"); //Just a leading blank line, incase there was previous data
    String header = "ID, Light, Temp";
    logFile.println(header);
    logFile.close();
    Serial.println(header);
  }
  else
  {
    Serial.println("Couldn't open log file");
  }

}

void loop()
{
  //Check Light Level
  int light_level = analogRead(light_pin); //Write the value of the photoresistor to the serial monitor.

  //Read Temperature
  sensors.requestTemperatures(); // request the temperatures from the DS18B20, does not actually do anything simple sets it up
  float currentTemp; // initialize variable to store and hold current temperature readings
  currentTemp = sensors.getTempCByIndex(0); // go and get temperature in Celcius for the first temp probe, temperature probe 0 (could have more than one sensor here if wanted)

  Serial.print("Temperature = ");
  Serial.print(currentTemp); // prints actual temperature and starts new line
  Serial.print(" Celcius ");
  /* Serial.print((char)223); print degree symbol in LCD format */
//  Serial.println("C");


  //Create Data string for storing to SD card
  //We will use CSV Format  
  String dataString = String(id) + ", " + String(light_level) + ", " + String(currentTemp);

  //Open a file to write to
  //Only one file can be open at a time
  File logFile = SD.open("LOG.csv", FILE_WRITE);
  if (logFile)
  {
    logFile.println(dataString);
    logFile.close();
    Serial.println(dataString);
  }
  else
  {
    Serial.println("Couldn't open log file");
  }

  //Increment ID number
  id++;

  delay(refresh_rate);
}

Both sketches are quite different, so I reccomend just looking at the intial void setup() part of each if you want to read through them.

  • Simply seeing an empty card on your computer, does not mean it's empty. Turn on 'Show hidden files' in Windows. Besides that, many of these files are written to the SD card to make it usable. Without them the card is either corrupted or formatted. – Len Jul 19 '16 at 10:09
1

Joy of tech... It's full file table, with old, deleted entries appearing as current files. You can nuke it with a quick or slow format, but the problem will return later. I don't know this shield, but there must be some problem with the code - it really shouldn't show deleted entries. Try another library, or google for problems with your current lib.

  • Not sure about quick format - but in any case, it shouldn't show old FAT. Please post your findings, I have some microsd modules in the mail. – user400344 Jul 19 '16 at 15:48
  • So I ended up leaving it be, and simply ran a different sketch and it seems to be working fine so far. I believe it may have been some hidden files instaled by my Mac when I first tried to use it, and so hopefully it will not be an issue in the future. – tyler a Jul 20 '16 at 8:47
  • mac's "hidden" files are prefixed with "." (dotfiles), that's not your bug. – user400344 Jul 20 '16 at 9:00
  • hmm, then not sure why it seems to have worked? – tyler a Jul 20 '16 at 11:15
  • can you post your broken and working code seperately? – user400344 Jul 20 '16 at 11:41
1

They are Mac's OS X "Spotlight" hidden indexing files. This answer shows how to turn it off.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.