How to use enc28j60 ethernet shield with Arduino Mega 2560

Today it is time to talk again about one of my favourite gadgets – my Arduinos. In particular, for the Arduino Mega 2560 and how these can be used in combination with the enc28j60 ethernet adapters.

No products found.

The enc28j60 Ethernet adapter should be known to one or the other of you, who has ever tinkered with an Arduino. These are the low-cost ethernet shields, which are available for example at eBay for less then 5$. Sure, the wiring and the library (the original ethernet library isn’t compatible), are not quite as comfortable as those of the original ethernet shields, but you can also save 30$  and more compared to the official ethernet shield.

For the Arduino Uno, there is already a handful of useful articles, which refers to the enc28j60 and Ethercard library. However, for the Arduino Mega 2560, I could not find anything useful information, so I would like to address briefly below on the intricacies of this combination.

How to wire Arduino Mega 2560 and enc28j60 ethernet shield

When cabling you must be a bit careful because of some other port assignment of the Arduino Megas. A 1-to-1 replica of the Arduino Uno tutorials unfortunately does not work.

Below I’ve graphed the the wiring for you. But you can also read the exact connections from to the table below the graphic.

Arduino Mega 2560 mit enc28j60 Ethernetadapter verkabeln

Enc28j60 Arduino Mega 2560
GND GND
3.3 3.3V
SO Pin50
SI Pin51
SCK Pin52
CS Pin53

Actually for wiring only 6 pins on the ethernet board has to be used. The remaining 4 pins are not necessary. (At least as long as you can live without things like wake-on-lan.)

The trick with the Ethercard library

When the Ethercard library is used with Arduino Mega a little piece of code needs to be adjusted. Thus, the begin()-method has to be called with a reference to the Pin53.

...
if (ether.begin(sizeof Ethernet::buffer, mymac, 53) == 0)
  {
    Serial.println(P("Failed to access Ethernet controller"));
  }
  else
  {
     Serial.println(P("Ethernet is fine and up"));
  }
...

That’s all. If the pin has been adjusted in the begin()-method, the library can be used normally (as well as with the Arduino Uno).

Some more tips…

If there are questions or anything is unclear, simply write a comment.

p.s.: Anyone who is still looking for a cheap Arduino Mega, should move on to eBay. There, I’ve already bought several Arduino Megas for ~18$ per unit (including shipping costs). Nowadays Amazon offers some Arduino Megas for the same cheap price as eBay but with better shipping conditions. So I added the following list with daily updated prices for Arduino Mega 2560s on Amazon:

No products found.

108 Comments

  1. The NBA YoungBoy Bandit jacket is a fan-favorite piece inspired by his collab track *Bandit* with Juice WRLD. Known for its bold style and streetwear edge, the jacket reflects YoungBoy’s unique fashion sense—mixing swagger, comfort, and a statement look that stands out in any crowd.

  2. Ledger.com/start is the official setup page for initializing your Ledger hardware wallet, ensuring a secure start to your crypto journey. By using Ledger.com/start, you get step-by-step guidance to install Ledger Live, configure your device, and create a recovery phrase. The benefits include industry-leading security, offline private key storage, and easy management of multiple cryptocurrencies.

Leave a Reply to rpg Cancel reply

Please be polite. We appreciate that. Your email address will not be published and required fields are marked