Adafruit SD card reader issue with Arduino nano

Hello every one,

I come to you because I have been scratching my head with my project and I can't find the solution to my issue.

To give some context I am building a portable suspension datalogger for my mountainbike.
The first tests on breadboard with an arduino uno and an UNO sized SD card reader (same chip as adafruit device) works perfectly.
Now I say I'm ok with the program I can go smaller with an arduino nano and the adafruit SD card reader.
And now I keep getting an "Initialization failed!" error message.
I check the wiring everything seems fine.
I do a swap test between the nano and the uno, and the later is working perfectly with the new adafruit SD card reader, so this one is not the issue.
I do the opposit with the nano and the old SD reader and here it does not work.
I check again the nano wiring comparing with other project on the net made with Nanos thinking maybe some special wiring for this particular device is required and everything I see match my wiring.

And I'm stuck at this point were I don't know what to check further to troubleshoot my issue. ^^'
So here I am open to any ideas ^^

And which of the numerous variants of the Nano are you using? Nano is a form factor that can have one of many processors. I assume an AVR ATmega328 based one since you are comparing it with an UNO.

Everything should be the same, I/O-wise, Uno == Nano.

MicroSD's require a surprising amount of current. The capabilities of Nano's 5V (and 3V) are much less than the Uno's.

Yes I'm using one with the atmega328P and it has the old bootloader if it can help.
Do you think it would be a power issue?
I see that while being powered through the USB it can output up to 500mA on the 5V pin which should be plenty for the SD reader no?

Perhaps you could use a 5V supply you may have.
If it's plugged into a healthy USB then 5V is running from USB power.
If power is derived from "VIN" then there's the rub (← the much-limited onboard 5V reg)

I have a UNO and a Nano but I’m sure I won’t have whatever other modules/sensors are used in your project. But I’ll try your sketch on both as far as those limitations allow if you post it and a circuit schematic.

My memory is that the Adafruit SD module has both 3.3V and 5V power pin options. Which one are you using?

For runaway_pancake I use the port on my laptop he is not that young but not that beat up either haha. But if we say it is the 5v supply from my usb port who is flimsy it should affect the Uno also no?

For Terrypin,
So in both case (Uno or Nano) I have the following pinout
pin 10 -- CS
pin 11 -- DI
pin 12 -- DO
pin 13 -- clk
and I use the 5V as supply mainly, but to answer to ShermanP I also tried with the 3.3v on the Nano without sucess.
The missing sensors should not be an issue I also do all my test only with the SD reader pluged in at the moment.
I also add my complet code if it can help

// D7 for push button log start,D6 log start led, D3 calibration led, D2 calibration button, A0 for one suspension data input. Warning Calibration LED not programed
const int BUTTON_REC = 7;       // the number of the pushbutton pin
const int RECLED = 6;
const int BUTTON_CAL = 2;
const int CALLED = 3;
int buttonState = 0;
int lastButtonState = HIGH;     // the previous reading from the input pin
int calibration;
unsigned long myTime;
#include <SD.h>
#include<Wire.h>                            /* Load the library for I2C communication (for RTC module). By default already built-in with Arduino software*/
#include "RTClib.h"                         // Must download the library from manage library > type RTCLib by Adafruit
#include<SPI.h>
File myFile;

