To connect an Arduino to an ENC 28J60 you will only need a few things: The Arduino, the ENC module and 6 wires.
To start we will discuss using the Arduino UNO then later in the guide we will discuss the differences between using the Arduino UNO and an Arduino Mega.
Connect the wires between the 2 devices in a manner depicted in the following Diagram
D13 | SCK | This is the SPI clock |
---|---|---|
D12 | SO | This is the output pin of the ENC |
D11 | SI | This is the input pin of the ENC |
D10 | CS | This is the Chip Select pin, by default this pin is set to 10 but can be change in the code |
VCC | 3.3V | Voltage supply. Highly important to use 3.3V and not 5V as to not damage the Module |
GND | GND | Ground |
All pins are defaults in the Library that we will use and the only one that can be altered is the CS pin.
When writing your code you should use the EthernetENC library. This library has functionality for these chips and allows you to receive information from them onto your Arduino. Additional information on the Library can be found here: https://docs.arduino.cc/libraries/ethernetenc/
This Library covers using the Arduino as a client or as a server
To connect to anything, you will need to define a few things to be used such as the following example:
Define:
Media Access Control (MAC) address, this is a unique identifier for the Arduino to other devices on the network.
IP Address, which is a unique label for devices on the network. When setting this the first three numbers of each device on the network should be the same (i.e. if connecting a laptop to the Arduino both addresses should start with 192, 168, 0 and the 4th number should be unique for each device)
Ethernet Server, this is the port that Arduino is going to send and listen on.
Then in your void setup function, you should write the following:
The serial.begin to set your serial BAUD rate
Ethernet.begin(mac, ip) initialises ethernet connection while using our previously defined mac address and IP address.
Lastly server.begin() begins server communication on the Arduino, it should now be listening on the defined port
If using an Arduino mega the pins should be swapped as such:
D52 | SCK |
---|---|
D50 | SO |
D51 | SI |
D53 | CS |
VCC | 3.3V |
GND | GND |