Data Logger Problem
Moderators: adafruit_support_bill, adafruit

Data Logger Problem

by ardaerzin on Sat Oct 13, 2012 8:47 pm

Hi everyone,

I have a data logger shield that I want to use, but I'm having problems with the SD library. I downloaded the SD library from github. Now I'm trying to compile the "datalogger" example, but it is giving me this error:

Code: Select all | TOGGLE FULL SIZE
/Users/ardaerzin/Documents/Arduino/libraries/SD/utility/Sd2Card.cpp: In member function 'uint8_t Sd2Card::init(uint8_t, uint8_t, int8_t, int8_t, int8_t)':
/Users/ardaerzin/Documents/Arduino/libraries/SD/utility/Sd2Card.cpp:290: error: 'digitalPinToPort' was not declared in this scope
/Users/ardaerzin/Documents/Arduino/libraries/SD/utility/Sd2Card.cpp:290: error: 'portOutputRegister' was not declared in this scope
/Users/ardaerzin/Documents/Arduino/libraries/SD/utility/Sd2Card.cpp:291: error: 'digitalPinToBitMask' was not declared in this scope
/Users/ardaerzin/Documents/Arduino/libraries/SD/utility/Sd2Card.cpp:294: error: 'portInputRegister' was not declared in this scope


can someone help me fixing this? I am not very experienced with these libraries.

btw, I'm using arduino 0023 and I would love to get this working without updating to 1.0.1
ardaerzin
 
Posts: 6
Joined: Thu Oct 04, 2012 4:59 pm

Re: Data Logger Problem

by adafruit_support_bill on Sun Oct 14, 2012 6:47 am

Scroll to the top of the error output window and post the first few lines. These are usually the most relevant.

From what you have posted, I suspect that your library is not installed in the correct location. Follow the instructions here: http://www.ladyada.net/library/arduino/libraries.html
User avatar
adafruit_support_bill
 
Posts: 31858
Joined: Sat Feb 07, 2009 10:11 am

Re: Data Logger Problem

by ardaerzin on Sun Oct 14, 2012 11:27 am

well the wierd thing is that, that is the whole error message. So far in my Arduino projects I had managed to find solutions etc on internet but this is by far the most annoying one =)

I kept getting these problems with my Arduino 0023 on Mac OSX Lion.Then I booted windows, which has arduino 1.0.1 installed the same libraries the same way, and it worked.
ardaerzin
 
Posts: 6
Joined: Thu Oct 04, 2012 4:59 pm

Re: Data Logger Problem

by adafruit_support_bill on Sun Oct 14, 2012 12:01 pm

I kept getting these problems with my Arduino 0023 on Mac OSX Lion.Then I booted windows, which has arduino 1.0.1 installed the same libraries the same way, and it worked.

It could be you had them installed in the right location but not capitalized as expected. On the Mac, capitalization matters. The Windows file system is case-insensitive.
User avatar
adafruit_support_bill
 
Posts: 31858
Joined: Sat Feb 07, 2009 10:11 am

Re: Data Logger Problem

by ardaerzin on Sun Oct 14, 2012 12:10 pm

i named the folder SD under libraries folder, both on windows and on mac. with further research, I'm learning there are some differenced between arduino 0023 and 1.0.1. For example the <Arduino.h> replacing "WProgram.h" with arduino 1 and stuff, but still nothing helps. I deleted 1.0.1 from my windows machine, installed 0023 and placed the very same library. I'm getting the same error I got on my Mac.
ardaerzin
 
Posts: 6
Joined: Thu Oct 04, 2012 4:59 pm

Re: Data Logger Problem

by adafruit_support_rick on Sun Oct 14, 2012 12:42 pm

I think you've got some sort of conflict between the standard arduino SD library and the adafruit SD library.

The adafruit library is smart enough to check which version of Arduino you're using, and it will include the right header file.:
Code: Select all | TOGGLE FULL SIZE
#if ARDUINO >= 100
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif

From what you describe, it seems as if the library is including the "Arduino.h" header instead of the "WProgram.h" header.

However, if you were somehow picking up the standard arduino 1.0.1 SD library, it wouldn't make that version check. It would simply include "Arduino.h"

I think you need to make sure that your install of 0.23 is really clean, and that there are no traces of 1.0.1 left at all.

Is there some reason you don't want to update to 1.0.1?

adafruit_support_rick
 
Posts: 13844
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Data Logger Problem

by ardaerzin on Sun Oct 14, 2012 1:02 pm

on my mac, i went to applications->arduino->(show package contents)->resources->libraries and deleted the SD library that comes with arduino. before and after this i got the same error message. on windows I simply deleted everything, reinstalled 23, deleted the sd library but again the same, so I think a clean installation is not the problem.

I want to use Sparkfun's linksprite JPEG camera and its libraries with the sd card shield. im basically doing the internet of things camera myself, but using a different camera . this is for a school project and we were given these cameras. I had a similar library problem with that camera, it won't work with 1.0.1, but it works just fine with 0023. That was the tradeoff for me, can't use both libraries on same arduino release for some reason. Anyways I gave up on using the jpegCamera library so that I can use SD card shield properly (i need to be able to write on an x2 eye-fi card and I guess without that library it is pretty much not possible. I am trying to get the code work for the camera, but im having problems with getting 640*480 pictures, they all get some wierd bands towards the end of jpg file, smaller sized pictures however work fine.

How do I learn about these libraries? Not installing them, but about understanding and modifying them
ardaerzin
 
Posts: 6
Joined: Thu Oct 04, 2012 4:59 pm

Re: Data Logger Problem

