ENC28j60 ethernet module does not work

Hi,

I bought an ENC28j60 module like the following:

I followed the tutorial and connected the module to my Arduino Uno. All leds blink, and I connected the module to my router.

After that I upload an example code to show a webpage.

However, when I go to my routers "Connected Devices" I don't see my Arduino module. Furthermore, a ping to my device could not reach its target.

I have used the same mask as my router (local network). I've triple-checked the wiring. Also, I've tried using DHCP to setup the device IP. Nothing worked :frowning:

Anybody an idea what's going on? Is the module broken and is it possible to check that? Is it possible to connect such module directly to my PC to try and connect as such, to test the module?

Thanks in advance!

The Etherner Shield with W5100 is officially supported by the Arduino.

The official Ethernet Shield is build with good components.

Your ENC28J60 might be broken, or something is wrong with connections.
It is not officially supported, but the Ethercard library is a good library.

You have to use the DHCP example by the Ethercard library, and see what the serial output of the Arduino is.
Can you copy the serial output of the DHCP example ?

Thanks a million!

It appears that at least the module is functioning. I get the following through serial back:

[testDHCP]
MAC: 74:69:69:2D:30:31
Setting up DHCP
My IP: 192.168.0.10
Netmask: 255.255.255.0
GW IP: 192.168.0.1
DNS IP: 192.168.0.1

However, when I do pin 192.168.0.10, I get "Destination unreachable". I assume this has something to do with some firewall settings on my router? Or is there a simpeler explanation?

Thanks again!

That is nice. Your router is talking to your Arduino.
The IP "192.168.0.10" is given by the router.

Can you make a sketch that uses both a webpage and DHCP.
Use this simple webpage:

And add the DHCP to it:

Instead of staticSetup(), you need the dhcpSetup().

If you have that running, type in your browser http://192.168.0.10

Can you see the local devices if you log into your router ? Your computer and Arduino should both be at 192.168.0.xxx

This looks like it's working great :slight_smile:

Dunno actually what I was doing wrong... I'm only happy that it's been solved!!

Thanks again!

PS: For reference, this is the completed code:

// This is a demo of the RBBB running as webserver with the Ether Card
// 2010-05-28 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = { 192,168,0,10 };

byte Ethernet::buffer[500];
BufferFiller bfill;

void setup () {
  Serial.begin(57600);
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
    
  Serial.println("\n[testDHCP]");

  Serial.print("MAC: ");
  for (byte i = 0; i < 6; ++i) {
    Serial.print(mymac[i], HEX);
    if (i < 5)
      Serial.print(':');
  }
  Serial.println();
  
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) 
    Serial.println( "Failed to access Ethernet controller");

  Serial.println("Setting up DHCP");
  if (!ether.dhcpSetup())
    Serial.println( "DHCP failed");
  
  ether.printIp("My IP: ", ether.myip);
  ether.printIp("Netmask: ", ether.mymask);
  ether.printIp("GW IP: ", ether.gwip);
  ether.printIp("DNS IP: ", ether.dnsip);
}

static word homePage() {
  long t = millis() / 1000;
  word h = t / 3600;
  byte m = (t / 60) % 60;
  byte s = t % 60;
  bfill = ether.tcpOffset();
  bfill.emit_p(PSTR(
    "HTTP/1.0 200 OK\r\n"
    "Content-Type: text/html\r\n"
    "Pragma: no-cache\r\n"
    "\r\n"
    "<meta http-equiv='refresh' content='1'/>"
    "<title>RBBB server</title>" 
    "<h1>$D$D:$D$D:$D$D</h1>"),
      h/10, h%10, m/10, m%10, s/10, s%10);
  return bfill.position();
}

void loop () {
  word len = ether.packetReceive();
  word pos = ether.packetLoop(len);
  
  if (pos)  // check if valid tcp data is received
    ether.httpServerReply(homePage()); // send web page data
}

Hi guys,

I had the same problem, but I didn't have success when I tried the testDHCP.ino.
Here is my result:

[testDHCP]
MAC: 74:69:69:2D:30:31
Setting up DHCP
DHCP failed
My IP: 0.0.0.0
Netmask: 0.0.0.0
GW IP: 0.0.0.0
DNS IP: 0.0.0.0

So what I can do to fix that?

Thanks,