Arduino Ethernet Using ENC28J60

RF Ethernet Maniac V1 Photo

Today’s goal is to get my Arduino on the wired Ethernet for cheap. There are basically two options in Arduino-land for Ethernet, Wiznet 5100 or ENC28J60. The Wiznet solution is the easiest and consequently it’s the standard for Arduino Ethernet. It’s also expensive. $45! I bet we can do better.

Electronics Kits Zone sells an ENC28J60-based Ethernet Shield Kit for $19. Stand-alone modules can be found cheaper still such as this $17 module from mdfly.com, but you still have to interface it with the Arduino and convert the voltage down.

Of course, all cheap hardware comes with a price. It requires a TCP/IP stack in software, as opposed to the Wiznet which implements it in hardware. This is not a trivial problem! We expect a full working TCP/IP stack on our PCs, but on a memory-constrained microcontroller, it’s another story entirely. None of the available stacks implement it fully, they all take some shortcuts. Worse, I could never find one that has been ‘tested by fire’ as much as a PC (or Mac or Linux) stack. They seem to still be fairly immature. This translates into a serious pain to use. You have been warned!

Hardware

My solution was to design and roll a dedicated PCB for the task. I got the cost down to $12.50 in quantity 3, and theoretically could get real close to $8 in quantity 10, using iTeadStudio’s amazingly cheap PCB service plus bulk pricing on the components.

This setup uses my Box Header Platform for connectors, but could just as easily be reconfigured into a shield.

As a little bonus, I threw on a connector for the nRF24L01 2.4GHz RF radios that I use ($6.50 at MDFly). Doing so didn’t add much complexity or size, and and enables easily putting an Arduino on the Ethernet AND an RF network.

Software

After much experimentation with the available options, I settled on Jee Labs’ EtherCard stack. This is based on the classic Stang/Socher code base, but refactored significantly which seems to have eliminated the quirks of the original. Best of all, JC Wippler is still actively working on it, which means it continues to get more mature.

Another possibility is iUP. There is an AVR implementation, avr-uip. However, EtherCard is already designed to work in an Arduino environment, and uIP would still need some work. After having got EtherCard to function reliably, I found no reason to continue looking for solutions.

Future

My next plan is to combine this with the MCU itself and go down to 3.3V for the whole system. This will be my personal “everything but the kitchen sink” Arduino clone.

Bill of Materials

One interesting note on the BOM, SparkFun ended up being the low cost leader on MagJacks. Nowhere else could they be found for $2. Amazing! First time I’ve seen SparkFun lead on price. Perhaps by the time you read this, they will have brought it up.

Total cost of these parts, $7.71. All parts are from Mouser, except the MagJack.

Qty Vendor# Description Price Comment
1 579-ENC28J60-I/SP Microchip Technology Ethernet ICs 8 KB RAM MAC&PHY Ethernet Controller $3.63 Datasheet Errata
1 Sparkfun PRT-08534 RJ45 Ethernet MagJack $1.95 Datasheet
1 815-ABL-25-B2F ABRACON Crystals +/-20ppm 25MHZ FUNDAMENTAL $0.39
1 579-MCP1700-3302E/TO Microchip Technology Low Dropout (LDO) Regulators 250mA Adj LDO 2%. $0.37
1 81-BL01RN1A1F1J Murata EMI/RFI Suppressors & Ferrites AXIAL 1 BEAD $0.15
2 140-50N2-220J-TB-RC Xicon Ceramic Disc Capacitors 50V 22pF NPO 5% Tol $0.06 For crystal
7 594-K104M15X7RF53L2 Vishay Multilayer Ceramic Capacitors (MLCC) – Leaded 0.1uF 50volts 20% X7R 2.5mm LS $0.06 across all VDD’s, and across TX/GND, RX/GND
3 647-UPW1E100MDD Nichicon Aluminum Electrolytic Capacitors – Leaded 25volts 10uF 5×11 20% 2LS $0.11 VCAP, across input & output VDD/VSS:
1 660-MF1/4DCT52R2321F KOA Speer Metal Film Resistors – Through Hole 1/4W 2.32K ohm 1% 2.32K OHM 1% $0.05 RBIAS
2 660-MF1/4DC3300F KOA Speer Metal Film Resistors – Through Hole 330ohm 1% 100PPM $0.04 LEDs
4 660-MF1/4DCT52R49R9F KOA Speer Metal Film Resistors – Through Hole 1/4W 49.9 ohm 1% $0.05 TX/GND and RX/GND

