May 16, 2014

Arduino Ethernet module ENC28J60

Hi

It has been some time since my last post about Arduino / embedded development, you know..... well, I'll not give the usual excuse of lack of time ;)

This post is about my last victory! Some one and half years ago I bought, a cheap, Ethernet module (ENC28J60) (similar to the one in the picture below) so I could do some experiments.

It happens that I failed miserably to get it working and I ended up ordering a Ethernet Shield (W5100) (which worked with no problems) and gave up on this module. 

Some days ago while I was checking my electronics junk stuff I found it again and decided I was ready to give it another try.

After reading a lot of blog posts, articles, documentation, etc, I finally succeeded and get it to work with the following configuration:
  • Arduino Leonardo
  • This library to access TCP/IP thought the ENC28J60 module (with the suggested modifications from this post) (which are only required / necessary for Arduino Leonardo)
  • Connections as described on the same post cited above.
To make it easier I posted the connections below:

ArduinoENC28J60
ICSP
HEADER
MISOSO
MOSISI
SCKSCK
RESETRST
I/O
PINS
VCC (3.3V)VCC
GNDGND
10CS
INT(2)INT






Below you can see a nice Arduino Leonardo diagram.



Note that on another Arduinos (like Mega / Uno), ICSP connector is also connected to the "normal I/O pins" but not on Leonardo so you must use the ICSP connector in order to connect the Arduino to the module.


The last piece that is missing was to change the file EtherCard/enc28j60.cpp as follows:

void ENC28J60::initSPI () {
    pinMode(SS, OUTPUT);
    digitalWrite(SS, HIGH);

    // rest of the code....
}

to:

void ENC28J60::initSPI () {
     pinMode(10, OUTPUT);
     digitalWrite(10, HIGH);


    // rest of the code....

This change was required because the SS constant is defined with a different value (17) than the pin I chosed (10).

Finished! Now it was only a matter of taking one of the ENC28J60 library examples, change it a little bit and some 60 mins later I had an web server running on my Arduino Leonardo.

What do you think? Pretty cool, IMO! :)

Happy Coding.

(Leia este post em Portugues)

No comments: