Offline
Newbie
Karma: 0
Posts: 14
|
 |
« on: January 11, 2013, 11:55:57 pm » |
I bought a new experimental DK electronics ethernet shield because it had a place to solder components on. I then bought a separate SD card. Later i realised that i would need to use the SD card with the Ethernet Shield but they conflict on 11, 12 and 13. Is there a way to connect them both at the same time?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 50
Posts: 6526
Arduino rocks
|
 |
« Reply #1 on: January 12, 2013, 12:01:53 am » |
Test code for a w5100 shield with SD card. //zoomkat 12/26/12 //SD server test code //open serial monitor to see what the arduino receives //address will look like http://192.168.1.102:84 when submited //for use with W5100 based ethernet shields
#include <SD.h> #include <SPI.h> #include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address byte ip[] = { 192, 168, 1, 102 }; // ip in lan byte gateway[] = { 192, 168, 1, 1 }; // internet access via router byte subnet[] = { 255, 255, 255, 0 }; //subnet mask EthernetServer server(84); //server port String readString;
//////////////////////
void setup(){
Serial.begin(9600);
// disable w5100 while setting up SD pinMode(10,OUTPUT); digitalWrite(10,HIGH); Serial.print("Starting SD.."); if(!SD.begin(4)) Serial.println("failed"); else Serial.println("ok");
Ethernet.begin(mac, ip, gateway, gateway, subnet); digitalWrite(10,HIGH);
//delay(2000); server.begin(); Serial.println("Ready");
}
void loop(){ // Create a client connection EthernetClient client = server.available(); if (client) { while (client.connected()) { if (client.available()) { char c = client.read();
//read char by char HTTP request if (readString.length() < 100) { //store characters to string readString += c; //Serial.print(c); } //if HTTP request has ended if (c == '\n') {
/////////////// Serial.println(readString); //print to serial monitor for debuging
client.println("HTTP/1.1 200 OK"); //send new page client.println("Content-Type: text/html"); //client.println("Content-Type: image/jpeg"); //client.println("Content-Type: image/gif"); //client.println("Content-Type: application/x-javascript"); //client.println("Content-Type: text"); client.println();
//File myFile = SD.open("boom.htm"); File myFile = SD.open("HYPNO.JPG"); //File myFile = SD.open("BLUEH_SL.GIF"); //File myFile = SD.open("SERVOSLD.HTM"); if (myFile) { //Serial.println("test.txt:"); // read from the file until there's nothing else in it: while (myFile.available()) { client.write(myFile.read()); } // close the file: myFile.close();
} delay(1); //stopping client client.stop(); readString=""; //} } } } } }
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #2 on: January 12, 2013, 12:30:39 am » |
Test code for a w5100 shield with SD card. //zoomkat 12/26/12 //SD server test code //open serial monitor to see what the arduino receives //address will look like http://192.168.1.102:84 when submited //for use with W5100 based ethernet shields
#include <SD.h> #include <SPI.h> #include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address byte ip[] = { 192, 168, 1, 102 }; // ip in lan byte gateway[] = { 192, 168, 1, 1 }; // internet access via router byte subnet[] = { 255, 255, 255, 0 }; //subnet mask EthernetServer server(84); //server port String readString;
//////////////////////
void setup(){
Serial.begin(9600);
// disable w5100 while setting up SD pinMode(10,OUTPUT); digitalWrite(10,HIGH); Serial.print("Starting SD.."); if(!SD.begin(4)) Serial.println("failed"); else Serial.println("ok");
Ethernet.begin(mac, ip, gateway, gateway, subnet); digitalWrite(10,HIGH);
//delay(2000); server.begin(); Serial.println("Ready");
}
void loop(){ // Create a client connection EthernetClient client = server.available(); if (client) { while (client.connected()) { if (client.available()) { char c = client.read();
//read char by char HTTP request if (readString.length() < 100) { //store characters to string readString += c; //Serial.print(c); } //if HTTP request has ended if (c == '\n') {
/////////////// Serial.println(readString); //print to serial monitor for debuging
client.println("HTTP/1.1 200 OK"); //send new page client.println("Content-Type: text/html"); //client.println("Content-Type: image/jpeg"); //client.println("Content-Type: image/gif"); //client.println("Content-Type: application/x-javascript"); //client.println("Content-Type: text"); client.println();
//File myFile = SD.open("boom.htm"); File myFile = SD.open("HYPNO.JPG"); //File myFile = SD.open("BLUEH_SL.GIF"); //File myFile = SD.open("SERVOSLD.HTM"); if (myFile) { //Serial.println("test.txt:"); // read from the file until there's nothing else in it: while (myFile.available()) { client.write(myFile.read()); } // close the file: myFile.close();
} delay(1); //stopping client client.stop(); readString=""; //} } } } } }
No, i know how to use it but the ethernet shield and the SD card are separate.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 50
Posts: 6526
Arduino rocks
|
 |
