WiFi LAN Converter With ESP32 and ENC28J60 Module

Electronics and Programming tutorials and projects

WiFi LAN Converter With ESP32 and ENC28J60 Module

wifi lan esp32 enc28j60

This project is a WiFi to LAN with “ENC28J60” and “ESP32” firmware arduino source code (.ino).

The project gives you an internet access via WiFi modem, over the LAN port (like USB WiFi stations).

Simply you can plug the ESP32 power, configure it with the modem’s SSID and Password, connect your PC or laptop to the “ENC” module with a RJ45 LAN cable and access to the internet.

The project contains the following files:

  1. ESP32ENCWiFiLan.ino (Main handler file)
  2. user_global.h – Project global variables and definitions file.
  3. user_init.ino – Project initial script file.
  4. user_loop.ino – This file has a “userLoop()” function which calls repeatedly (like arduino “loop()” function).
  5. user_settings.ino – Project settings file.
  6. user_global.ino – This file has the global functions.
  7. Webapp.h – This file contains the WebApp’s script.

Uploading the WiFi LAN project

First open one of the files with Arduino program, then set the settings as the following image (Board and Flash Frequency).

  • The “Board” must be set on one of the ESP32 Modules before doing anything.

And then click on the upload button, the firmware will compile and automatically upload to the ESP32 module.

ENC28J60 LAN Module

This module (which is called “MINI ENC28J60” too) has an ENC28J60 chip, an RJ45 port and a pin header which lets you to communicate with the main chip via SPI protocol.

The chip converts LAN Rx and Tx data to the SPI protocol and buffer it until the host receives it and sends the response back.

The WiFi-LAN Schematics

The schematic is so simple. Just connect the wire as the following picture:wifi lan schematic

  • If you are using another ESP32 board (or ESP32 Module), connect the wires to the same ESP32’s GPIO pins.

WiFi LAN Configuration

Before access to the internet via the LAN cable, setup the WiFi connections.

Then turn on the ESP32 module by plugging its USB cable and connect to its hotspot (WiCardWiFiLan by default). The default password is: 12345678

The default web application address is 192.168.4.1, insert the address in a web browser’s address bar to access to the configuration page.

  • If you don’t have a WiFi support device, you can plug the LAN cable and go to 192.168.6.1 with a web browser.

The configuration has been divided to 5 parts:

  1. Modem Configuration
    In this section you can see the available access points, the connection status, the device MAC address and the DHCP IP.
    Also in this section you can set the SSID and password of the modem’s access point.
  2. Device Hotspot Configuration
    In this section you can set your module’s hotspot SSID and password.
    The secure link is a string which will be added at the end of your module’s IP address. For example if you set it “123”, the IP address of the WebApp of your module will be 192.168.4.1/123 instead 192.168.4.1
    The even means the default IP is 192.168.4.1, the Odd means the default IP is 192.168.5.1
    Hidden HotSpot will set the HotSpot hidden.
    Temporary HotSpot will disable the HotSpot right after the module is connected to the modem or joined to the network (For the last device in the network).
  3. NAT Configuration
    In this section you can set the DNS server ip address. The default is: 8.8.8.8
wifi lan dns server

Access to the Internet

After the configuration, re-start the module, wait for a few seconds until ESP32 registers itself to the WiFi modem.

Then plug the LAN cable in your PC or laptop.

  • In case you are using windows 7, turn off your laptop WiFi device before plugging the LAN cable.

Wait for a few seconds until DHCP done. Then your PC or laptop IP would be 192.168.6.2 and the WiFi LAN IP would be 192.168.6.1 and you can access to the WiFi modem Internet via you WiFi LAN device.

  • Due too low buffer size of ENC28J60 and the low process speed of ESP32, this firmware can handle a few connections at the same time. So it’s suggested do not open multiple tabs in your browser.
  • This is the first release of this project, and it is a good tutorial for Ethernet, IP, TCP-UDP and DHCP headers. In the next releases I will try to increase the firmware abilities.
  • This release doesn’t support “ping” command.

The project is available in the following:

More projects in our Blog.

 

2 Responses

  1. Ezequiel Martínez Larraignet says:

    muy buen proyectoo graciaas por el aporte. saludos desde argentina

Leave a Reply

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

2 × four =