Leonardo and Adafruit Datalogger Shield

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

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
farmertough
 
Posts: 15
Joined: Tue Feb 05, 2013 5:10 pm

Re: Leonardo and Adafruit Datalogger Shield

Post by farmertough »

I switched the baud rate to 9600 and had no message on serial show. I'll try again with the sd card lib. Correct my process if wrong, I the download the SD lib from github, placed the new sd file in library of the arduino 1.0.3. Renamed the old sd as a backup file and place it in under the new sd. I'll remove the old sd file completely from library next and keep an update.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Leonardo and Adafruit Datalogger Shield

Post by adafruit_support_rick »

Here's what I did:
- Inside of the Arduino application folder (not the sketchbook folder), look for 'libraries'
- Create a new folder called "SD_Backup" inside of that 'libraries' folder.
- Drag the entire SD folder to SD_Backup. This will prevent Arduino from finding that library

- Download the Adafruit SD library from github
- Rename the folder 'SD', and drag it to the sketchbook libraries folder, where all the other adafruit libraries are.

farmertough
 
Posts: 15
Joined: Tue Feb 05, 2013 5:10 pm

Re: Leonardo and Adafruit Datalogger Shield

Post by farmertough »

Here is the update, with the code you had used with your leo, I have re-installed the arduino and have gone through and placed the original SD library into another folder so that it looks like this
C:\Users\Desktop\arduino-1.0.3\libraries\SDBackup\SD
and the updated version from the datalogger walkthrough like this
C:\Users\Desktop\arduino-1.0.3\libraries\SD
I tried this and I receive a blank screen on the com port used.

I, however did get the TransmogriShield and tried this as you would with original and updated SD libraries for each; the example cardinfo, the original code I had given, and the code you gave. Now the original Error came up that it isn't initializing on all tries. I feel like it might be the datalogger board, I know a place where I can grab an SD Shield and try that. Unless you know another way to use the TransmongriShield or can see something messed up either in coding or something else.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Leonardo and Adafruit Datalogger Shield

Post by adafruit_support_rick »

Seems like you've covered all the bases here. Please email [email protected] with a link to this thread and ask for a replacement data logger shield.

farmertough
 
Posts: 15
Joined: Tue Feb 05, 2013 5:10 pm

Re: Leonardo and Adafruit Datalogger Shield

Post by farmertough »

Thank you very much for staying with me through the troubleshooting. Been some of the best help I've had online. I've been tearing my hair out trying to figure out the problem. I'll send an update once I get a fix for the problem.

farmertough
 
Posts: 15
Joined: Tue Feb 05, 2013 5:10 pm

Re: Leonardo and Adafruit Datalogger Shield

Post by farmertough »

Here is the latest update. I found a store nearby that did have uno R3's and gave it one last try. I found that the Datalogger wasn't bad and the uno was able to hook up and read the SD card with the regular cardinfo example and chipselect=10. I'm not for sure what is wrong with the Leonardo, but will see about what is wrong with it and keep an update, I'm hoping that its not bad and just something with settings or code that isn't set up.

farmertough
 
Posts: 15
Joined: Tue Feb 05, 2013 5:10 pm

Re: Leonardo and Adafruit Datalogger Shield

Post by farmertough »

Not for sure if this is a possibility haven't tried it yet but here might be a way to address the problem.
http://arduino.cc/forum/index.php?PHPSE ... 058.0.html

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Leonardo and Adafruit Datalogger Shield

Post by adafruit_support_rick »

Well, the adafruit SD library ought to work for you. But I wasn't aware that Arduino implemented a soft SPI fix for the Leo. I'll give it a try when I get home.

beerhoof
 
Posts: 8
Joined: Fri May 23, 2014 11:57 am

Re: Leonardo and Adafruit Datalogger Shield

Post by beerhoof »

I also am having trouble getting the the data logger to work with the leonardo. I need the leonardo for it's extra inputs, so UNO is not an option. I have tested the shield with an UNO and it works just fine (no soldering errors).

I naturally tried the guide here: https://learn.adafruit.com/adafruit-dat ... d-leonardo
first. Changing chipSelect to 10 gives me the the 'Initialization failed...'. I then tried changing:

