SD-Card adapter on Uno working, on Nano Every not working

Hi,

I have spend numerous hours on this problem now, hope someone can help me figuring out the problem. I'm building a larger system but I have reduced the problem to just a controller and a SD-card adapter.

What I have working; Arduino Uno with connected a HW-125 micro sd-card adapter. Connected the wires to pins D10 to D13 (SS, MOSI, MISO and SCK). Used the standard example sketch SD->CardInfo. Modified the "const int chipSelect = SS" to "const int chipSelect = 10" to be sure the sketch uses pin D10 for Chip Select signal. I uploaded the sketch and the serial monitor indicates the card is connected and it lists some card info and it lists the files on the sd-card. Perfect.

What I don't have working; Arduino Nano Every with the same HW-125 sd-card adapter. I have added the library for Arduino mega AVR board to be able to select the Arduino Nano Every board. Plugged the device to another USB port on the laptop but also changed the port in the software and serial monitor. Wired the HW-125 to the same pins (D10 to D13) as I did with the UNO. Further using the same sketch as used for the UNO and using the same sd-card.

Simple picture of hardware setup:

Pinning of both controllers:

The sketch:

/*
  SD card test

  This example shows how use the utility libraries on which the'
  SD library is based in order to get info about your SD card.
  Very useful for testing a card when you're not sure whether its working or not.

  The circuit:
    SD card attached to SPI bus as follows:
 ** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila
 ** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila
 ** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila
 ** CS - depends on your SD card shield or module.
 		Pin 4 used here for consistency with other Arduino examples


  created  28 Mar 2011
  by Limor Fried
  modified 9 Apr 2012
  by Tom Igoe
*/
// include the SD library:
#include <SPI.h>
#include <SD.h>

// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile 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
// MKRZero SD: SDCARD_SS_PIN
const int chipSelect = 10;

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


  Serial.print("\nInitializing SD card...");

  // we'll use the initialization code from the utility libraries
  // since we're just testing if the card is working!
  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card inserted?");
    Serial.println("* is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    while (1);
  } else {
    Serial.println("Wiring is correct and a card is present.");
  }

  // print the type of card
  Serial.println();
  Serial.print("Card type:         ");
  switch (card.type()) {
    case SD_CARD_TYPE_SD1:
      Serial.println("SD1");
      break;
    case SD_CARD_TYPE_SD2:
      Serial.println("SD2");
      break;
    case SD_CARD_TYPE_SDHC:
      Serial.println("SDHC");
      break;
    default:
      Serial.println("Unknown");
  }

  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
    while (1);
  }

  Serial.print("Clusters:          ");
  Serial.println(volume.clusterCount());
  Serial.print("Blocks x Cluster:  ");
  Serial.println(volume.blocksPerCluster());

  Serial.print("Total Blocks:      ");
  Serial.println(volume.blocksPerCluster() * volume.clusterCount());
  Serial.println();

  // print the type and size of the first FAT-type volume
  uint32_t volumesize;
  Serial.print("Volume type is:    FAT");
  Serial.println(volume.fatType(), DEC);

  volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
  volumesize *= volume.clusterCount();       // we'll have a lot of clusters
  volumesize /= 2;                           // SD card blocks are always 512 bytes (2 blocks are 1KB)
  Serial.print("Volume size (Kb):  ");
  Serial.println(volumesize);
  Serial.print("Volume size (Mb):  ");
  volumesize /= 1024;
  Serial.println(volumesize);
  Serial.print("Volume size (Gb):  ");
  Serial.println((float)volumesize / 1024.0);

  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  root.openRoot(volume);

  // list all files in the card with date and size
  root.ls(LS_R | LS_DATE | LS_SIZE);
}

void loop(void) {
}

The main question; is there a difference in the Every compared to the Uno what could be the issue that I'm not getting sd-card working on the Every? Could it be a hardware issue? Is it a software (spi) library issue?

Thanks for any help or suggestions. If additional info is needed then please let me know.
Arjen.

(first post on this forum, hope I did it right)

The biggest difference between these boards is the power output. On the UNO board even the USB connector is bigger. Compare voltages. The SD card needs a good amount of power.

For low-speed and small-capacity SD cards, power consumption is often less than 100mA.

With the advent of 8, 16, and 32GB high-speed SD cards, 300 to 400mA of power consumption has been common

Source: https://www.elinfor.com/knowledge/efficient-power-supply-methods-for-sd-flash-memory-of-smart-phone-p-11010

Hi rtek1000, thanks for your reply.
I was not aware of such power consumption, thanks for this info, good to know.

Reading (again) the Every datasheet I see that the power tree of the Every indicates that for user application 950 mA is available. This should be enough for the sd card I think.

Some measurements; voltage from the UNO is exactly 5.0, voltage from the Every is 4.7. With the Every connected I measure 3.3 volts on the power regulator on the HW-125 adapter. Think this is as expected.

