Hayes modem with Arduino and ENC28J60 ethernet module

Written March 24th, 2021 by

I had this ENC28J60 ethernet module in my drawer, purchased months ago and practically never used, so I thought I could use it to make an Hayes-compatible modem on a wired ethernet network. It could be a valid alternative to WiFi modems for environments where the signal does not arrive very well. It also helps to recreate the cable crowding typical of the past years.

Microchip’s ENC28J60 chip is used to equip a microcontroller capable of communicating through a standard SPI serial connection, such as Arduino’s ATMEGA328, with an ethernet network interface. However, the chip alone is not enough and it is necessary to implement the TCP/IP stack via software to be able to connect to another computer through the internet, so I used the library UIPEthernet compatible with the ENC28J60.

The emulation of the Hayes commands comes directly from my other project WiFiModem with which I created the equivalent for WiFi modules with ESP8266. The code is virtually identical except for some minor adaptations.

For the connection to the PC I initially used the standard hardware serial which seemed to work correctly when Arduino is not connected via USB, however testing everything with other computers like RC2014 and my P8X180 it turned out that, even if not connected, the ATmega8U2 that realizes the USB-Serial interface of Arduino, interferes in some way making communication impossible. I therefore added a software serial on pins D2 and D3 for the connection to the PC or retro-computers which does not interfere in any way.

The complete sketch is available from GitHub.

Wiring the ethernet module with Arduino UNO.

The ENC28J60 module connects to Arduino through the pins associated with the SPI interface. They are available on both the standard stripline connectors and the 6-pin ICSP connector located in the center on the right side. For the sake of representation I have chosen to connect the pins on the standard connectors.

ArduinoUno_ENC28J60

ENC28J60 Arduino UNO
CS D10
SI D11
SO D12
SCK D13
RESET RESET
VCC 3.3V
GND GND

The PC, or other similar device equipped with a TTL serial port, to be used with the modem, must be connected using the 6-pin standard connector visible at the bottom left.

Serial Arduino UNO
DCE DTE
6 N.C. N.C.
5 D3 D2
4 D2 D3
3 5V (optional) 5V (optional)
2 N.C. N.C.
1 GND GND

The use of RTS/CTS hardware flow control signals is not supported. Pin D4 is set to 1 when the modem is connected to a server and can be used as a DCD (Data Carrier Detect) signal.

Pin 3 can be used to power Arduino and the ENC28J60 module from the connected serial device or, vice versa, to power the serial device from Arduino. In both cases, make sure that enough current is supplied to support all devices.

The DCE wiring must be used if the modem is connected to a PC via a standard USB-Serial adapter. The DTE wiring must be used for all those devices to which a USB-Serial PC adapter is normally connected (for example the Z80 RC2014 computer is one of these). The difference between the two relates to the direction of pins 4 and 5.

Image Gallery

Arduino-ENC28J60-1Arduino-ENC28J60-2
Arduino-ENC28J60-Minicom1Arduino-ENC28J60-Minicom2