Arduino connection to Ethernet module
ENC28J60
1. installation of the library
The first step is to download and install the appropriate Arduino library, e.g. from github.com, and then you should:
- Unpack the downloaded archive
- Rename the unpacked folder for example EtherCard, then move with all content to the libraries folder in the Arduino folder
- Reboot the Arduino IDE environment, the new library should be added
2. the combination of systems
The next step is to physically connect the systems (e.g. with connection cables). This should be done according to the table below:
VCC |
3,3V | 3,3V |
GND |
GND | GND |
SCK |
PIN 13 | PIN 52 |
SO |
PIN 12 | PIN 50 |
SI |
PIN 11 | PIN 51 |
CS |
PIN 10 | PIN 53 |
Additionally, in the program for Arduino Mega, the line should be changed:
ether.begin(sizeof Ethernet::buffer, mymac)
on
ether.begin(sizeof Ethernet::buffer, mymac,53)//53 - is the CS line
3. sample programme
Then open the backSoon example in the newly added library and configure the values:
- myip - Arduino IP address
- gwip - the address of the default gateway, e.g. the address of a network router.
- mymac - unique MAC address of the module
These values will be used if the attempt to set a dynamic IP address - DHCP server - fails. To completely disable the attempt to connect via DHCP, enter the values 1 under STATIC definition (default value 0).
Next steps are to connect Arduino via USB, upload backSoon program with proper IP address configuration and default gateway.
In order to check the correct operation, you should:
- open the Serial Port Monitor located in the Arduino Tools Menu, set the baud rate to 57600 baud (as in the backSoon program)
- connect the network cable to the RJ-45 socket of the ethernet module
- restart the Arduino module using the RESET button
- after a dozen or so seconds, the serial port monitor screen should display the Arduino IP address
- then check the module's response to the ping command by running the command line and typing the ping x command, where x is the IP address of Arduino module. You can start the browser and enter the IP address of the module. A page should appear on the screen with information as in the picture below.