I connected an external power supply (via 7805 regulator) to the HW-125 adapter. Power is 4.9 volts. Also 3.3 volts measured on the sd card adapter power regulator. For the application it makes no difference, still no sd card detected.

Other suggestions, hints, tips, are much appreciated. Thanks.

Sorry, it was my fault, I didn't see that the board is Nano Every, what I said earlier is valid for the Nano board, not Nano Every.

However, about the current capacity of the computer's USB port, it should be around 500mA only.

I know that the SD card is usually used with some pullup resistors, but as your adapter board already worked with the Arduino UNO, I believe that would not be the problem.

50k pull-up resistors are essential, even for the pins that are not being used for SPI communications

Source: http://hades.mech.northwestern.edu/index.php/Interfacing_with_a_Secure_Digital_(SD)_card

As I don't know the Nano Every board, I can't say, but it could be a matter of other services or interruptions interfering with the access times to the SD card, this is very common in 1-wire communication.

I'm going to do some research on this Nano Every model to see if I can tell you any testing suggestions.

So far I found this post below with "Nano Every" and "SD card", but I couldn't see the code because I don't have the login, it might be interesting to check with the developer of the SD card library you are using, if that library is compatible with this Nano Every board.

Arduino NANO Every, review, launch, tests, how to, and.... problems

I searched the Issues, but I didn't find any references to Nano Every, I believe you can ask there about the compatibility of the library with the Nano Every board:

https://github.com/arduino-libraries/SD

Thanks for the research, much appreciated, I will keep it in mind to ask for library compatibility.

I did a test with a 4 channel scope. First picture is from the UNO connected to the sd card module. This looks very good. CH1 (yellow) = CLK, CH2 (cyan) = MISO, CH3 (magenta) = MOSI, CH4 (blue) = CS.

Next picture is from the Every, clearly something is not good.

Could this be the pull-ups issue? But that would mean the UNO has pull-ups enabled and the Every not? Could I just try to connect the 4 signal lines with a resistor to the +5V?

2 Likes

Added 4 pull-up resistors to the 4 signal lines. Now getting this picture. :roll_eyes:

2 Likes

I'm glad you have the proper tools to debug your hardware.

The graphics for the Every model are really not good at all.

It may be necessary to analyze the Every microcontroller datasheet and make some changes to the low-level library, which makes the conversation between the functions used in the Arduino IDE and the low-level functions of the microcontroller.

I saw now that they are announcing version 2.0 with more emphasis, so it occurred to me to ask you if this problem also occurs using version 2.0 of the Arduino IDE.

Possibly who can help you is the Arduino IDE developer, I'll leave the repository here so that maybe you can contact them to evaluate if this is a bug to be fixed:

Bugs & Issues

If you want to report an issue, you can submit it to the issue tracker of this repository. A few rules apply:

  • Before posting, please check if the same problem has been already reported by someone else to avoid duplicates.
  • Remember to include as much detail as you can about your hardware set-up, code and steps for reproducing the issue. Make sure you're using an original Arduino board.

Will need to find some time to give it a try, but thanks for your feedback! I appreciate this.
Yes, the scope is nice tool to have and fun to use.

1 Like

@arjen8888
I face a very similar problem to you.
And I find that nano series has a quite unique design, the 5V output is disenabled by default.
Please Google "Arduino nano 5V output" and you will find more explanations.
Hope this can help you!

Hi, thanks for your message. I do not find direct hits on 5V power being disabled for the Nano Every. Is this issue also applicable for the Every? Could you help me with some direct links to the explanations you are suggesting? Thanks.

Dear Arjen,

Sorry to hear that, seems that my solution doesn't apply to Every as Every is different from BLE 33.
Hope you can find the solution.

Same problem overhere,
The basic SD library is not working with the Sparkfun Levelshifting Micro SDcard adaptor wired to the nano every. (checked the wiring at least 6 times, over multiple days so that's not the problem). Don't have any advanced checking tools. However have somer resistors, but I don't know how or why you would need pullup resistors. (Also don't really see if that was your solution or just something moving you in the right direction?) Thanks in advance and will post if I find anything usefull.

Update, Found something. First of all you should reïnstall de SD Library (program files/arduino/libraries/SD , Delete and reinstall using lib manager or github file).
Secondly something is still wrong with the card detect, if I don't use it (put all ref in comment it works). Maybe somebody smarter can figure out what's going on? Thanks in advance!

1 Like

Hi, that you have something working with commenting the card detect is I think a good indication that the issue is more software related than hardware. Good job that you figured this out and thanks for sharing. I have some other things to do at this moment but when I have the opportunity I will have a go on this.

Note: the pullup resistors were just for trying, I did not really expect this would be the problem or solution.

Additional info or if someone else got the Every working with a SD card, please share your solution, thanks.

1 Like

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