TechBlog

Teknik och filosofi

Troubleshooting the ENC28J60 Ethernet module for Arduino

inga kommentarer

 

I have bought some very cheap Ethernet modules for Arduino based on the ENC28J60 chip:

http://www.banggood.com/ENC28J60-Ethernet-LAN-Network-Module-Schematic-For-Arduino-51-AVR-LPC-p-87596.html

image

This is not your normal PC Network card, this little module has a full IP/TCP/UDP stack implemented in the chip. TCP channels are exposed to the Arduino as normal streams, and you have virtual no control below level 7 in the OSI model.

I had tremendous problem to get them working due to the fact that I didn’t know how to troubleshoot them correctly. This is a summary of what I have learned so far.

My setup is a Arduino Nano (cheap china clone) acting as a Web server.

Step 1: Ethernet Link

The Ethernet link will light up immediately when the chip is powered up and a network cable is connected. You only need to connect VCC and GND of the Ethernet module to get link. If this is not working, check you power connection.

Step 2: Use UIPEthernet library instead of the normal Ethernet library

The normal Ethernet library does not work with the ENC28J60 chip, you have to use the UIPEthernet library. This is a in-place replacement, just change your #include<> statements.

Step 3: Response to PING (and ARP)

ICMP Ping response is implemented in the ENC28J60, but not as you might think. In the WebServer example below I expected the module to response to ping right after you call Ethernet.begin(mac, ip) at line 44, but later I found out that the PING response starts working after the first call to server.available() at line 53.

image

Step 4: For stable operations, make sure you have enough power!

I had a very hard time to get stable operations over time with my module. It randomly hangs, sometimes after a few minutes and sometimes after a couple of hours. My research of the problems did not give me anything specific, but many discussions mentioned power problems.

I can now confirm that enough power is necessary for stable operations. When I powered my module from the 5V pin of my cheap China-Arduino-Nano-clone it failed to accept new client connections randomly. The cause of this is probably that the internal power regulator of the Arduino Nano simply can not power both the Arduino itself and the Ethernet module.

My recommendation is that you have a 5V power source (you standard USB phone charger?) and split the incoming power to feed both the Arduino through the VIN pin and the Ethernet module through the VCC pin. The ENC28J60 is 5V safe even if many connections specify 3.3V for the VCC pin.

Make sure to have a powerful USB Charger, some older charges had a limit of 0.5A current. Most newer chargers built for tablets capable of 2.1A.

Av kalle

september 5th, 2016 at 9:52 f m

Postat i Okategoriserade

Kommentera