Heartbeat timeout Uno R3 CH340 and ENC28J60

I’m trying with you :slight_smile:
My sketch:

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <UIPEthernet.h>
#include <BlynkSimpleUIPEthernet.h>
#include <SimpleTimer.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

byte arduino_mac[]={0x48,0x45,0x87,0xA4,0x55,0x23};

SimpleTimer timer;

void publishMillis()
{
   unsigned long m=millis()/1000L;
   Blynk.virtualWrite(V15,m);
   Serial.println(m);
   Enc28J60.init(arduino_mac); 
}

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth);

  timer.setInterval(600000L, publishMillis);
}

void loop()
{
  Blynk.run();
  timer.run();
}

I invented the mac address, but when the publishMillis function is calling I’m losing connection.

[0] Getting IP...
[5272] IP:172.16.230.189
[5273] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.4 on Arduino Nano

[5387] Connecting to blynk-cloud.com:8442
[20466] Connecting to blynk-cloud.com:8442
[20907] Ready (ping: 51ms).
620
[627021] Heartbeat timeout
[630026] Connecting to blynk-cloud.com:8442
[645068] Connecting to blynk-cloud.com:8442

Hi. Forget the idea of Enc28J60.init(arduino_mac);
Use the seydamir library. For me is working OK in 7 hours and counting.

1 Like

Yes, i downloaded this library. I have the latest version of IDE. I get lots of warnings during compiling. After compiling it’s working ok. But after some time I’m getting Heartbeat timeout :expressionless: I don’t know where I’m wrong…

Here is my sketch:

//file IoT-eth-00.ino
//Internet of Things, Institut Tecnologic Rambla Prim
//Jaume Nogues jnogues@gmail.com
// http://vps249990.ovh.net/iot/
// http://jnogues.org

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <UIPEthernet.h>//ENC28J60 https://github.com/seydamir/arduino_uip
#include <BlynkSimpleUIPEthernet.h>//ENC28J60

char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxx";
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };

#include <SimpleTimer.h>
SimpleTimer timer;

boolean stateI2=0;
boolean prevStateI2=0;
boolean stateI8=0;
boolean prevStateI8=0;
boolean stateIA2=0;
boolean prevStateIA2=0;
boolean stateIA1=0;
boolean prevStateIA1=0;
boolean stateQ3=0;
boolean prevStateQ3=0;
boolean stateQ7=0;
boolean prevStateQ7=0;
boolean stateQA3=0;
boolean prevStateQA3=0;
boolean stateQ9=0;
boolean prevStateQ9=0;

void setup()
{
  pinMode(2,INPUT);
  pinMode(8,INPUT);
  pinMode(A2,INPUT);
  pinMode(A1,INPUT);
  pinMode(3,OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(A3,OUTPUT);
  pinMode(9,OUTPUT);
  
  Serial.begin(115200);
  Blynk.begin(auth, "blynk-cloud.com", 8442, arduino_mac);
  
  timer.setInterval(200L, checkInputsOutputs);
}

void loop()
{
  Blynk.run();
  timer.run();
}

BLYNK_CONNECTED() 
{ 
 Blynk.syncAll();
 //Serial.println(".");
}

BLYNK_READ(15)
{
   unsigned long m=millis()/1000L;
   Blynk.virtualWrite(V15,m);
   Serial.println(m);       
}

void checkInputsOutputs()
{
     stateI2=digitalRead(2);
     if (stateI2!=prevStateI2)
     {
     if (stateI2==0) Blynk.virtualWrite(V2,0);
     if (stateI2==1) Blynk.virtualWrite(V2,255);
     }
     prevStateI2=stateI2;
    
     stateI8=digitalRead(8);
     if (stateI8!=prevStateI8)
     {
     if (stateI8==0) Blynk.virtualWrite(V8,0);
     if (stateI8==1) Blynk.virtualWrite(V8,255);
     }
     prevStateI8=stateI8;
    
     stateIA2=digitalRead(A2);
     if (stateIA2!=prevStateIA2)
     {
     if (stateIA2==0) Blynk.virtualWrite(V12,0);
     if (stateIA2==1) Blynk.virtualWrite(V12,255);
     }
     prevStateIA2=stateIA2;
    
     stateIA1=digitalRead(A1);
     if (stateIA1!=prevStateIA1)
     {
     if (stateIA1==0) Blynk.virtualWrite(V11,0);
     if (stateIA1==1) Blynk.virtualWrite(V11,255);
     }
     prevStateIA1=stateIA1;
    
     stateQ3=digitalRead(3);
     if (stateQ3!=prevStateQ3)
     {
     if (stateQ3==1) Blynk.virtualWrite(V3,255);
     if (stateQ3==0) Blynk.virtualWrite(V3,0);
     }
     prevStateQ3=stateQ3;

     stateQ7=digitalRead(7);
     if (stateQ7!=prevStateQ7)
     {
     if (stateQ7==1) Blynk.virtualWrite(V7,255);
     if (stateQ7==0) Blynk.virtualWrite(V7,0);
     }
     prevStateQ7=stateQ7;

     stateQA3=digitalRead(A3);
     if (stateQA3!=prevStateQA3)
     {
     if (stateQA3==1) Blynk.virtualWrite(V13,255);
     if (stateQA3==0) Blynk.virtualWrite(V13,0);
     }
     prevStateQA3=stateQA3;

     stateQ9=digitalRead(9);
     if (stateQ9!=prevStateQ9)
     {
     if (stateQ9==1) Blynk.virtualWrite(V9,255);
     if (stateQ9==0) Blynk.virtualWrite(V9,0);
     }
     prevStateQ9=stateQ9;
}

House, is still working without issues, 15 hours. I use the Uno, but you the nano, is OK?
Try with a UNO!!

Yes, i used nano. Ok, now I’m trying with your code and Arduino UNO. I’m using other mac address and my auth token :smiley:
And I do like this:

 * Typical wiring would be:
 *  VCC -- 5V
 *  GND -- GND
 *  CS  -- D10
 *  SI  -- D11
 *  SCK -- D13
 *  SO  -- D12
 *  INT -- D2

We will see…

No problem with use my mac address, but if you have two devices using in the same subnet the same MAC then there are a problem.
Now my blynk enc28j60 + UNO is working without problem from yesterday 7:00h ( now are 14:01 in Barcelona).
Good luck!!!

2 Likes

Hi, 12 hours without crash :+1: Only twice I got Heartbeat timeout, but it returned to the connection itself - very fast :slight_smile: I’m still testing, but I think that I can make a project with it.

The mine is still working too. After more tests I propouse than blynk team recomend this library as default for enc28j60.

Regards

Hi All!

Please try actual version of UIPEthernet.
I fixed the errata#12.

Best Regards

Hi. I use the 2.0.6 version of library (lastest), ENC28J60 and Arduino Mega. I can’t check now will it work, but I have the same error while compiling. I checked all folders for redefentions, there’s no matter. I installed it from Library Manager of Arduino IDE. an you help me?

Can you send me a library please? You can get it from sketchbookfolder/libraries/…
Seydamir deleted his account on GitHub…(