while (!card.init(SPI_HALF_SPEED, chipSelect)) {

to

while (!card.init(SPI_HALF_SPEED, 10, 11, 12, 13)) {

after this, the serial monitor doesn't print anything

I also tried:

while (!card.init(SPI_HALF_SPEED, chipSelect, 11, 12, 13)) {

this gives me a blank serial monitor

and

while (!card.init(SPI_HALF_SPEED, chipSelect, MOSI, MISO, SCK)) {

I then changed #define MEGA_SOFT_SPI 0
to #define MEGA_SOFT_SPI 1
in Sd2Card.h

nothing.

I then tried these suggestions (all with adafruit SD library): https://learn.adafruit.com/adafruit-shi ... -assembled

1: specifying pin 10 for chip select, 11 for MOSI, 12 for MISO and 13 for SCK... WHERE DO I SPECIFY THESE?
2: adding the line "#define SOFTWARE_SPI" to the top of utility/Sd2Card.h gives me this when compiling: Sd2Card.cpp:585: error: 'SPI' was not declared in this scope
3: Tried this with every iteration of the previous with no avail

I'd really like to get this working and was hoping it would be as simple as the tutorial. I was planning on buying 3 more of these, but not I'm not so sure.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Leonardo and Adafruit Datalogger Shield

Post by adafruit_support_rick »

Did you download the Adafruit SD library? Looks like you're using the standard Arduino SD library.

beerhoof
 
Posts: 8
Joined: Fri May 23, 2014 11:57 am

Re: Leonardo and Adafruit Datalogger Shield

Post by beerhoof »

yes. I moved the original SD library in program files ... to SD_backup and placed the adafruit SD library in my documents libraries.

I opened the example from the adafruit sd library

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Leonardo and Adafruit Datalogger Shield

Post by adafruit_support_rick »

The cardinfo sketch is a little weird. try the listfiles sketch. The card initialization should look like this:

Code: Select all

  if (!SD.begin(10, 11, 12, 13)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

beerhoof
 
Posts: 8
Joined: Fri May 23, 2014 11:57 am

Re: Leonardo and Adafruit Datalogger Shield

Post by beerhoof »

This is what the listfiles sketch looks like from the Adafruit SD library (https://github.com/adafruit/SD/archive/master.zip):

Code: Select all

/*
  SD card basic file example
 
 This example shows how to create and destroy an SD card file 	
 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

 created   Nov 2010 by David A. Mellis
 modified 9 Apr 2012 by Tom Igoe
 modified 13 June 2012 by Limor Fried
 
 This example code is in the public domain.
 	 
 */
#include <SPI.h>
#include <SD.h>

File 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
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 Leonardo only
  }


  Serial.print("Initializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin 
  // (10 on Arduino Uno boards, 53 on the Mega) must be left as an output 
  // or the SD library functions will not work. 
  pinMode(SS, OUTPUT);

  if (!SD.begin(chipSelect)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  root = SD.open("/");
  
  printDirectory(root, 0);
  
  Serial.println("done!");
}

void loop()
{
  // nothing happens after setup finishes.
}

void printDirectory(File dir, int numTabs) {
  // Begin at the start of the directory
  dir.rewindDirectory();
  
  while(true) {
     File entry =  dir.openNextFile();
     if (! entry) {
       // no more files
       //Serial.println("**nomorefiles**");
       break;
     }
     for (uint8_t i=0; i<numTabs; i++) {
       Serial.print('\t');   // we'll have a nice indentation
     }
     // Print the 8.3 name
     Serial.print(entry.name());
     // Recurse for directories, otherwise print the file size
     if (entry.isDirectory()) {
       Serial.println("/");
       printDirectory(entry, numTabs+1);
     } else {
       // files have sizes, directories do not
       Serial.print("\t\t");
       Serial.println(entry.size(), DEC);
     }
     entry.close();
   }
}


As is I got 'initialization failed!'

All of these changes yielded a blank serial monitor:

set chipSelect = 10;
// chipSelect = 10, then ... if (!SD.begin(10, 11, 12, 13)) { ...
chipSelect = 10, then ... if (!SD.begin(chipSelect, 11, 12, 13)) { ...

beerhoof
 
Posts: 8
Joined: Fri May 23, 2014 11:57 am

Re: Leonardo and Adafruit Datalogger Shield

Post by beerhoof »

in Adafruit SD library the utility/Sd2PinMap.h is a bit counter intuitive looking:

Code: Select all

#elif defined(__AVR_ATmega32U4__)
// Leonardo

// Two Wire (aka I2C) ports
uint8_t const SDA_PIN = 2;
uint8_t const SCL_PIN = 3;

// SPI port
uint8_t const SS_PIN = 17;
uint8_t const MOSI_PIN = 16;
uint8_t const MISO_PIN = 14;
uint8_t const SCK_PIN = 15;

static const pin_map_t digitalPinMap[] = {
  {&DDRD, &PIND, &PORTD, 2},  // D2  0
  {&DDRD, &PIND, &PORTD, 3},  // D3  1
  {&DDRD, &PIND, &PORTD, 1},  // D1  2
  {&DDRD, &PIND, &PORTD, 0},  // D0  3
  {&DDRD, &PIND, &PORTD, 4},  // D4  4
  {&DDRC, &PINC, &PORTC, 6},  // C6  5
  {&DDRD, &PIND, &PORTD, 7},  // D7  6
  {&DDRE, &PINE, &PORTE, 6},  // E6  7
  {&DDRB, &PINB, &PORTB, 4},  // B4  8
  {&DDRB, &PINB, &PORTB, 5},  // B5  9
  {&DDRB, &PINB, &PORTB, 6},  // B6 10
  {&DDRB, &PINB, &PORTB, 7},  // B7 11
  {&DDRD, &PIND, &PORTD, 6},  // D6 12
  {&DDRC, &PINC, &PORTC, 7},  // C7 13
  {&DDRB, &PINB, &PORTB, 3},  // B3 14
  {&DDRB, &PINB, &PORTB, 1},  // B1 15
  {&DDRB, &PINB, &PORTB, 2},  // B2 16
  {&DDRB, &PINB, &PORTB, 0},  // B0 17
  {&DDRF, &PINF, &PORTF, 7},  // F7 18
  {&DDRF, &PINF, &PORTF, 6},  // F6 19
  {&DDRF, &PINF, &PORTF, 5},  // F5 20
  {&DDRF, &PINF, &PORTF, 4},  // F4 21
  {&DDRF, &PINF, &PORTF, 1},  // F1 22
  {&DDRF, &PINF, &PORTF, 0},  // F0 23
};

edit:

i think i have to somehow make sure that http://37.media.tumblr.com/02016fb16100 ... 1_1280.png

corresponds to the leonardo settings in Sd2PinMap.h

but I don't know enough about what I'm doing here.
Last edited by beerhoof on Tue May 27, 2014 10:23 am, edited 1 time in total.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Leonardo and Adafruit Datalogger Shield

Post by adafruit_support_rick »

Please post clear, detailed pictures of both sides of the shield, showing your soldering.

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

Return to “Arduino Shields from Adafruit”