Schematic

For the schematic, I started with the schematic for EtherCard, and referred to the schematic for the MDFly module I had already gotten working. The only really tricky part was getting the TPIN/TPOUT pins right for the magjack I’m using.

> Download RF EtherCard Maniac V1.sch from box.net.  This work is licensed CC BY-NC-SA.

RF EtherCard Maniac.sch

Circuit Board

This is a 1.975 x 1.45 board, ordered from pcb.laen.org, at a per-board cost of $4.77.

> Download RF EtherCard Maniac V1.brd from box.net.  This work is licensed CC BY-NC-SA.

RF EtherCard Maniac-laen

About these ads

16 Comments

Filed under Arduino, Ethernet

16 responses to “Arduino Ethernet Using ENC28J60

  1. recreator

    Hi, I laid out that board again with the same schematic, mainly just to familiarize myself with the circuit. It came out smaller, with no vias, and larger traces all around. If you like, feel free to grab a copy from https://github.com/dgentry/RF-Ethercard-board and fix anything I might have broken.

    Cheers!

    • Very nice. What is the advantages of larger traces and no vias?

      • Ghydda

        I would say the advantage surfaces for those who want to etch the board themselves. Succesflly etching fine tracks can be a pain. Drilling extra holes for vias are just annoying – especially if they could be avoided.

  2. John

    Hi there,

    Have you managed to get it working for the RF and Ethernet simultaneously as you have made provision for the RF? Therefor the atmega328 uses the RF to aggregate all the sensor data and then the ethernet to store it to a database.

    Or do you suggest having a RF arduino board and arduino enc28j60 ethernet board and let them communicate over serial?

    Cheers

  3. Joey

    I would love to see the code that manages RF/Ethernet as well. I am trying to do a similar thing in one of my projects.

    Thanks!

    • Yes, I would love to get it out. Alas, I haven’t gotten to the point where it’s publication-ready.

      • wazolas

        +1 struggling with managing both SPI slaves (enc28j60 and nrf24l01+). Can you please point in any direction? no need to post the code, any hint would help… i’ve checked SPI dividers, enable/disable slaves, change the SS ports, different versions of the library… Even tried to begin and close SPI twice on the loop, one for each SPI device.. no luck at all! they both work independently. It’s just when i put them together that results get messy. it’s not the first time i’m dealing with SPI protocol on atmega, but it’s been the longest and hardest :\
        thanks!

  4. Tom

    Hi! I can’t get the RF24l01 module working with a Arduino Ethernet Shield v1.1 with ENC28J60 chip. My ethernet connection does work but when this shield is attached, my wireless module doesnt. I’ve set the RF24l01 ports to (2, 3). Do you have some example code availble for using the RF24l01 with an arduino Ethernet Shield v1.1 together?

    Thanks,
    Tom

    • No, sorry. Are you sure the “Arduino Ethernet Shield” is really using ENC28J60? The official boards use a different chip, the wiznet. I haven’t used the official boards at all.

  5. Hello maniacbug and thanks for this nice post.

    I have a few questions about your BOM : are all specifications mandatory ?

    By example, should the 25Mhz crystal necessarily be +/-20ppm ? The ferrite bead a Murata BL01RN1A1F1J ?

    What are the minimal requirements for these 2 components ?

    Thanks in advance for your reply.

    • Hi there. No no, certainly a wide variety of components may be used. I’m listing the components I used to make it easy for people to build it themselves, knowing that it for sure should work. As far as minimal requirements, this you would need to determine from the data sheets or experimentation (or both!). Good luck!

  6. Chris

    hi there, am trying to integrate the ENC28J60 board with an arduino UNO to display the contents of a text or CSV file stored on a SD card, but am having no luck- any suggestions?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s