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.

34 Comments

  1. Allison J. Eichhornsays:

    “Fantastic guide on using the enc28j60 Ethernet shield with Arduino Mega 2560! Your tutorials are always detailed and helpful. On a different note, if anyone is exploring new ventures, we provide comprehensive Medspa Business Plans to help entrepreneurs successfully launch medical spas. Feel free to learn more on our website!”

  2. men’s leather aviator jacket adds a touch of luxury to any outfit

  3. Your blog truly impressed me; it’s commendable and captivating. Your insights are engaging I would love to see more of your work. Please continue sharing your thoughts and ideas. Thank you for inspiring us with your writing!

  4. Maximize your Facebook experience with groups. Learn how to join, create, and manage groups. Click here for tips on using Facebook groups.

  5. Discover the step-by-step guide to logging into Facebook without any hassle. Quick, easy, and secure methods for accessing your Facebook account.

  6. Stay informed about your Facebook account activity with login alerts. Learn how to set up alerts for enhanced security. Click to set up alerts now.

  7. Click here for effective solutions.Navigate to the Facebook login page easily with our guide. Learn tips for quick access and troubleshooting common issues. Click now to access the login page.

  8. Facing problems logging into Facebook? Check out our detailed troubleshooting guide to resolve Facebook login issues quickly. Click here for effective solutions.Navigate to the Facebook login page easily with our guide. Learn tips for quick access and troubleshooting common issues. Click now to access the login page.

  9. I love how informative this article is without being too technical. I might look into some premium vape juice soon.

  10. Struggling with your accounting tasks? Our accounting assignment help at “My Assignment Help” offers expert guidance to tackle even the most complex problems. With our team of professionals, we ensure that your assignments are completed accurately and on time, helping you stay ahead in your studies. Reach out today for top-notch assistance!

    https://myassignmenthelp.com/uk/financial-accounting-assignment-help.html

  11. Nandita Surisays:

    Khel Raja offers an exhilarating online roulette experience! With a sleek interface and smooth gameplay, you can enjoy classic and modern variations right from your home. The thrill of the spin, combined with exciting bonuses and promotions, makes every game feel special. Join Khel Raja today and let the roulette wheel decide your next big win!

  12. Komal Ahujasays:

    The 12A and 80G registration process online can be daunting, but NGO Expert simplifies it for you! Their expert guidance ensures a smooth application experience, helping your organization gain the necessary tax exemptions and recognition. With their support, you can focus more on your mission and less on paperwork. Highly recommend their services for any NGO!

  13. Increasing Instagram engagement is pivotal for maximizing reach and fostering community growth. Focus on producing visually captivating content that aligns with your brand’s identity. Utilize interactive features like polls, questions, and challenges to stimulate audience participation. Consistently schedule posts during optimal engagement times to maintain visibility. Use trending and niche-specific hashtags for wider reach and discoverability. Collaborate with influencers who share your brand values to boost credibility and interaction. Engage thoughtfully with followers by promptly responding to comments and messages. Implement a data-driven approach using Instagram Insights to continuously refine strategies. By embracing creativity and interaction, you can cultivate an active and engaged Instagram community.
    https://www.buyyoutubesubscribers.in/buy-instagram-comment-likes/

  14. Liza Liamsays:

    Struggling with complex assignments and tight deadlines can be overwhelming for students. That’s where assessment help https://myassignmenthelp.expert/assessment-help.html comes in, offering expert guidance and support to ensure you meet your academic goals. Whether it’s detailed research, formatting, or understanding tricky concepts, professional help can make the process easier and more efficient. By seeking assessment assistance, you can improve your work quality and boost your confidence, ensuring you’re on the right path toward academic success.

  15. Great tutorial on using the enc28J60 ethernet shield with the Arduino Mega 2560! It really simplifies setting up network communication for projects. Speaking of functionality, Mark Wahlberg Green Jacket is a stylish yet practical choice, perfect for those hands on tech days.

  16. Alex Jamessays:

    Great guide! It’s helpful for anyone looking to add network connectivity to their projects. While you’re busy coding, don’t forget to stay stylish with “My Life with the Walter Boys Isaac Garcia Black Leather Jacket” for that perfect tech savvy look.
    Visit! https://www.stardomjackets.com/product/my-life-with-the-walter-boys-isaac-garcia-black-leather-jacket/

  17. 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
    https://humidifier.in.net/catalogue

  18. 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.

  19. 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.

  20. maxh60434says:

    During my studies, I try to use useful tools as much as possible. The professional resource https://www.nursingpaper.com/ 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.

  21. Arjensays:

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

    something like this?
    client.Post(“192.168.1.1/value=10”)

  22. Ricardo Castrosays:

    Hi,
    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.

  23. Ricardo Castrosays:

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

  24. 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 …

    [webClient]
    DHCP failed
    IP: 0.0.0.0
    GW: 0.0.0.0
    DNS: 0.0.0.0
    DNS failed
    SRV: 0.0.0.0

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

  25. zainabsays:

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

    ip =172.16.64.202
    gateway:192.168.1.4
    subnetmask: 255.255.248.0
    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

    thanks.

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

    I downloaded https://github.com/jcw/ethercard/archive/master.zip (renaming from ethercard-master.zip to just ethercardmaster.zip)

    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?

  27. Grahamsays:

    Raffi

    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.

    Graham

  28. Mairtinsays:

    Hi Raffi,
    I bought an ethernet shield off ebay ( http://www.ebay.co.uk/itm/261086363306?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649 ) 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,
    Mairtin

    • 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.

      Greets,
      Raffi

  29. Man , you solve my problem !!

    Thx , from Argentina!

  30. 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?

  31. 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