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
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"));
     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.


  1. Explore leading manufacturers and sellers of high-quality humidifiers, offering innovative solutions to improve air quality and comfort. Find reliable suppliers providing a range of humidification options tailored to your needs

  2. jesssicaalexsays:

    Due to its association with a beloved film franchise and its status as a fashion statement, the Blade Runner 2049 Jacket has garnered immense popularity among collectors and enthusiasts. Limited edition replicas, officially licensed 2049 blade runner jacket , and custom-made versions of the jacket are highly sought after, adding to its collectibility and value.

  3. jesssicaalexsays:

    One of the significant advantages of assignment writing is its role in honing critical thinking skills. As students analyze information, evaluate arguments, and draw conclusions, they develop the ability to think critically and assess the do my assignment for me
    and reliability of sources. This skill is invaluable not only in academia but also in everyday life, as it enables individuals to make informed decisions, solve complex problems, and navigate a world inundated with information.

  4. maxh60434says:

    During my studies, I try to use useful tools as much as possible. The professional resource became my reliable assistant in writing medical papers, thanks to the support of nursing essay writers, I was able to effectively balance studies and personal life. The most impressive benefit was the ability to receive high-quality help with complex tasks while maintaining complete privacy and security of my data.

  5. Arjensays:

    Library works for my. But how do you send a Post message to a Webserver with this library ?

    something like this?

  6. Ricardo Castrosays:

    Who is interested, I have connected the CS to pin 10 arduino mega 2560, and it works perfectly, I have also connected W5500 to 5V.

  7. Ricardo Castrosays:

    To whom it may concern, I have connected the CS to pin 10 arduino mega 2560, and it works perfectly for me.

  8. pradeepkumar ksays:

    Hi ,
    I am connected the devices as mentioned above but i am getting the DHCP error like below kindly help me to resolve the same …

    DHCP failed
    DNS failed

    <<< REQ
    <<< REQ
    <<< REQ
    <<< REQ
    <<< REQ
    <<< REQ
    <<< REQ
    <<< REQ
    <<< REQ
    <<< REQ
    <<< REQ
    <<< REQ
    <<< REQ
    <<< REQ
    <<< REQ
    <<< REQ

  9. zainabsays:

    i want interface en28j60 on lan. a/c to my lan configration ihave set

    ip =
    i have setup this by static setup method and its configured correctly. but when ping from other computers on same network its unreacheable from them :( destination unreacheable.

    any help would be appreciated


  10. Im new to arduino and programming, can anyone help me with the Ethercard installation?

    I downloaded (renaming from to just

    From the Arduino arduino 1.5.6-r2 IDE: Sketch -> Import Library… -> Add Library and pointed it to the zip

    But when I restart the IDE, I don’t see any “Ethercard” in the menu.. In the Examples->Ethernet, the same examples prior to importing are there, but nothing that says Ethercard. What am I doing wrong?

  11. Grahamsays:


    Thanks for this. I’ve been struggling for 2 days trying to figure out how to get the Ethernet module to work with my Mega 2560.

    I appreciate you sharing this.


  12. Mairtinsays:

    Hi Raffi,
    I bought an ethernet shield off ebay ( ) it is built to fit directly into the arduino uno, but it fits perfectly into the atmega2560, with the only difference of CS which i cut off the shield so it wouldnt connect to pin 10(unos CS) and then brought a wire from pin 53 (megas CS) to ethernet shield.
    Ive also notices the number 53 in the snippet of code u have and had it changed before i tested it, but it still doesnt work is th pin number referenced more than 1 place in the ethernet library?
    Also I am using the ICSP pins to talk to my shield, could that be an issue im having?
    And final question is it 100% necessary to have my arduino and pc connected to a modem because im not using one at the moment?
    Thanks in advance,

    • Hey Mairtin,

      it’s some time ago, that I wrote this article. But I seem to remember, that the Pin was referenced at more that one point. I think it was referenced in the header files (*.h) also. Just open the documents in your favourite editor and search for the pin number with help of Strg+F.

      No, they don’t have to be connected to a modem. You can give your Arduino a fixed IP. So you can connect it directly to your pc and send traffic/messages/packets between your pc and your Arduino. Or you take two PowerLAN (Ethernet over Powerline) adapters and connect your Arduino to your wifi router for example.

      I hope I could answer your questions. If there’s something not clear, just write me another comment.


  13. Man , you solve my problem !!

    Thx , from Argentina!

  14. Jacksonsays:

    Please advise on the cable to use ie cross over or straight through between Enc2860 aand PC. I have no router, can I still put arduino on web with out router nor switch.

    • I use a simple patch cable. No crossover. Bringing up the Arduino to net without a router or switch? Sound hard! What about buying a cheap used switch for ~5 bucks at eBay?

  15. Gregsays:

    Can the CS pin be changed to any pin? I would like to use pin 10 as I have a UTFT which uses pin 53.

    I’ve tried (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0)
    but I can’t seem to get it working.

    • I think it should be possible to change the pin. But you have to have a look inside the Ethercard library. Sadly there seems to be more than one point, where Pin 53 is hardcoded into the library. But if you change all references, then it should work.

Leave a comment

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