In this illustration we will going to wire the ENC28J60 Ethernet Module. This module is another widely used network module for popular microcontroller, the early Arduino network module is accomplished by mean of ENC28J60, although later a new Arduino network module come up based on W5100 chip, but the ENC28J60 is also widely used due to stability and reliability.

With this Ethernet module your Arduino can be used to connect to internet capable adapting TCP/IP protocol stacks true Arduino Ethernet library, and web client application to access distributed network sensors. Can adapt EtherCard / EtherShield code library to perform low-level interfacing with network interfaces, a high level routine are provided to allow variety of purposes including simple data transfer though HTTP.

Ethernet-Shield221

Required Components

Arduino UNO/MEGA/NANO/PRO
ENC28J60 Ethernet Module
1x Resistor 220k
1x LED Red
Jumper Wires
Solder Less BreadBoard

Optional Components

Relay Module with Optocoupler/Isolator

Wiring Diagram

ENC28J60-Ethernet-Module-Home-Automation-Diagram-Wiring

Arduino Sketch Code

Download EtherShield Code Library | Zip
Download ENC28J60 Code library  | Zip

 

Wiring the ENC28J60 Ethernet Module on Arduino with Relay
Facebooktwitterredditpinterestmail
Tagged on:         

JLCPCBPCBgogoPCBway4pcb

3 thoughts on “Wiring the ENC28J60 Ethernet Module on Arduino with Relay

  • at
    Permalink

    Examples

    Several example scripts are provided with the library which demonstrate various features. Below are descriptions on how to use the library.

    Note: ether is defined globally and may be used to access the library thus: ether.member.
    To initiate the library call EtherCard::begin

    uint8_t Ethernet::buffer[700]; // configure buffer size to 700 octets
    static uint8_t mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; // define (unique on LAN) hardware (MAC) address

    uint8_type nFirmwareVersion ether.begin(sizeof Ethernet::buffer, mymac);
    if(0 == nFirmwareVersion)
    {
    // handle failure to initiate network interface
    }

    To configure IP address via DHCP use EtherCard::dhcpSetup

    if(!ether.dhcpSetup())
    {
    // handle failure to obtain IP address via DHCP
    }
    ether.printIp(“IP: “, ether.myip); // output IP address to Serial
    ether.printIp(“GW: “, ether.gwip); // output gateway address to Serial
    ether.printIp(“Mask: “, ether.mymask); // output netmask to Serial
    ether.printIp(“DHCP server: “, ether.dhcpip); // output IP address of the DHCP server

    To configure a static IP address use EtherCard::staticSetup

    const static uint8_t ip[] = {192,168,0,100};
    const static uint8_t gw[] = {192,168,0,254};
    const static uint8_t dns[] = {192,168,0,1};

    if(!ether.staticSetup(ip, gw, dns);
    {
    // handle failure to configure static IP address (current implementation always returns true!)
    }

    Send UDP packet

    To send a UDP packet use EtherCard::sendUdp

    char payload[] = “My UDP message”;
    uint8_t nSourcePort = 1234;
    uint8_t nDestinationPort = 5678;
    uint8_t ipDestinationAddress[4];
    ether.parseIp(ipDestinationAddress, “192.168.0.200”);

    ether.sendUdp(payload, sizeof(payload), nSourcePort, ipDestinationAddress, nDestinationPort);

    DNS Lookup

    To perform a DNS lookup use EtherCard::dnsLookup

    if(!ether.dnsLookup(“google.com”))
    {
    // handle failure of DNS lookup
    }
    ether.printIp(“Server: “, ether.hispip); // Result of DNS lookup is placed in the hisip member of EtherCard.

    Reply
  • at
    Permalink

    I been looking for this guide, anyway. thanks Ive eaten already. just wondering if its possible to make it on STM or PIC.

    Reply
  • at
    Permalink

    Hello.
    I am using an TP-LINK ethernet module.
    I have an doubt. You have written that
    “static uint8_t mac[6] = {0x54, 0x55, 0x58, 0x10, 0x00, 0x24}; // mac address of your Router”
    Here does the MAC id belongs to ENC28J60 or my TP-LINK ethernet router ??

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *