Connecting ENC28J60 (Ethernet LAN) to Arduino

Connecting ENC28J60 (Ethernet LAN) to Arduino

Daniil Zhuk
Often microcontrollers need access to the Internet, local network. This can be useful, for example, to build a smart home, create weather stations, "People's Monitoring", install a simple web server and much more. All this can provide the Ethernet-module ENC28J60.
In this article, I would like to talk about connecting ENC28J60 to Arduino. This module allows Arduino to access the Internet or a local network.

To implement the project from this article, we need the following components:
  • Arduino Uno R3
  • ENC28J60 module
  • Breadboard
  • Wires



 The module connects to the Arduino using the SPI interface. The clock frequency of the interface can reach 20 MHz. To connect to a TCP / IP network, an RJ-45 connector is used. The module is galvanically isolated from it.

The module controller has a maximum clock frequency of 25 MHz. All functions for working with network protocols are assigned to it, Arduino can only send data packets and receive received.

The module operates at a voltage of 3.3 V, which makes it compatible with STM32 or STM8 microcontrollers. The maximum current consumption can be 250 mA, nominal - 170 mA.
Now let's look at connecting ENC28J60 to Arduino.



Consider connecting ENC28J60 to UNO and other Arduino ATmega328 / 168 based boards.

The scheme will look like this:

  • VCC - 3v3;
  • GND - GND;
  • CS - 8;
  • SI - 11;
  • SO - 12;
  • SCK - 13.

Connecting ENC28J60 to Arduino
When using the Arduino Mega, it will look like this:

  • VCC - 3v3;
  • GND - GND;
  • CS - 53;
  • SI - 51;
  • SO — 50;
  • SCK - 52.

The pin number of CS can be changed using the ether.begin () function.

Please note that the module consumes a lot of energy and the current supplied by the 3v3 port may not be enough, especially on Chinese clones. In this case, you will need to use an external power source.

Now let's move on to programming and connecting ENC28J60 to the Arduino.

Among the standard Arduino IDE libraries there is no library for our module, so we will use the EtherCard library, which supports the following Arduino models: UNO, Mega, Leonardo, Nano, Pro Mini, LilyPad, Duemilanove, and others based on AVR microcontrollers. Boards with ARM architecture, such as 101, Zero, Due are not supported.

Let's try to output the device's IP address, subnet mask, default gateway and DNS server address to the serial port of the computer.

After assembling the circuit and connecting the board to the computer, load the following sketch into the Arduino:

 #include <EtherCard.h>

static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[700];

void setup () {

Serial.print("MAC: ");
for (byte i = 0; i < 6; ++i) {
Serial.print(mymac[i], HEX);
if (i < 5)

if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println(F("Failed to access Ethernet controller"));

Serial.println(F("Setting up DHCP"));
if (!ether.dhcpSetup())
Serial.println(F("DHCP failed"));

ether.printIp("My IP: ", ether.myip);
ether.printIp("Netmask: ", ether.netmask);
ether.printIp("GW IP: ", ether.gwip);
ether.printIp("DNS IP: ", ether.dnsip);

void loop () {}

 The MAC address is in hexadecimal. Make sure that it does not coincide with any of the existing addresses on the network, otherwise problems may occur.

Other examples of using the library are in the “examples” folder in the archive with it. 

This library is not the only one, there is also EtherEncLib and UIPEthernet.

Add a comment

* Comments must be approved before being displayed.