By ecangis
#8934
So, hi, i have been working around with the microSD card reader (cod. dfr0229) and the arduino expansion for raspberry (cod. DFR0327) that until i have understood is compatible as arduino leonardo.

the arduino works great, i even have a lcd display working without any problem, but the sd card reader don't seem to work so well, i have connected it to the icsp pins, taking like number one the closest to reset button and border, changed the jumper quite few times and don't seems to be the problem. The most crazy thing is that when i reset the arduino it randomly trow a correct initialization but when i reset or turn it off and on later it stop working, if i have to give a statistic, i would say it works one every 30 times or more. i also discard the shield being broken because eventually it work and the red led is turn on.

what could it be? may something in the connection be wrong?
for your answer, thanks

p.s. just working around with it, somehow, if i take off the sd card of the reader everything go well, but if i put the sd card on the failure keep coming.
By Leff
#8945
Hi ecangis,

Sorry for the late reply.

I checked with the expansion shield schematic that the SPI interface are connected to Raspberry Pi's SPI interface but not leonardo, so as the IIC interface (I am not sure what kind of LCD you r using with?), could you tell me your code for SD card module?
By ecangis
#8955
yeah, hi, respected to the spa connection i have all connected to the icsp pins on the board, which should correspond to the arduino board if i'm not wrong, maybe i made a mistake talking of spi.

respecte to the code my hole code is the next:
Code: Select all
 #include <SPI.h>
#include <SD.h>
#include <LiquidCrystal.h>

//constantes
Sd2Card card;
SdVolume volume;

File root;
char* files[1];

int Sdpin = 8;
int Irpin = 9;
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
int x=0;

void setup() {
  //Start serial connection and pin setup

  Serial.begin(9600);
  pinMode(Irpin, INPUT);
 
  //begin lcd screen
 
  lcd.begin(16, 2);
 
  lcd.clear();
  lcd.print("Iniciando");
  lcd.setCursor(0,1);
  lcd.print("sistema");

  //Try connect sd card
 
  if(!card.init(SPI_HALF_SPEED, Sdpin)){
    lcd.clear();
    lcd.print("Sin conexion con");
    lcd.setCursor(0,1);
    lcd.print("tarjeta Sd");
  } else {
    lcd.clear();
    lcd.print("Tarjeta Sd");
    lcd.setCursor(0,1);
    lcd.print("iniciada");
    delay (1500);
    lcd.clear();
  }
 
}

void loop(void) {

}


any help would be mostly appreciate, thanks so much.
By Leff
#8959
Hi,

Sorry for my belated answer. I think this is the problem:

SPI: on the ICSP header. These pins support SPI communication using the SPI library. Note that the SPI pins are not connected to any of the digital I/O pins as they are on the Uno, They are only available on the ICSP connector. This means that if you have a shield that uses SPI, but does NOT have a 6-pin ICSP connector that connects to the Leonardo's 6-pin ICSP header, the shield will not work. From Arduino

And I tested with your code (with a little modification) and get this MicroSD card module for Arduino working on Leonardo

Code: Select all
#include <SPI.h>
#include <SD.h>
#include <LiquidCrystal.h>

//constantes
Sd2Card card;
SdVolume volume;
SdFile root;

char* files[1];

int Sdpin = 8;
int Irpin = 9;
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
int x = 0;

void setup() {
  //Start serial connection and pin setup

  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  pinMode(Irpin, INPUT);

  //begin lcd screen

  lcd.begin(16, 2);

  lcd.clear();
  lcd.print("Iniciando");
  lcd.setCursor(0, 1);
  lcd.print("sistema");

  //Try connect sd card

  if (!card.init(SPI_HALF_SPEED, Sdpin)) {
    Serial.println("not found SD");
    lcd.clear();
    lcd.print("Sin conexion con");
    lcd.setCursor(0, 1);
    lcd.print("tarjeta Sd");
  } else {
    Serial.println("found SD");
    lcd.clear();
    lcd.print("Tarjeta Sd");
    lcd.setCursor(0, 1);
    lcd.print("iniciada");
    delay (1500);
    lcd.clear();
  }

}

void loop() {

}


Wiring

(108.71 KiB) Downloaded 543 times


ICSP interface:

(3.39 KiB) Downloaded 7842 times


After I opened the Serial Monitor, I could see the found SD message. Or please Format your TF/SD card to FAT(default)

(2.5 KiB) Downloaded 7842 times