« Reply #3 on: January 12, 2013, 12:33:40 am » |
bummer
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #4 on: January 12, 2013, 12:36:01 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Miramar Beach, Florida
Offline
Faraday Member
Karma: 49
Posts: 3441
|
 |
« Reply #5 on: January 12, 2013, 06:17:50 am » |
Have you tried to get them to work separately?
edit: They are going to share three lines on the SPI bus. Line Uno Mega MOSI D11 D51 MISO D12 D50 SCK D13 D52
Leonardo SPI is not on any digital pins. They are on the ICSP connector only.
Your ethernet shield appears to use the SPI lines on the ICSP connector if it has a 6 pin connector connecting to the ICSP pins on the Arduino.
|
|
|
|
« Last Edit: January 12, 2013, 06:29:17 am by SurferTim »
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #6 on: January 12, 2013, 02:01:39 pm » |
Have you tried to get them to work separately?
edit: They are going to share three lines on the SPI bus. Line Uno Mega MOSI D11 D51 MISO D12 D50 SCK D13 D52
Leonardo SPI is not on any digital pins. They are on the ICSP connector only.
Your ethernet shield appears to use the SPI lines on the ICSP connector if it has a 6 pin connector connecting to the ICSP pins on the Arduino.
I can get them to work separately. Idk how to wire it up though.
|
|
|
|
|
Logged
|
|
|
|
|
Miramar Beach, Florida
Offline
Faraday Member
Karma: 49
Posts: 3441
|
 |
« Reply #7 on: January 12, 2013, 02:06:14 pm » |
If you got that far, you are almost there. What digital pin are you using for the slave select on the SD module? Digital 10 is the SS for the w5100.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #8 on: January 12, 2013, 02:26:26 pm » |
Im using 4 for the CS on the SD card. the ethernet shield uses 2, 10, 11, 12, 13.
|
|
|
|
|
Logged
|
|
|
|
|
Miramar Beach, Florida
Offline
Faraday Member
Karma: 49
Posts: 3441
|
 |
« Reply #9 on: January 12, 2013, 02:30:39 pm » |
Are you sure zoomkat's code above did not work? Those are the correct pins.
The w5100 uses pins D2, D10, D11, D12, and D13. The SD uses D4, D11, D12, and D13.
Looks good to me.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #10 on: January 12, 2013, 02:33:56 pm » |
Im just about to use ribbon cable to connect them my nano board for testing.
|
|
|
|
|
Logged
|
|
|
|
|
Miramar Beach, Florida
Offline
Faraday Member
Karma: 49
Posts: 3441
|
 |
« Reply #11 on: January 12, 2013, 02:38:38 pm » |
Let me know how it does. If they work separately, and all works as normal, you should be ok with zoomkat's code above. 
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #12 on: January 12, 2013, 03:02:26 pm » |
Its still not working. I re-checked my wiring and its all connected with nothing crossed. With zoomkat's example, the SD card fails and then it prints "Ready" and then there is nothing more printed. With the ethernet webserver example, i get server is at 0.0.0.0 Is there a program i can use to log the digital pins?
|
|
|
|
|
Logged
|
|
|
|
|
Miramar Beach, Florida
Offline
Faraday Member
Karma: 49
Posts: 3441
|
 |
« Reply #13 on: January 12, 2013, 03:09:30 pm » |
With the ethernet webserver example, i get server is at 0.0.0.0 Then you have a SPI fail between the Arduino and the w5100. I use this for my server code. http://playground.arduino.cc/Code/WebServerST
|
|
|
|
|
Logged
|
|
|
|
|
|
|
|