void setup() {
  Serial.begin(9600);
  pinMode(BUTTON_REC, INPUT_PULLUP);
  pinMode(BUTTON_CAL, INPUT_PULLUP);
  pinMode(RECLED,OUTPUT);
  pinMode(10, OUTPUT);

if (!SD.begin(10)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
}
void loop() {
  int readingrec = digitalRead(BUTTON_REC);
  int readingcal = digitalRead(BUTTON_CAL);
 int sensorValue=analogRead(A0);
   myTime = millis();
   if(readingcal == LOW){
    calibration = analogRead(A0);
    Serial.println(calibration);
    digitalWrite(CALLED,HIGH);
   }
   else{
    digitalWrite(CALLED,LOW);
   }
  if (readingrec != lastButtonState) {
    if (readingrec == LOW) {
      buttonState = !buttonState;  // Toggle the buttonState
    }
    delay(50);  // Debounce delay
  }
  if(buttonState == 1){
    if (myFile) {
    digitalWrite(RECLED,HIGH);
    Serial.println("Writing to test.txt...");
    myFile.print(myTime);
    myFile.print (",");
    myFile.print (sensorValue);
    myFile.print (",");
    myFile.print (calibration);
    myFile.print (",");
    myFile.println(buttonState);
    
    }else {
    myFile = SD.open("test.txt", FILE_WRITE);
    digitalWrite(RECLED,HIGH);
    Serial.println("INITIALIZING test.txt...");
    myFile.print(myTime);
    myFile.print (",");
    myFile.print (sensorValue);
    myFile.print (",");
    myFile.print (calibration);
    myFile.print (",");
    myFile.println(buttonState);
  }
    } 
    else{
      myFile.close();
      digitalWrite(RECLED,LOW);
      }

  lastButtonState = readingrec;
  delay(10);
}

If you're using USB to run the project, whether it's the Uno or the Nano shouldn't make a difference as they are running on USB (not from the onboard regulator - in either case).

When "VIN" is used is when the onboard regulator comes into play.

Yes, you should power the SD module with 5V.

After it has failed to initialize, then hit the Nano's reset button. Does it fail again? Are you using one set of jumpers for both the Uno and Nano?

If the connections are all the same, and the jumpers are good, and the code is the same for both, there's no reason the Nano wouldn't work as well as the Uno.

For the reset button I tried it and it gives always a fail.
Regarding jumper cables I do have different ones since I don’t have the same pin/header connexion welded on the uno and nano. I will try connecting the nano cables to the working uno/cable set to see if the nano ones might be the issue.

Ok, well I'm pretty much out of possibilities at this point, other than you just have a bad Nano, which I think is unlikely.

It seems that the likely issues are less and less ^^'
I just tested the jumper cables by connecting the Uno with its jumper cables to the Nano jumper cables and it works ^^'
I have another nano on hand but it has a burnt usb diode, so not a good idea to use it hahaha

What's the SD card reader mounted on? Is it an add on to a display? Or by itself?

It’s by itself. It is the adafruit MicroSD card breakout board+

Ok I'm more and more starting to think something is wrong with my nano ^^'. So I ordered a set of new ones (clones). Looking at it I stepped upon the nano every which is more powerfull and I have the possibility to have it in 24hours instead of the 2 weeks for the clones haha. My only question is that I see a lot of comment regarding the incompatibility due to the different chip, Does my code above need to be drastically updated or can it be used as it is for this nano every board?

As I suspected I found it impractical to work on anything close to your own code. So I would recommend that you switch (or at least add) the popular library DFRobotDFPlayerMini.h and see if that gets your tracks playing.

The sketch below is a simple example to get you started. Compiled and tested.

/* Uses software Serial on UNO/Nano/ etc, with DFR MP3 Player using
DFR's original library. Plays any single track in setup() and then
5 seconds of all othet tracks.
*/

#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;

void setup()
{
  Serial.begin(115200);
  delay(200);
  mySoftwareSerial.begin(9600);

  Serial.println();
  Serial.println(F("DFRobot DFPlayer Mini Demo"));
  Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));

  if (!myDFPlayer.begin(mySoftwareSerial, true, false))    //Use softwareSerial to communicate with mp3.
  {
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
    while (true);
  }
  Serial.println(F("DFPlayer Mini online."));

  myDFPlayer.volume(15);  //Set volume value. From 0 to 30
  myDFPlayer.play(1);  //Play the first mp3
  delay(1000);

  Serial.println("setup ended");
}

void loop()
{
  static unsigned long timer = millis();

  if (millis() - timer > 5000)
  {
    timer = millis();
    myDFPlayer.next();  //Play next mp3 every 5 seconds.
  }
}

Hello all, just to follow on my issue.
Impatient me just bought a new nano every to tryout and Bingo it works!
It initialize properly now.
So it seems my issue was coming from my old Nano.

Thanks you all for giving a helping hand!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.