I've just started learing more about electronics (Other than the regular soldering and diagram reading from school.) and I'm trying to use an ENC28J60 ethernet module from dealextreme, together with an Arduino Mega 2560 drom dealextreme as well. What my project is all about, is controlling an robot over WiFi using my Android phone (Having the arduino hooked up by cable to a router, and my phone to the router over WiFi.). But I've already gotten my head into the deep end of the pool.
The first problem is that I can't find any updated guides on how to connect the ethernet module to the Arduino itself. Pin configuration, libraries to use etc. One of the setups that I tried is from (Arduino ENC28J60 Ethernet Module - Geeetech Wiki), but that one doeasn't seem to work as of v1.0. The only thing that happens, is that the DI diod light up red on the ethernet module.
Other than that I've tried the deafult examples from the Arduino soeftware, but no luck there eather.
What do I do? I'm desperate for a solution, as I've done a mere 1% of this project during the last two months. =(
(Yes, I've tried to search the forum for a solution to this. But I've found none.)
Hope it will help Do not hesitate to ask if you need any further informations, I'll do my best to help.
Edit : you might easily find the mapping between the pin numbers of an Uno and your Mega2560 (also check the library's source for pin numbers)
This sounds really promising! I will try it out as soon as possible. But there was one thing on the blog that I didn't quite understand.
What did you mean by "* = CS should be logically connected to a D10 or Arduino Uno pin 16 on a ATMega328 (Slave Select), but the library uses the following D8 / pin 14 by default."? Which pin do I connect the CS to, and how? :~
Update: I tried what the blog sugested. And it did not work. I tried switching the pings around, using DCHP and static address, but to no avail.
I just gave a quick look to the source code of the EtherCard library (especially enc28j60.cpp) and figured that it should be compatible with Arduino Mega 2560 out of the box.
Here's the portion of code that defines the pin numbers :
This english translation : "CS should be logically connected to a D10 or Arduino Uno pin 16" is not correct. I mean to say that Slave Select on the ATMega328 is pin 16 (D10 on Arduino Uno, D53 on Arduino Mega 2560), but I read somewhere pin 8 on Uno should be used, and it worked like this for me.
However, it looks strange as D10 is actually defined as SS pin in the library's source code ... you should try both to figure which one is correct (and do not hesitate to keep me posted ;))
Basic stuff : you need to add ",_cspin" in the begin() call in the example sketches for them to work. For some obscure reason, there is a "default cs=8" in several places, that already lead dozens of people into confusion.
Consistently writing it
if (ether.begin(sizeof Ethernet::buffer, mymac,10) == 0)
and replacing the 10 by 8 if you're using a Nanode, 53 for MEGA, etc. would have helped may people a lot.
The trouble comes from the fact that you have three "levels" of library here : the spi.h, the enc28j60.h and the ethercard.h
Then depending on the versions, your server etc, you may or may not have DHCP working.