February 9, 2013

Getting Arduino Online with an ENC28J60

After learning that an ethernet shield could be purchased for Arduino for under $10, I knew it was time to take my Arduino online. If this is your first time hearing that a $10 or less shield is available I encourage you to search you favorite search engine for the ENC28J60. On Ebay I picked one up for $5 from Hong Kong. But lets get into the meat and potatoes of how to connect one of these boards to and Arduino and start using it.

Instructions

  1. Download the Ethercard library from
    https://github.com/jcw/ethercard/blob/master/README.md. The current version available supports the Arduino v1+ IDE and is compatible with DHCP. The link provided points to the download page with instructions on installing the library into your Arduino IDE.
  2. Physically wire the ENC28J60 board to the Arduino using the pinouts below:
    • ENC -> Arduino
      • VCC -> 3.3V
      • GND -> GND
      • SCK -> Pin 13
      • SO -> Pin 12
      • SI – Pin 11
      • CS -> Pin 8
    • I cut down an old Parallel ATA (PATA) cable (which is a Insulation Displacement Contact (IDC) connector) to plug into my ENC28J60’s SPI header
    • Pinout Diagrams
      • 10th wire -> CLK   | INT  <- 9th wire
      • 8th wire ->   WOL | SO    <- 7th wire
      • 6th wire ->    SI       | SCK  <- 5th wire
      • 4th wire ->    CS      | RST  <- 3rd wire
      • 2nd wire ->   VCC   | GN    <- 1st wire (starting from bottom of PATA cable)

      Arduino ENC28J60 SPI Pinout

      Parallel ATA Cable (PATA) & Related SPI Connection on ENC
      (Check to confirm your ENC’s SPI matches)
      PATA Wire SPI Left SPI Right PATA Wire
      10th CLK INT 9th
      8th WOL SO 7th
      6th SI SCK 5th
      4th CS RST 3rd
      2nd VCC GND 1st
      The PATA cable count starts in the lower
      right-hand corner of the SPI connector.

      Arduino with ENC28J60

      ENC -> PATA -> Arduino Pinout
      ENC PATA Arduino
      VCC wire 2 3.3v
      GND wire 1 GND
      SCK wire 5 Pin 13
      SO wire 7 Pin 12
      SI wire 6 Pin 11
      CS wire 4 Pin 8

       

  3. Download BackSoon.ino from
    https://github.com/jcw/ethercard/tree/master/examples/backSoon
  4. Open backSoon.ino in the Arduino IDE . Confirm the myip, gwip, and mymac variables are correct in the sketch. These are the static network settings that will be used if DHCP fails.
    • myip = This is the Arduino’s unique ip address. If there is another device on the network with the same IP, you will have problems.
    • gwip = This is your gateway’s ip address.
    • mymac = This is the unique MAC address for the Arduino. If there is another device on the network with the same MAC, you will have problems.
  5. Plug your Arduino board into you computer via USB (to power and program).
  6. Upload the backSoon sketch to Arduino.
  7. [OPTIONAL] Open up your network’s router to the screen where you can see clients connected to the router.
  8. Open up Arduino’s Serial Monitor. This will allow you to see what Arduino is doing.
  9. Plug an ethernet cable into the ENC28J60 and look for the ENC/Arduino to show up on your router.
  10. Reset Arduino with the physical button.
  11. Patiently wait for the Serial Monitor to display the Arduino’s IP address. Within about 10 seconds you should see something like the following:
    IP: 192.168.1.107
    GW: 192.168.1.1
    DNS: 24.49.173.40
  12. Open your web browser of choice, surf to that IP, and rejoice when you see the following:
    Arduino OnlineIn your router’s DHCP administration panel you should see an entry for the Arduino. Router Arduino DHCP Entry

Connection Loss After Extended Periods?

If you are having issues with the ENC28J60 losing connection, try adding a heat-sink. See the notes below from Brad on October 10,2013 regarding his experience.

Sources

~Nathan