Reputation: 341
I've designed a board based on the Arduino Mega, which uses a WizNET Ethernet shield and the included SD card reader. Using the standard Ethernet-library and SdFat works fine.
Now I've changed my hardware design to use the ENC28J60 Ethernet board from ElecFreaks and the ElecFreaks SD card breakout board. The decission was made to have a better ability to design a case that can be mounted to a DIN rail in an electric cabinet. I've stayed with SdFat, but I had to use the EtherCard library to talk to the ENC28J60.
I've used Pin 13 and Pin 14 of the mega for my chip select lines and wired the two boards to the SPI bus. Both boards alone work perfectly using the example files from the library. I read my configuration from a file on the SD card and set my Ethernet up with the values from the files. So far so good. The SD card is accessed correctly and the Ethernet board responds to ping requests. The problem now is that it seems that I can't make a TCP request with the Ethernet board.
How can make these two boards work together?
Here's some code which should do the trick, but it doesn't.
//Initial request
char request_uri[] = "/foo/bar/";
Stash::prepare(PSTR("GET $F HTTP/1.1" "\r\n"
"User-Agent: arduino/1.5.2" "\r\n"
"\r\n"),
request_uri);
ether.copyIp(ether.hisip, target_ip);
ether_sessionID = ether.tcpSend();
request_timer = millis() + REQUEST_TIMEOUT;
//And in the loop
ether.packetLoop(ether.packetReceive());
//Function called after initial request in loop (different state)
void checkTcpResponse() {
const char* reply = ether.tcpReply(ether_sessionID);
if (reply != 0) {
Serial.println(reply);
}
else {
if (millis() > request_timer) {
Serial.println("Timeout reached");
state = STATE_RESET;
delay(1000);
}
}
}
//This is just cut from the code, so it is not complete, etc.
While doing the request I'm watching the access.log of the connected Webserver. Nothing happens :( As said before, with the WebClient example of the EtherCard library the request to the given Webserver works and shows up in the log.
Upvotes: 0
Views: 2120
Reputation: 11
I know you asked this question a year ago but nobody seems to have given you any help.
I've come across a similar problem using the enc28j60 Ethernet Card alongside an SD Card. Both worked individually but not together.
I solved the problem but using a separate power supply to give me 3.3volts.
I used one of those breadboard power supplies which give both 3.3 & 5 volts.
I still had some problems whilst I connected through the breadboard.
I think the breadboard connection was a bit dodgy so I solved this by taking the power directly from the additional supply pins.
There was enough power to supply a Real Time Clock and LCD display as well at 5 volts.
You've probably solved your problem by now but someone else may find this useful.
Upvotes: 1