Arduino Ethernet Shield based on W5100 enc28j60

Ad Code

Arduino Ethernet Shield based on W5100 enc28j60

Arduino Ethernet modules and shields are one of the easiest ways to organize an internet connection in an arduino project. In this article, we will talk about how to organize Internet access and control the Arduino board at a distance using Ethernet Shield shields, we will describe the main characteristics of modules based on w5100 enc28j60. We will learn how to connect via SPI, how to write a sketch to create your own server on Arduino or send data to a remote server.

Contents hide ]

  • 1 Ethernet Modules for Arduino
  • 2 Ethernet Shields for Arduino Uno or Nano
    • 2.1 Ehternet for Arduino Nano
  • 3 How Ethernet works
  • 4 How to connect Ethernet module to Arduino
  • 5 Programming a sketch for an Ethernet module in Arduino
    • 5.1 Server on Arduino Ethernet
    • 5.2 Arduino Ethernet as a client. Sending data to the server
  • 6 Conclusions

Arduino Ethernet Modules

There are several ways to connect the arduino board to the Internet. Wireless connectivity is perfectly organized using the ESP8266 or ESP32 platforms. Lora modules can be used with appropriate WiFi gateways. But the most noise-immune and “traditional” is the good old Ethernet. Using a regular RJ45 connector and a twisted pair cable, you can combine your card with other network equipment, be it a router, router or the same WiFi modem. The advantages of an Ethernet connection are speed, stability, and greater immunity from interference. The disadvantages are obvious - the equipment is tied with a wire, and in real-life conditions the quality of this wire must be high.

Arduino Ethrnet Shield Expansion Board
Arduino Ethrnet Shield Expansion Board

The most popular Ethernet modules for Arduino today are based on the wiznet w5100 chip, which is capable of supporting data exchange at a constant speed of 100 Mbps. Ready-made libraries have been written for devices based on w5100, this architecture is simple and ideal for beginner electronics enthusiasts who can use them as a launching pad for subsequent projects.

Key characteristics of modules based on W5100:

  • The operating voltage is 5 volts, power from the Arduino board is suitable.
  • Internal buffer 16 Kb.
  • The connection speed reaches 10/100 Mbps.
  • Communication with the arduino board is carried out via the SPI port.
  • The W5100 supports TCP and UDP.

Options for modules based on other microcircuits:

  • Module based on Wiznet W5500. It has a smaller size, heats up less, has more power.
  • Enc28j60 based module. This is a much more budget option, cheaper than the W5100, but there may be more potential problems with it.

Ethernet Shield for Arduino Uno or Nano

The most convenient way to work with the W5100 is to use a ready-made Ethernet Shield for Arduino Uno or Nano. All the necessary connections have already been made on such modules, the shield is simply inserted into the corresponding connectors of the board and you just have to upload the sketch. Naturally, other devices can be connected to the board if desired.

Arduino Ethernet
Arduino Ethernet Shield

The expansion board is connected via an RJ-45 connection. The board has a built-in SD / MicroSD slot , which is used to store files used for connection and transfer over the local network. This slot is compatible with all Arduino / Genuino boards, i.e. you can work with the data on the card using the standard SD Library. You can also find a reset button on the expansion board. nutrition. Early versions of the expansion board were not friends with the mega arduino, they required a manual reset after the power was applied.

If the board is equipped with a POE module (power supplied over twisted pair), then the shield will meet the following specifications:

  • Compliant with IEEE3af standard.
  • Has low output ripple.
  • Protects against overload and short circuit phenomena.
  • Effectively converts voltage.
  • Has an isolation of 1500 volts at the point between input-output

By default, the board is not equipped with this module, you need to find the appropriate model.

Purpose of Ethernet Shield LEDs:

  • PWR indicates the presence of power on the board.
  • LINK lights up when there is a network and flashes when transmitting / receiving data.
  • FULLD stands for full duplex network connection.
  • 100M stands for 10Mbps network connection.
  • RX flashes when the screen is receiving data.
  • TX flashes when sending data by the screen.
  • COLL blinks when network conflicts are detected.

In addition to these, there are a couple of LEDs on the rj 45 socket, one of which glows when the cable is connected, and the other flickers when data is received.

Ehternet for Arduino Nano

The Arduino Nano Ethernet module deserves a special mention. It is made in a form factor that makes it easier to connect to a Nano v 3.0 board, but has almost the same capabilities as the “regular” version for the Uno. The shield is based on the ENC28J60 microcircuit.

Ethernet Arduino Nano Shield
Shield Ethernet Arduino Nano Shield

The module also has an RJ-45 connector, an SD slot and, in some modifications, is also equipped with a PoE controller.

How Ethernet works

