netduino


Netduino + Ethernet Shield: How to write to SD card?


I have tried several example programs to write data to the SD card mounted on the Ethernet shield, but none worked. The SD card size is 4 GB and formatted as FAT32.
The Ethernet shield is the following:
(Bought on Amazon - Arduino Ethernet Shield)
And this is example code that doesn't work when creating a Netduino application (not Netduino Plus application) (thefirst line throws an exception):
public static void Main()
{
StorageDevice.MountSD("SD1", SPI_Devices.SPI1, Pins.GPIO_PIN_D10);
string[] directories = System.IO.Directory.GetDirectories(#"\");
Debug.Print("directory count: " + directories.Length.ToString());
for (int i = 0; i < directories.Length; i++)
{
Debug.Print("directory: " + directories[i]);
}
string[] files = System.IO.Directory.GetFiles(#"\SD1");
Debug.Print("file count: " + files.Length.ToString());
for (int i = 0; i < files.Length; i++)
{
Debug.Print("filename: " + files[i]);
FileStream fs = new FileStream(files[i], FileMode.Open, FileAccess.Read, FileShare.None, 512);
StreamReader sr = new StreamReader(fs);
Debug.Print("contents: " + sr.ReadToEnd());
}
}
Is there a example working program?
Solution:
Thanks to Chris and James, I managed to write to the SD card and read from it. After putting everything together, I wrote an article, in case anyone else faces the same issues.
The latest revision of the Arduino Ethernet Shield uses the "ICSP" header (3x2, 6-pin header on right side of board) to communicate. The input/output data going to your SD card is going over those pins.
We've included these same headers on the Netduino for compatibility; to use this shield, you'll want to solder the appropriate header onto your Netduino. Then you should be good to go!
BTW, Netduino Plus has integrated MicroSD and fast Ethernet networking...which may be an easy solution as well. http://www.netduino.com/netduinoplus/
Chris (Secret Labs LLC)
I found a reference on this forum page http://forums.netduino.com
"you'll currently need to put a jumper wire between D10 and D4 to get
the SD card to work--although that will not be necessary with the
production v4.1.1 firwmare (which will let you specify the SD card's
chip select line)."
Which makes me think that you need to use D4 instead of D10 for the SD Card. I found some other references on the same page that mentioned D10 is the SS pin for the Ethernet. The Firmware available on their download page is currently only 4.1.0 so you will probably need the jumper. I can't test this but the forum link should be a good starting point.

Related Links

Is it possible to programmatically power on/off the 3V3?
Netduino or Gadgeteer running IIS and ASP.NET MVC
Netduino + Ethernet Shield: How to write to SD card?

Categories

HOME
classification
leaflet
service
postgresql-9.3
openacc
python-requests
ibm
liquibase
postsharp
sms
promotions
fetch
guidewire
http-status-codes
expo
tmux
logstash-configuration
vala
tcpdf
quality-center
ps
nsopenpanel
bytebuffer
csproj
ipython-parallel
lines
oracle-nosql
android-scrollview
n1ql
dropdownbox
cocoa-scripting
gstreamer-1.0
client-server
nscollectionview
monaca
skype-bots
xamarin-test-cloud
was
scanf
universe
hdr
jigsaw
nsoperationqueue
pebble-js
radar-chart
trendline
clear
yfiles
gtkwave
pushwoosh
vspackage
valdr-bean-validation
nfa
mathics
sony-xperia
static-files
caption
growl
pnunit
azure-worker-roles
im4java
triplestore
visual-studio-setup-proje
android-relativelayout
webshim
nodeunit
adabas
sygic
angularjs-select2
typography
extensibility
usersettings
bho
dnsbl
linqdatasource
correctness
gssapi
expresso-store
big-endian
mysql-connector
wdm
rjs
parallel-python
overlays
table-valued-parameters
managed-code
vista64

Resources

Encrypt Message