I am trying, very long, to make the SD card module with the Arduino mini pro working! I tried a sdcard with 128mb and the wiring with MOSI and MISO but it dosnt work!
The connections:
GND to Arduino pro mini GND
VCC to Arduino pro mini VCC
MISO to pin 12
MOSI to pin 11
SCK to pin 13
CS to pin 10
but when i try to run it, the error message says:
Initializing SD card...initialization failed. Things to check:
* is a card inserted?
* is your wiring correct?
* did you change the chipSelect pin to match your shield or module?
I formatted the SD card with FAT32
I am trying like 6 Weeks...
I don't think the SD module circuit error will matter in this case. The module should work ok so long as there isn't another SPI device in the circuit. If it's just the Pro Mini and the SD module, it should work.
I think 128MB should be ok. I've used 256MB cards in the past with Arduinos and they worked fine. 128MB should be ok with FAT32. If it's actually 128GB, that might be a problem since FAT32 only goes to 32GB, and the basic Arduino libraries don't go beyond SDHC.
I wonder if D10 for CS is what his code says. Well, without seeing his sketch, we'd just be guessing.
I recall it was recommended to format the SD card using the SD org format program. download here.
I used it, it worked I have no knowledge if a windows FAT32 will be an issue.
This is my code I used to verify the SD card operation:
/*
SD card read/write
Mod 01 make file name a string and iterate until we find a unused file name.
Mod 02 add capability to increment filename.
Rev 03 tested successfully on Arduino M0
SD card attached to SPI bus on ICSP Header.
SD Board power = 5V (for large board with EEPROM)
based on code created: Nov 2010 by David A. Mellis, 9 Apr 2012 by Tom Igoe
This code is in the public domain.
driver has a 512 byte buffer then write to SD
Closing the file forces any buffered data to be written to the SD and also updates
the file's directory entry.
If you don't close the file, you will lose all data written the file since it was opened,
not just the last buffer, since the directory entry will not be updated.
*/
#include <SPI.h>
#include <SD.h>
// *** SD Card declarations **************************************************
// ***************************************************************************
#define SDCARD_CS_PIN 9
uint16_t fileNumb = 900;
char dataFile[8];
bool SD_Error = false;
File myFile; // create instance of a "File" class
void setup() {
SerialUSB.begin(115200);
delay (2000);
// Initializing SD card....
SPISettings mySetting(1000000,MSBFIRST, SPI_MODE0);
if (!SD.begin(SDCARD_CS_PIN))
{SerialUSB.print("initialization failed");
SD_Error = true;
}
// loop until we find a file that doesn't already exist.......
do
{
itoa(fileNumb, dataFile, 10); // (value, Array, base)
const char *extension = ".csv";
strcat(dataFile, extension); // syntax strcat(dest, source)
++fileNumb;
} while (SD.exists(dataFile));
SerialUSB.print("READY TO OPEN FILE FOR WRITING = ");
SerialUSB.println(dataFile);
myFile = SD.open(dataFile, FILE_WRITE); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
SerialUSB.println(myFile);
// if the file opened okay, write to it:
if (myFile) {
myFile.println("data from boiler"); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
SerialUSB.println("data from boiler");
//SerialUSB.print(" data written to file: ");
myFile.close(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
SerialUSB.println(dataFile);
}
else {
// if the file didn't open, print an error:
SD_Error = true;
}
SerialUSB.print("SD_Error = ");
SerialUSB.print(SD_Error);
}
void loop() {
// nothing happens after setup
}
I have had problems with the inexpensive SD card adapters not making good contact with the SD card. Removing and reinserting the SD card a time or two usually fixes it.
Is the wiring between the SD card adapter and the Pro Mini secure?