It is understood that for projects related to connecting the Arduino to the network, you must have at least a general knowledge of networking technologies. Today, you can easily find relevant materials on the Internet. While it is not our intention to write a tutorial on Ethernet, the general information may be helpful.

Today Ethernet is the key and most widespread technology for organizing local networks along with WiFi. In the standard OSI model, it is at the link and physical layer, defining sublayers of media access control and logical link control. The creator of Ethernet was Xerox, its engineer Robert Metclough created the technology as a tool for connecting many computers to shared resources on a local network. The technology became the official standard in 1982 after the appearance of the IEEE802.3 specification.

Arduino Ethernet Shield based on W5100 enc28j60

Today there are several options and modifications of Ethernet, differing in speed characteristics and the way of organizing the physical channel:

  • Ethernet. Speed ​​up to 10Mb / s. Any types of wires (coaxial, twisted pair, fiber optic).
  • Fast Ethernet. Speed ​​up to 100Mb / s. Twisted pair or optics only.
  • Gigabit Ethernet. Speed ​​up to 1Gb / s. ... Twisted pair and optics only.
  • 10G Ethernet. Speed ​​up to 10Gb / s. Naturally, also without coaxial.

There are a dozen more different groups and subgroups of the standard, in this article we will not consider all of them.

Possible Ethernet network layout

From a practical point of view, working with Ethernet looks like an opportunity to connect end equipment in a certain way with the nearest point that has access to other network segments. Most often it is a router or router with access to the Internet or to other resources of the local network.

If you are starting a project with Ethernet, then you will need to understand the following basic concepts related to this technology:

  • Cable. As a rule, this is a twisted pair, less often - fiber (it will not be possible to connect it to Arudino in a simple way).
  • The connector for the cable is RJ-45. In fact, the standard for plugs has a completely different name (8P8C), but the “people” usually refer to the standard Ethernet connector as RJ45. It should be noted that there are other standards - RJ-25, RJ-14, etc. They will not work for connecting to arduino through standard modules.
  • Network Ethernet MAC address. This is a unique six-byte device identifier on the network, which is usually flashed into the device itself, but in some cases can be changed by software. In total, 2 to the power of 48 addresses can be specified, these are trillions of different options (more precisely, 281 474 976 710 656), so for now there are enough of them to create truly unique identifiers.

Arduino Ethernet Shield based on W5100 enc28j60 Arduino Ethernet Shield based on W5100 enc28j60

In the vast majority of tasks, a project with Arduino will be connected to an existing Ethernet network via standard equipment. Those. you just take an Ethernet module, connect it to the Arduino, and then plug the network cable into this very module. All you need is to correctly configure your MAC address in your sketch (you can change it!) And register the IP address of the devices to which you will connect. We'll look at an example in the programming section.

How to connect Ethernet module to Arduino

The w5100 modules are connected to the arduino   via SPI . If you have some experience with the platform, this should not cause any difficulties. In the simplest case, you just need to “put on” the shield board by inserting the Uno or Nano boards into the corresponding connectors. If you use a separate module, you can connect the w5100 to the arduino via standard SPI pins.

Arduino Ethernet Shield based on W5100 enc28j60

It should be remembered that in the Arduino Uno for SPI pins 11, 12, 13. In the Arduino Mega - 50, 51, 52. On the shield for the Uno SS, the signal is connected to pin 10. On the Mega board, pin 53 is responsible for SS, but it is not used. Regardless , you need to make sure to set it to OUTPUT using the pinMode function .

The pinout of the shield with the description of the board elements for the Arduino Uno is shown in the following figure.

Description of Ethernet Shield
Arduino Ethernet Shield schematic

After connecting the external module to Arudino, you will need to connect it to the existing network infrastructure via a twisted pair cable with an RJ45 connector. Moreover, you can also connect to a WiFi router, which allows your project to communicate wirelessly (you will still need a wire from the arduino to the router).

After completing the physical connection, it remains to take only the last, but the most difficult and important step. You need to write and upload an appropriate sketch to the board, which will turn the board into a server that responds to requests from remote devices or into a client that collects data from servers or sends data to them.

Programming a sketch for an Ethernet module in Arduino

When creating a program on arduino to work with the network, you will always send or receive some kind of data. Depending on the goals of the project, your device can act both as a server and as a client - it all depends on the logic and system structure you choose. You can send data from sensors and your arduinka to a remote server and receive instructions from it. Or you can make a control server that receives data from other devices or from a person through a Web browser who will already act as a client.

Ethernet support for the arduino platform appeared in the first versions of the Arduino IDE. You just need to add the standard libraries to your sketch using <include> and use the ready-made classes.

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

