Arduino Leonardo and Logger Shield
Moderators: adafruit_support_bill, adafruit

Arduino Leonardo and Logger Shield

by WhiteNite1971 on Sun Feb 10, 2013 11:13 pm

Hi Gang

I have recently purchased a Arduino Leonardo and Logger Shield. Unfortunately these do not play well together. I thought I'd start a thread dedicated to working out how to resolve this.

The key issue revolves around the Serial Peripheral Interface (SPI) on the Arduino Leonardo. Specifically; the Arduino Leonardo does not have any SPI pins connected to digital pins 10 through to 13 which the Logger Shield requires.

To resolve this problem you need to download the following library;

https://github.com/adafruit/SD

//WARNING WARNING WILL ROBINSON!!!

It is at this stage I'm stuck. From what I've read I need to replace my SD library with the one above. I've searched everywhere to find where my 'installed' library is located but with no success. I can add new libraries no problem. :)

If I can get past this hurdle then what changes do I need to make to the following sample code to get the ball rolling;

Code: Select all | TOGGLE FULL SIZE
#include <SD.h>

void setup(){
  Serial.begin(9600);
 
  Serial.println("Check");
  pinMode(10, OUTPUT);
 
  if (!SD.begin(10)) {
    Serial.println("Fail");
    return;
  }
  Serial.println("Pass");
}

void loop(){
    File dataFile = SD.open("Test.txt", FILE_WRITE);
    if (dataFile){
      dataFile.println("Test");
      dataFile.close();
      Serial.println("Test");
      delay(5000);
    }
    else{
      Serial.println("Error");
    }
}


Any help would be greatly appreciated.

Cheers

Jase :)
WhiteNite1971
 
Posts: 18
Joined: Sun May 08, 2011 9:47 am

Re: Arduino Leonardo and Logger Shield

by adafruit_support_bill on Mon Feb 11, 2013 8:09 am

You need to find where your Arduino installation folder is. It should be named something like "Arduino-1.0.3" (depending on the version). Inside that there should be a "Libraries" folder with all the standard libraries - including the SD library.

To use the "software-spi" in your code, you need to specify all the SPI pins in the "begin" function:

Code: Select all | TOGGLE FULL SIZE
  if (!SD.begin(10,11,12,13))
User avatar
adafruit_support_bill
 
Posts: 30794
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino Leonardo and Logger Shield

by WhiteNite1971 on Mon Feb 11, 2013 11:36 pm

Hi adafruit_support

Thanks for getting back to me. For anyone attempting to do this, to get to your 'Existing Libraries Folder' on a Mac do the following;

1. Navigate to Applications Arduino
2. Control - Click Arduino
3. Click on Show Package Contents
4. File path Contents/Resources/Java/libraries

The original SD library is located here. Replace it with the one linked at the beginning of the thread.

Cheers

Jase
WhiteNite1971
 
Posts: 18
Joined: Sun May 08, 2011 9:47 am

Re: Arduino Leonardo and Logger Shield

by WhiteNite1971 on Tue Feb 12, 2013 12:22 am

Hi Gang

I've changed the code as follows;

Code: Select all | TOGGLE FULL SIZE
#include <SD.h>

void setup(){
  Serial.begin(9600);
    while (!Serial) {
    ;
  }
 
  Serial.println("Check");
  pinMode(10, OUTPUT);
 
  if (!SD.begin(10,11,12,13)) {
    Serial.println("Fail");
    return;
  }
  Serial.println("Pass");
}

void loop(){
    File dataFile = SD.open("Test.txt", FILE_WRITE);
    if (dataFile){
      dataFile.println("Test");
      dataFile.close();
      Serial.println("Test");
      delay(5000);
    }
    else{
      Serial.println("Error");
    }
}


Unfortunately the serial monitor prints 'Fail' then 'Error'. The other curious thing is I'm unable to detect a voltage between GND and VIN.

Any thoughts?

Cheers

Jase
WhiteNite1971
 
Posts: 18
Joined: Sun May 08, 2011 9:47 am

Re: Arduino Leonardo and Logger Shield

by adafruit_support_bill on Tue Feb 12, 2013 8:17 am

First thing: Have you verified the wave shield works on a standard Arduino? Have you tried different SD cards? Try the CardInfo sketch. It gives you a little more specific diagnostic information.
User avatar
adafruit_support_bill
 
Posts: 30794
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino Leonardo and Logger Shield

by WhiteNite1971 on Thu Feb 14, 2013 5:38 am

Hi adafruit_support

Again thanks for getting back to me. I have used the Logger Shield on an Arduino Uno and it works a treat! No issues at all :) . I then replaced the SD library as instructed and uploaded the amended sketch and for some odd reason it doesn't work. The reason I'm keen on using the Arduino Leonardo is that I also wish to emulate a keyboard (as well).

Any help would be greatly appreciated.

Cheers

Jase
WhiteNite1971
 
Posts: 18
Joined: Sun May 08, 2011 9:47 am

Re: Arduino Leonardo and Logger Shield

by adafruit_support_bill on Thu Feb 14, 2013 7:31 am

Have you tried the Cardinfo sketch? What does it report?
User avatar
adafruit_support_bill
 
Posts: 30794
Joined: Sat Feb 07, 2009 10:11 am