0

Using a knockoff Arduino Nano (pinout seems to be the same), I would like to record data to an external SD card. I have everything hooked up (correctly I think) but I continue to fail to initialize the card using SD.begin().

Here's a snippet of code that I'm running to do this:

//Wire and MS5803_I2C libraries for communicating with the pressure sensor. 

#include <Wire.h>               
#include <SparkFun_MS5803_I2C.h>
// For the SD card reader.
#include <SPI.h>               
#include <SD.h>              

const int chipSelect = 4;

void setup(void) {
  Serial.begin(9600); // Set baud rate.
  pinMode(10, OUTPUT); // Set data output pin for the SD card reader.
  digitalWrite(10, HIGH);
 // see if the card is present and can be initialized:
 if (!SD.begin(10)) {
   Serial.println("Card failed, or not present");
   // don't do anything more:
   return;
 }
 Serial.println("card initialized.");
  delay(500);  // Wait half a second before continuing.
}

void loop(void) {
  Serial.println("Hello Library!");
  delay(100000);
}

Here's the Nano pinout:

enter image description here

And a picture of the circuit.

enter image description here

3
  • 1
    Which version of the SD library are you using? This can be found at Sketch > Include Library > Manage Libraries... > Filter your search... > SD.
    – per1234
    Jan 22, 2017 at 3:43
  • I was running 1.0.8, but I just noticed there was an update. I'll try that out now that the library is updated! Thanks - I didn't know how to do that. Jan 23, 2017 at 1:16
  • I was asking because there was a bug in 1.1.0 that was causing this sort of problem and was fixed in 1.1.1 but since you were using 1.0.8 that wouldn't have been your issue.
    – per1234
    Jan 23, 2017 at 2:28

2 Answers 2

1

The Sparkfun pressure sensor has a 3.3V chip and a SD memory card is also 3.3V. Your Arduino Nano is probably a 5V board. How did you connect those to the board ?

When your Nano board is 5V, you need a SD module with a level shifter for the signals.

To make it work, test either the SD or the sensor and try to make it work. When testing the SD, don't connect the sensor and don't even include the sensor library.

2
  • I've been trying to upload a picture, but it keeps failing on both this site and imgur. Any suggestions? - I might make a schematic later today and upload it. Also, no sensor is currently attached, and this code is much simplified from a larger code-base but you're probably right, I should take out the sensor library for now - good suggestion. Jan 22, 2017 at 22:46
  • Alright, I added a photo of the setup currently. Jan 23, 2017 at 1:52
0

Is it my eyes or there's nothing connected to D4...?

const int chipSelect = 4;

Your chipSelect/CS pin seems connected to D10.

1
  • Yes, that's a remnant of the previous code. !SD.begin(x) allows for chipSelect to be entered as x. Here I have it as 10, which as far as I can tell is the actual CS on the device. What I'm wondering is if it is !CS and if that is different from the regular Arduinos Jan 23, 2017 at 5:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.