Arduino Uno with MINI ENC28J60 Ethernet can't connect to network

As the title says, I have an Arduino Uno Rev3 connected to an Mini Ethernet module ENC28J60.

Using the example Files > Examples > Blynk > Boards_Ethernet > ENC28J60 from the Blynk library version 1.0.1 by Volodymyr Shymanskyy I can’t succeed connecting it to internet. The wires were checked for continuity, the pinout used is the one in the example:

  Typical wiring would be:
   VCC -- 5V
   GND -- GND
   CS  -- D10
   SI  -- D11
   SCK -- D13
   SO  -- D12
   INT -- D2

The code I use (I’ve read somewhere that I can comment Blynk.run() until it connects):

#include <UIPEthernet.h>
#include <BlynkSimpleUIPEthernet.h>
char auth[] = "my_key";

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth);

  //Blynk.begin(auth, "blynk-cloud.com", 80);
  //Blynk.begin(auth, IPAddress(192,168,1,100), 8080);
}

void loop()
{
  //Blynk.run();
}

The output:

[0] Getting IP...
[60218] DHCP Failed!
[1] Getting IP...

The Ethernet wire works because when I connect my PC via ethernet it works, I can navigate on the internet.

I also tried to use the “manual” connection to internet as another example exists in this sense. The code used and my settings:

#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL-G0tCsqY"
#define BLYNK_DEVICE_NAME "D"
#define BLYNK_DEFAULT_PORT 80
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

char auth[] = "my_key";

IPAddress server_ip (192,168,10,20);

byte arduino_mac[] = { 0x43, 0x44, 0xB2, 0x07, 0xF8, 0x26};
IPAddress arduino_ip ( 192,   168,   100,  254);
IPAddress dns_ip     (192,168,100,1);
IPAddress gateway_ip (192,168,1,1);
IPAddress subnet_mask(255, 255, 255,   0);

void setup()
{
  Serial.begin(9600);
  //Blynk.begin(auth, server_ip, 8080, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
  // Or like this:
  Blynk.begin(auth, "blynk-cloud.com", 80, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
}

void loop()
{
  //Blynk.run();
}

The output

[0] Using static IP
[1580] IP:5.0.0.0
[1581] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.0.1 on Arduino Uno

[1692] Connecting to blynk-cloud.com:80

I want to connect the device via router. My router specs:

IPv4 Address. . . . . . . . . . . : 192.168.100.4(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.100.1
DHCP Server . . . . . . . . . . . : 192.168.100.1

I want to mention that for the second example I need to add Ethernet-master.zip library (because it doesn’t work only with Blynk) and for the first example I need to use UIPEthernet-master.zip. Also when I ping the Blynk cloud server I get the response from my computer.

This is the url for the legacy cloud servers.
The correct url for Blynk 2.0 is “blynk.cloud”

A gateway outside of your network range won’t work.

I don’t see how the code you’ve posted can produce this result. Are you sure the code and output match?

Pete.

Thank you very much for the fast respose. I modified the server address as you indicated.

this is the output:

[0] Using static IP
[1580] IP:0.0.0.0
[1581] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.0.1 on Arduino Uno

[1692] Connecting to blynk.cloud:80

for this code:


/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#define BLYNK_TEMPLATE_ID "TMPL-G0tCsqY"
#define BLYNK_DEVICE_NAME "Dragos"
#define BLYNK_DEFAULT_PORT 80

#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "key";

IPAddress server_ip (192,168,10,20);

// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0x43, 0x44, 0xB2, 0x07, 0xF8, 0x26};
IPAddress arduino_ip ( 192,   168,   100,  254);
IPAddress dns_ip     (192,168,100,1);
IPAddress gateway_ip (192,168,100,1);
IPAddress subnet_mask(255, 255, 255,   0);

void setup()
{
  // Debug console
  Serial.begin(9600);
  //Blynk.begin(auth, server_ip, 8080, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
  // Or like this:
  Blynk.begin(auth, "blynk.cloud", 80, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
}

void loop()
{
  //Blynk.run();
}

P.S I copy pasted everything except the key. This is the program compiled and uploaded on to my board. Now the ip is 0.0.0.0. after modifying the gateway to 192.168.100.1

Is your device connected directly to your router, or via a network switch?

Pete.

It is directly connected to my router (the single one).

And what happens if you change this:

To your preferred IP address of 104 rather than 254 ?

Pete.

[0] Using static IP
[1580] IP:5.0.0.0
[1581] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.0.1 on Arduino Uno

[1692] Connecting to blynk.cloud:80
... and so on

Have you tried rebooting your router?

Pete.

I just tried but no difference at all.

Can there be a mismatch between the pinout in the example and the pinout the library used? Also, I don’t understand why the ENC example (DHCP) won’t work by itself.

Also, regardin the 5.0.0.0 value from the ip. It is a strange thing, I searched on the internet for an example to set the MAC address on the Ethernet module, and to my surprize, the MAC was 5.0.0.0.0.

The code

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {123, 123, 123, 123, 13, 142};
IPAddress ip(10, 0, 0, 177);

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Ethernet.begin(mac, ip);

  byte macBuffer[6];  // create a buffer to hold the MAC address
  Ethernet.MACAddress(macBuffer); // fill the buffer
  Serial.print("The MAC address is: ");
  for (byte octet = 0; octet < 6; octet++) {
    Serial.print(macBuffer[octet], HEX);
    if (octet < 5) {
      Serial.print('-');
    }
  }

  Ethernet.setMACAddress(mac);
  Ethernet.MACAddress(macBuffer); // fill the buffer
  Serial.print("The MAC address is: ");
  for (byte octet = 0; octet < 6; octet++) {
    Serial.print(macBuffer[octet], HEX);
    if (octet < 5) {
      Serial.print('-');
    }
  }


}

void loop () {}

The output

The MAC address is: 5-0-0-0-0-0

P.S I’ve bought 2 mini ENC because I though one may be broken but I got the same behavior with both.

yesterday I fixed UIPthernet and EthernetENC for esp8266 arduino 3. use the GitHub version of the enc28j60 library

Excuse me could you please provide the link in order to avoid mistakes? I fell I already have some problems with libraries because I got a lot of messages that multiple libraries are installed and I would like to do a clean install for arduino, and then install only the correct libs. Thanks in advance!

This one I think…

Probably easier to simply delete the libraries you don’t want. The IDE compiler gives you the paths, so its quite easy.

Pete.

1 Like

Both libraries are in Library Manager and the “More info” link goes to GitHub.
The library.properties file contains the link too.

Thank you I will try as soon as I can.