Arduino Uno + enc28j60 - still not working

Hello everyone,

I'm trying to connect my Arduino Uno to the enc28j60 Ethernet module. The wiring seems to be right (it was made like this:

VCC -   3.3V
GND -    GND
SCK - Pin 13
SO  - Pin 12
SI  - Pin 11
CS  - Pin  8

The red and green LED on the ethernet module are on, the yellow LED is blinking sometimes

The router I use is D-Link DIR-300, standard firmware, the ethernet cable from the ENC is plugged to one of the LAN ports of the router.

The library used is EtherCard, the test sketch "BackSoon" was taken from one of the tutorials (so the problem must be not in the code):

// 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,0,200 };
// gateway ip address
static byte gwip[] = { 192,168,0,1 };
#endif

// ethernet mac address - must be unique on your network
static byte mymac[] = { 0xDD,0xDD,0xDD,0x00,0x00,0x01 };

byte Ethernet::buffer[500]; // tcp/ip send and receive buffer

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.
"
      "Please try again later."
    "</em></p>"
  "</body>"
"</html>"
;

void setup(){
  Serial.begin(57600);
  Serial.println("\n[backSoon]");
  
  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);
  }
}

The device IP adress was set to 192.168.0.200 as there's no other device with this IP, the MAC was taken from one of the sketches (there must be no devices with such MAC in my network). The gateway was set to the same IP adress as I use to open my router control panel (is it right?).

The result is, sometimes after the [BackSoon] the serial monitor shows nothing, sometimes it ends with "DHCP Failed". If I use the static IP (#define STATIC 1), in the Serial Monitor the IP, GW and MAC are shown, the same as I've set up previously, but going to this IP from the browser (or pinging it) from my PC gives no result.

Can anybody help me with such issue? Have read a lot, and still haven't found anything useful for my case.

PS The IDE I've tried to use are 1.0.4 and 1.0

Thanks.
Paul.

Do you have a link on the router? (that's an led on the router showing that there is a physical connection between the two devices).

You don't need the gateway if you're just connecting from your LAN.

Sounds like my hair pulling sessions a few nights ago with the enc28j60. Turns out to be the mac address. Try some other ones.

dvo1:
Sounds like my hair pulling sessions a few nights ago with the enc28j60. Turns out to be the mac address. Try some other ones.

Hey, you are right! Previously I tried to change the MAC as well, took ones from different test sketches. But now I've used one of the "Random MAC Generators" on the web, entered the new MAC for the device and it works now!

Really, thanks a lot :slight_smile:

I am facing same problem with ENC28J60 module. I am also using EtherCard library. Will you please tell me what MAC address you used?? Is there any kind of format of this particular mac address? Please help me.. its urgent..! Thanks... :slight_smile: