Documentation is bad sometimes.
Sometimes you just want to tear your hair out when the documentation of a product is WRONG. Something I ran into recently when trying to attach an enc28j60 from Hanrun to my genuine Arduino. I have used the ethernet shield on the Arduino without a hitch. So I supposed there would be no problem again... So I thought. Followed the map for hooking the two devices together as follows:
VCC - 3.3V
GND - GND
SCK - Pin 13
SO - Pin 12
SI - Pin 11
CS - Pin 8
Downloaded the latest Arduino and Ethercard software. Loaded both of them on the computer. Imported code for a simple web server.
// Present a "Will be back soon web page", as stand-in webserver.
// 2011-01-30 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
#include <EtherCard.h>
#define STATIC 0 // set to 1 to disable DHCP (adjust myip/gwip values below)
#if STATIC
// ethernet interface ip address
static byte myip[] = { 192,168,1,200 };
// gateway ip address
static byte gwip[] = { 192,168,1,1 };
#endif
// ethernet mac address - must be unique on your network
static byte mymac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x28 };
byte Ethernet::buffer[500]; // tcp/ip send and receive buffer
const char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
"<head><title>"
"Service Temporarily Unavailable"
"</title></head>"
"<body>"
"<h3>This service is currently unavailable</h3>"
"<p><em>"
"The main server is currently off-line.<br />"
"Please try again later."
"</em></p>"
"</body>"
"</html>"
;
void setup(){
Serial.begin(9600);
Serial.println("\n[backSoon]\n");
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println( "Failed to access Ethernet controller");
#if STATIC
ether.staticSetup(myip, gwip);
#else
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
#endif
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
}
void loop(){
// wait for an incoming TCP packet, but ignore its contents
if (ether.packetLoop(ether.packetReceive())) {
memcpy_P(ether.tcpOffset(), page, sizeof page);
ether.httpServerReply(sizeof page - 1);
}
}
Then I proceeded to compile it. Actually I had used other bits of code that would not compile until used this code. Well I proceeded to compile the code using a static ip address and all was well or so i thought. Brought up a web page and obviously it did not work. So like any good tech, you go to the web to get an answer, There were suggestion to change the mac address, and even using the +5 volt line instead of the 3.3v line. All of which did not work. Eventually I found an article that said the ethernet shield module used the #10 line on the Arduino. The current configuration used the #8 line. What??? With nothing to lose, I used the #10 line instead of the #8 and viola everything worked with the 3.3v line being used. Whew that was a killer, Bad documentation will eat your lunch. Surprised I did not see that fix on the web, The new configuration is now:
Arduino Module
digital 12 SO
digital 11 ST
digital 13 SCK
digital 10 CS
3.5v Vcc
Gnd GND
So here are the results!
It seems to work with the Arduino mega also.
Comments
Post a Comment