Go Down

Topic: SD card read/write with Arduino (Read 220147 times) previous topic - next topic


Mr. Orange,

Thanks.  I plan to use to log a battery charging session to see what the profile is on my DeWalt battery charger.

Any chance you would post the real time clock circuit you have on there?




Nov 05, 2008, 01:46 pm Last Edit: Nov 05, 2008, 04:41 pm by zumbi Reason: 1

I'm trying to interface arduino uC to a microSD card thru pin 8-13 and GND.

I have been googling and i found this post, ladyada's code[1] based on roland's code[2] and some arduino's vendor code[3].

I have not been able to use SD card yet. The closest i got it is with this post and ladyada's code, but i can not initialize correctly the SD card.

As i read in this post, some people is having same issues, did you resolve it?

I'll be waisting some time on this and kick it, if somebody wants to join, it is welcome.

(I can not post active links)



Code: [Select]

Data sampling system                                
send r to read disk                                  
send s to start sampling
send q to stop sampling
MMC/SD initialization failed

How should i format SD card? I have tried without partitions and with FAT16


Can you use this with a micro sd card?


No, I have not been able to use it yet. It compiles safely but it does not initialize the SD card, so I can not write nor read from it.


I don't think it will work with microSD. According to wikipedia the SPI mode that this library uses is optional for microSD but required for SD:


How hard would it be to use the SD mode instead of SPI? And what about SDHC support?


Dec 11, 2008, 03:12 pm Last Edit: Dec 11, 2008, 03:13 pm by dbunting Reason: 1
this might be an incredably stupid question, but im new here.
(you can thank ladyada her GPS data logger kit got me addicted)

someone mentioned using the SD card as a 1gig EEPROM.
would it be possible to use the SD card as the storage location for the sketch code?

maybe in a dual core setup. using one arduino as the access medium to the SD card and then having the second arduino execute the resulting code from the first?

like i said probebly a really stupid question, but im still new, and a bit of a dreamer


Dec 11, 2008, 04:13 pm Last Edit: Dec 11, 2008, 04:13 pm by kg4wsv Reason: 1
would it be possible to use the SD card as the storage location for the sketch code?

Technically, since the ATmega is capable of self-programming, the answer is yes.

Practically, the answer is no. Since there is no way to run code from the external device, you would be required to copy code from the SD card to flash, run the code, then reprogram the flash with whatever code you need to run next.  This is slow, complicated, and the flash has a limited number of write cycles, which means the ATmega would die an early death.

maybe in a dual core setup.

I think this has more potential, but not in the way you say.  The dedicated ATmega would provide  FAT filesystem support and interface to the SD card.  FTDI has already done this with the Vinculum, although with a USB interface and not directly to SD.



Dec 11, 2008, 04:38 pm Last Edit: Dec 11, 2008, 04:57 pm by dbunting Reason: 1
now is there no way because the arduino isnt currently capable (ie not part of the core code) if thats the case could a custom core be written.

or is there no way because of the technical limitations of the chip and execution enviroment?

and why limit it to fat if raw works fine?


and why limit it to fat if raw works fine?

Because raw is difficult to deal with if you want to pop the SD card out of the arduino and put it into a computer to exchange data.  If you use FAT on the SD card, you already have FAT filesystem drivers on all major operating systems.  If you use some raw format, you must write custom code for every possible operating system that you wish to exchange data with.



If we could store the code on the SD card then could we make it able to have 2 sets of code files and a switch to switch between them and their code?


AVR 8-bit microcontrollers are (modified) harvard architecture. that means that the program and data memory are completely separate except for the special ability to load program data into ram such as string constants, so you can't load anything into ram then run it as if it was code, like you can on von neumann architectures such as desktop PCs.

This basically means that we can only use SD for data. If you want to store code on one, you will have to write your own language and interpreter, or use a microcontroller with a von neumann architecture instead of the atmega168 on your arduino.


Sorry, Triffid, but as I said the ATmega is capable of self-programming, so yes it is technically possible for it to pull code from the SD card, write it to flash, and execute it.  This really isn't any different conceptually  from pulling the data from a serial port and writing it to flash, which is exactly what the Arduino bootloader does for us, allowing us to program the ATmega without a hardware programmer.

As I said earlier I don't think it's terribly practical, but it absolutely is possible.



So back on topic... SD mode IO? SDHC support?



I do also experience som trouble after resetting Arduino. Everything works fine to read and write to the SD Card but after resetting the Arduino the SD Card data is blank.

Have you found any solution for this?



Zumbi, I am having the same problem as you. I cannot get the SD card to initialize. If anyone has some pointers I would be grateful. :    ::)

Go Up