This is not to say that the library is written flawlessly; from time to time, very dubious code fragments that affect performance are found in it. But for the first educational projects, it fits completely. You can use the built-in SD library to work with the memory card.

Arduino Ethernet Server

The created Web-Server works in full compliance with the HTTP protocol. The main functions of the server are to track client requests and perform various functions based on the received data. And then the result itself is sent directly in the form of an HTML code. An example sketch can be found in the Arduino IDE (Sample File). Below are just short excerpts and a description of the key points.

Working with the library is divided into two stages. First, we create the necessary objects and make the settings. During the initialization process, you should register the MAC address and IP through which the user will gain access to the server.

byte macAddress [] = {
0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF
IPAddress ipAddress (192, 168, 1, 10); // IP address depends on your network settings

EthernetServer myServer (80); // You can choose another port

// ...
void setup () {
Serial.begin (9600);
// Connected to Ethernet
  Ethernet.begin (macAddress, ipAddress);
// Start the server
  server.begin ();
  Serial.print ("server is at");
  Serial.println (Ethernet.localIP ());

Then we turn on an endless loop, in which we constantly check for the presence of requests from clients in the queue. If there are requests, then we analyze them and, depending on the parameters, form a response. Basically, we implement the logic of a regular web server, only all tasks for authentication, routing and generation of a response have to be implemented independently. An additional inconvenience is created by the very modest possibilities of the built-in libraries for working with strings.

void loop () {
  // Check if there are requests
  EthernetClient client = server.available ();
  if (client) {  
  // There are requests
    Serial.println ("New client!");
    while (client.connected ()) {
      if (client.available ()) {
        char c = ();
        Serial.write (c);
        // ... Here is the parsing of the line and the description of the response logic
        client.println ("HTTP / 1.1 200 OK"); // This is a sample code for sending data to the client.
        // ...
    // Inquiry 
    // Give a little time for the client to receive data
    delay (5);
    // Close the connection 
    client.stop ();
    Serial.println ("Client disconnected");
    Ethernet.maintain ();
  } // if (client)
} // Loop

After the user has uploaded the sketch and connected it to the computer using a network cable, the server on the arduino waits for commands. After the user navigates to the specified IP address, a get request is sent to the server, which informs about the need to issue a web page. The task of the server is to form this page and send it back to the client, after which the browser itself processes the HTML code and displays forms, tables and other content. The user can perform some actions in the form (for example, by marking the inclusion of the necessary pins) and they will again be sent to the Arduino server. And so on ad infinitum, as long as the system will work and the network will not fall off.

Arduino Ethernet as a client. Sending data to the server

If we want to send data over an Ethernet connection, then we need to use the methods of the Client class of the standard Arduino library. The initialization process looks exactly the same - we specify the IP and MAC address. But we create a client object, not a server object.

byte macAddress [] = {
0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF
IPAddress ipAddress (192, 168, 1, 10); // IP address depends on your network settings

EthernetClient client;


The next step is to connect and send data to the server

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

  // Connecting via Ethernet:
  if (Ethernet.begin (mac) == 0) {
    Ethernet.begin (macAddress, ipAddress);
  delay (1000);
  Serial.println ("connecting ...");

  if (client.connect (server, 80)) {
    Serial.println ("connected");
    // Make a HTTP request:
    client.println ("GET / search? q = arduino HTTP / 1.1");
    client.println ("Host:");
    client.println ("Connection: close");
    client.println ();
  } else {
    Serial.println ("connection failed");


After sending the data, we want to receive some kind of response from the server. For example, that the data was received successfully or an error occurred. The server may also give some instructions for execution in response to information received from us. So the next step is to listen for server responses and do some kind of reaction.

void loop () {
  if (client.available ()) {
    char c = ();
    Serial.print (c);

  if (! client.connected ()) {
    Serial.println ();
    Serial.println ("disconnecting.");
    client.stop ();

    while (true);


All of the above sketch fragments will not work individually. You can get the complete working code for the Ethernet module for free in the Arduino IDE itself. The figure shows exactly where this can be 


In this article, we discussed the possibility of controlling the Arduino board via the Internet using an Etherent module based on the w5100. As we have seen, connecting the module and programming the sketch is not a significant problem. The main thing is to correctly determine the structure of the project, to determine what will be the server and what will be the client, how the connection to the Internet will be carried out.

The most convenient and fastest way to connect the module is to use a ready-made Ethernet Shield for Arduino Uno or Nano. The connection is carried out via the SPI interface, which is available in any platform boards. Taking as a basis ready-made libraries and sketches from the Arduino IDE examples, you can create an application of any complexity. But for this you will definitely need programming skills and an understanding of the principles of operation of existing network protocols. Let's hope our article helped you take the first step.

Close Menu