Thursday, January 12, 2012

Arduino + ENC28J60 Ethernet Module

For Christmas I got a small ENC28J60 Ethernet module from eBay in my stocking.
All the advertisers stated it worked with Arduino so I thought let's have a go.

This is a small cheap, less capable Ethernet connection than the official Ethernet Shield.
The official shield has support built into the IDE but this board has code from very clever contributors.

Last night I rigged up the board using instruction from http://www.electrodragon.com/?p=1112 and it failed.
Not the best start.  So, I tried a few other libaries and again no success. I added voltage buffers (74HC125) to do the voltage change from 3.3V on the ENC28J60 to 5V on the Arduino.   
I asked a question at electrondragon and in fairness to him (I'm assuming him - never met them) he came back straight away with some helpful tips.
Still no luck.
Beaten, off to bed I went and then did a bit more digging today.  The 1 thing I didn't try was using an older IDE.  I took this opportunity to upgrade to Arduino IDE 1.0 where before I was using Arduino IDE 0021.

So, tonight was my second attempt.

I copied the libraries to Arduino IDE 0021 that I had been using.  I uploaded the sketch for the web server.
Opened up Firefox and browsed to 192.168.1.25.
Success 1st time.

I uploaded the ping sketch.  Success 1st time.

I then wired up an LED to Pin 4 and loaded the etherShield_web_switch sketch that allows you to control the LED from a web browser.
Again - success 1st time

Looks like the library referenced on http://www.electrodragon.com/?p=1112 from nuelectronics does not work with the latest IDE 1.0.

If you do a search for Arduino ENC28J60 in Google it will come up with stuff about using voltage convertor to convert the boards 3.3V level to the Arduino's 5V level.  At the same time it is mentioned that the Arduino can handle lower voltage (I think as low as 2V) as a HIGH, so based on the recommendation from electrondragon I just wired the ENC28J60 directly to the pins of the Arduino with no problems at all.
It worked and there was no smoke.
NOTE: As always this is FYI and your smoke and funny smells may be different.

The final hurdle I had to overcome was that the kit I have has male-male jumper wires and as you can see from the picture the ENC28J60 board has pins rather than sockets, so my wires would not work.
I considered buying some male-female wires but then figured out I could use an old HDD IDE cable to convert the pins on the ENC28J60 board to sockets for my jumper wires.

All worked really well.


Now I have the test sketches working I'll have to examine the code and figure out how to do some more interesting things now that the Arduino is connected to the network.

From searching eBay it looks like the Chinese are now manufacturing cheap W5100 based shields that also include a micr-SD slot like the offical Arduino Ethernet shield.  More expensive than the ENC28J60 board but potentially more cost effective as from my readings the W5100 based boards are supported by the built in Ethernet library so no messing with 3rd party libraries that may be out of sync with the IDE (like my experience her)  Also the W5100 by all accounts provides more of the Ethernet stack so uses less memory on the Arduino and more robust.
After messing with the ENC28J60 I expect I will get a cheap W5100 board for doing anything serious.



Finally, there is no video for this one as I'm just running the standard Examples so nothing unique or special and I thought showing my screen equivalent to the electrondragon screens would be a bit of a waste.

Onwards and upwards.


UPDATE: Below is  a follow up post to this one giving a bit more detail on the wiring and the coding.
http://winkleink.blogspot.co.uk/2012/01/arduino-enc28j60-ethernet-module-part-2.html

UPDATE August 2012: A bit more fun with the ENC28J60 and using a web server coded in PHP to control it. http://winkleink.blogspot.co.uk/2012/08/arduino-ethernet-ethercard-xamp-web.html