Unstable Connection ENC28J60 / HanRun HR911105A with Nano

Hi guys,

I have trouble to get a stable connection with a HanRun HR911105A with a Arduino Nano 3.0

I’m using the Libary “ethercardMaster” (https://github.com/jcw/ethercard)

My problem:
After some (random) time, the connection to the Server is getting unstable - I get no results back. I’am testing yesterday 10 hours to get that fixed, but without success. I also make a very big workarround to automatically restart the board if the connection is hanging, but this is no solution :frowning:

Sometime it works 1 minute, sometime 2 hours…

Thank you very much for any help! :slight_smile:

This is the Code (Democode, called Webclient):

// Demo using DHCP and DNS to perform a web client request.
// 2011-06-08 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[700];
static uint32_t timer;

char website[] PROGMEM = "www.softairforum.org";

// called when the client request is complete
static void my_callback (byte status, word off, word len) {
  Ethernet::buffer[off+300] = 0;
  Serial.print((const char*) Ethernet::buffer + off);

void setup () {

  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) 
    Serial.println( "Failed to access Ethernet controller");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);  
  ether.printIp("DNS: ", ether.dnsip);  

  if (!ether.dnsLookup(website))
    Serial.println("DNS failed");
  ether.printIp("SRV: ", ether.hisip);

void loop () {
  if (millis() > timer) {
    timer = millis() + 5000;
    Serial.print("<<< REQ ");
    ether.browseUrl(PSTR("/foo/"), "bar", website, my_callback);

Here an example Result:



<<< REQ >>>
HTTP/1.0 404 Not Found
Connection: close
Content-Type: text/html
Content-Length: 345
Date: Thu, 27 Dec 2012 11:01:01 GMT
Server: lighttpd/1.4.19

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<<< REQ 
<<< REQ 
<<< REQ 
<<< REQ 
<<< REQ


Unfortunately, I get the same kind of errors, but often after several days which makes testing / debugging quite difficult
The first step I did to reduce the number of errors was to go from 3V3 to 5V alimentation as I noticed that my Nano copy was delivering a mere 3.1V wich was not sufficient

Still investigating ...

Did you guy manage a solution for this problem?


I managed to reduce the frequency of errors by optimizing memory usage (using tips found on this very forum), but still have connection issues (i.e. sometimes 2 days after restart, sometimes 3 weeks)
I now suspect a memory allocation issue somewhere in my code ...