by adafruit_support_rick on Sun Oct 14, 2012 1:13 pm

ardaerzin wrote:on my mac, i went to applications->arduino->(show package contents)->resources->libraries and deleted the SD library that comes with arduino. before and after this i got the same error message. on windows I simply deleted everything, reinstalled 23, deleted the sd library but again the same, so I think a clean installation is not the problem.


In that case, there must be an include conflict. That is, some other header file is including the wrong version of the header BEFORE including the SD header file.

Are you trying to build one of the adafruit example sketches? If not, try that, and see if you still have this problem.

If this is your own sketch that you are writing, try moving the #include <SD.h> higher in the list of #includes. If you post your code here, we can have a look at it.
ardaerzin wrote:How do I learn about these libraries? Not installing them, but about understanding and modifying them

Really, the only way is to read the code and understand what it does. The SD library is one of the more complex ones. Most of the other adafruit libraries are relatively simpler.

adafruit_support_rick
 
Posts: 13844
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Data Logger Problem

by ardaerzin on Sun Oct 14, 2012 1:47 pm

i am testing the sd library using arduino 0023 with the code below:

Code: Select all | TOGGLE FULL SIZE
/*
  SD card datalogger
 
 This example shows how to log data from three analog sensors
 to an SD card using the SD library.
    
 The circuit:
 * SD card attached to SPI bus as follows:
 ** UNO:  MOSI - pin 11, MISO - pin 12, CLK - pin 13, CS - pin 4 (CS pin can be changed)
  and pin #10 (SS) must be an output
 ** Mega:  MOSI - pin 51, MISO - pin 50, CLK - pin 52, CS - pin 4 (CS pin can be changed)
  and pin #52 (SS) must be an output
 ** Leonardo: Connect to hardware SPI via the ICSP header
       Pin 4 used here for consistency with other Arduino examples
 
 created  24 Nov 2010
 modified 9 Apr 2012 by Tom Igoe
 
 This example code is in the public domain.
    
 */

#include <SD.h>

// On the Ethernet Shield, CS is pin 4. Note that even if it's not
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
// 53 on the Mega) must be left as an output or the SD library
// functions will not work.
const int chipSelect = 4;

File dataFile;

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


  Serial.print("Initializing SD card...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(SS, OUTPUT);
 
  // 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:
    while (1) ;
  }
  Serial.println("card initialized.");
 
  // Open up the file we're going to log to!
  dataFile = SD.open("datalog.txt", FILE_WRITE);
  if (! dataFile) {
    Serial.println("error opening datalog.txt");
    // Wait forever since we cant write data
    while (1) ;
  }
}

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 += ",";
    }
  }

  dataFile.println(dataString);

  // print to the serial port too:
  Serial.println(dataString);
 
  // The following line will 'save' the file to the SD card after every
  // line of data - this will use more power and slow down how much data
  // you can read but it's safer!
  // If you want to speed up the system, remove the call to flush() and it
  // will save the file only every 512 bytes - every time a sector on the
  // SD card is filled with data.
  dataFile.flush();
 
  // Take 1 measurement every 500 milliseconds
  delay(500);
}


this is the "datalogger" example included in the library folder, but this even this is generating the same error.

btw, I figured out the jpeg problem, apparently I had to use unsigned ints in my code to be able to adress larger 640*480 image files. I am surprised to see this is not even included in Sparkfun's library, i had to change it myself. we kinda need better documented libraries I guess
ardaerzin
 
Posts: 6
Joined: Thu Oct 04, 2012 4:59 pm

Re: Data Logger Problem

by adafruit_support_rick on Sun Oct 14, 2012 2:57 pm

Alright - I just downloaded and installed 0.23 on my mac. The Datalogger tutorial says to replace the standard SD library with the adafruit SD library, but all I did was to rename the standard library to something other than SD.

I copied your sketch into a new 0.23 sketch, and it came up with two errors. The first thing it didn't like was this:
Code: Select all | TOGGLE FULL SIZE
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

It didn't like the (!Serial), but since this is for Leonardo only, I commented it out. The second thing it didn't like was this:
Code: Select all | TOGGLE FULL SIZE
  pinMode(SS, OUTPUT);

Which is because the symbol 'SS' is not defined. I changed that to a literal '10', and the sketch compiled with no errors.

So, I don't know what your issue is. Did you remove/rename the standard SD library and replace it with the Adafruit library?

You're not trying to do this on a Leonardo, are you?

adafruit_support_rick
 
Posts: 13844
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Data Logger Problem

by ardaerzin on Sun Oct 14, 2012 3:19 pm

ah of course I did those. I changed the pinSelect to 10 cuz im using an adafruit shield etc etc, deleted that line because i'm using an uno r3. after those steps I got my error
ardaerzin
 
Posts: 6
Joined: Thu Oct 04, 2012 4:59 pm

Re: Data Logger Problem

by adafruit_support_rick on Sun Oct 14, 2012 4:16 pm

Did you delete the SD library from the Arduino application package?

adafruit_support_rick
 
Posts: 13844
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Data Logger Problem

by anwarhahj on Mon Mar 11, 2013 2:16 pm

For anyone else who has similar problems, I just wanted to say that I experienced the same issues on a Fedora Linux install. The solution to my issue ended up being the same as driverblock said, so make sure not to delete the original SD card library, just rename it and correct the undefined variable name (SS) errors and remove the offending while statement. I replaced the SS variable reference with the chipSelect variable that the tutorial said to change.
anwarhahj
 
Posts: 1
Joined: Mon Mar 11, 2013 2:12 pm