Arduino Uno + Enc28j60 Ethernet failed - SOLVED

Hello, I'm trying to setup the Enc28j60 Ethernet module with the Arduino uno. I followed This Page which is on the Arduino link to the "T" in wiring as well as library and Sketch. But for some odd reason. I can not get the Ethernet to work. I'm also using the Arduino IDE version 1.8.16. I'm not sure what else to do I looked and looked all over But so far no fix. Can someone please help me out to figure this problem on why I can not get it to work.

I'm running the Be Back soon Example from the Library I'm posting below. Only thing I have changed was the Ip address to 244 from 200. Everything else remains the same. Also there is no error in compiling and upload.

// Present a "Will be back soon web page", as stand-in webserver.
// 2011-01-30 <jc@wippler.nl>
//
// License: GPLv2

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

// ethernet mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

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

  // Change 'SS' to your Slave Select pin, if you arn't using the default pin
  if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 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);
  }
}

Edit: I did put the ethernet wire into my laptop and Got a Ip address and I got onto the internet with no problem. So I know the connection ethernet wire works.

Joseph

Hello, Just a update. I couldn't get it to work and more looking around and saw that it needs the ss pin that is showing on D8 needs to be on D10. When I did that I was able to reset it and got a Ip address of 192.168.1.22. But the static Ip address I put on it is 192.168.1.200. I'm not sure why I can not get that Ip address to run.

Joseph

Maybe because of #define STATIC 0 which will result in the below part of your code being executed.

Change to #define STATIC 1 and it might work.

To debug a bit more, add serial prints; something like below.

#if STATIC
  Serial.println("Using static IP");
  ether.staticSetup(myip, gwip);
#else
  Serial.println("Using dynamic IP");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");
#endif

Hello Sterretje, Thank you so much. That part I didn't even notice. I was trying not to bang my head on my desk. Again Thank you it works now.

Joseph