BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Heartbeat timeout Uno R3 CH340 and ENC28J60


#1

hello,

i have a problem with my project, the controller goes every 2-5minutes offline, with Heartbeat timeout ,
i use: Uno R3 CH340 and ENC28J60 with new 0.4.4 blynk library and actually ENC28J60 ethernet library.

here is my code and serial log error:

/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 *
 * This example shows how to use ENC28J60 (UIPEthernet library)
 * to connect your project to Blynk.
 *
 * For this example you need UIPEthernet library:
 *   https://github.com/ntruchsess/arduino_uip
 * 
 * Typical wiring would be:
 *  VCC -- 5V
 *  GND -- GND
 *  CS  -- D10
 *  SI  -- D11
 *  SCK -- D13
 *  SO  -- D12
 *  INT -- D2
 *
 * Feel free to apply it to any other example. It's simple!
 *
 **************************************************************/

#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[] = "xyz";
int sensorPin = A3;    // select the input pin for the potentiometer
WidgetBridge bridge1(V1);
SimpleTimer timer; // Create a Timer object called "timer"! 

BLYNK_CONNECTED() {
  bridge1.setAuthToken("xyz2"); // Place the AuthToken of the second hardware here
}

void setup()
{
   Serial.begin(9600);
  Blynk.begin(auth);
   timer.setInterval(1000L, sendUptime); //  Here you set interval (1sec) and which function to call
}

void sendUptime()
{
  
  if (map(analogRead(sensorPin), 0, 1023, 0, 100) > 70) {
   bridge1.digitalWrite(5, LOW);//rot ein 0-active
   bridge1.digitalWrite(6, HIGH);//gruen aus 0-active
  }
  else
  {
   bridge1.digitalWrite(5, HIGH);//rot aus 0-active
   bridge1.digitalWrite(6, LOW);//gruen ein 0-active
  }
  

}

void loop()
{
  Blynk.run();
  timer.run(); // SimpleTimer is working
  
 
}

[0] Getting IP…
[6327] IP:192.168.177.151
[6328]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.4.4 on Arduino Uno

[6441] Connecting to blynk-cloud.com:8442
[31442] Connecting to blynk-cloud.com:8442
[32027] Ready (ping: 49ms).
[143117] Heartbeat timeout
[146169] Connecting to blynk-cloud.com:8442
[161234] Connecting to blynk-cloud.com:8442


#2

Could be several things. First thing I’m thinking is faulty hardware or bad wiring from the ENC to the Arduino. The ENC is very picky about it’s wiring, grounding and powersupply (believe me, I messed up a couple modules before I found out, lol). I’d highly recommend trying another ENC module or adding Wifi. It could also be the network cable, but that is highly unlikely. Try rebooting your router/modem, sometimes that worked for me.

I’ve had better results with Wifi than Ethernet.


#3

Hi,

I have the same problem, but I use blank Blynk example for ENC28J60. I tried with Arduino UNO + ENC28J60. Now I’m trying with Arduino Nano + ENC28J60.

Here is my output from Serial Monitor.

[1] Getting IP...
[5281] IP:172.16.230.128
[5282] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.4 on Arduino Nano

[5396] Connecting to blynk-cloud.com:8442
[20483] Connecting to blynk-cloud.com:8442
[20971] Ready (ping: 51ms). // sometimes 5 minutes, 30 or 2 hours.
[1856098] Heartbeat timeout
[1859101] Connecting to blynk-cloud.com:8442
[1874144] Connecting to blynk-cloud.com:8442
[1889183] Connecting to blynk-cloud.com:8442

and so on…
I tried on several routers and on several Ethernet cables. I don’t know where might be a problem. I have to add, that while the sketch is compiling i get lots of warnings:

#warning "Not defined ENC28J60_CONTROL_CS. Use borad default SS pin setting. You can configure in 'utility/Enc28J60Network.h'."
#warning "You can configure LogObject and ACTLOGLEVEL in 'utility/logging.h'. More verbosity more memory usage."
#define ntohs(x) htons(x)
#define ntohs htons
 #warning "You can configure LogObject and ACTLOGLEVEL in 'utility/logging.h'. More verbosity more memory usage."
#warning "You can configure LogObject and ACTLOGLEVEL in 'utility/logging.h'. More verbosity more memory usage."
#warning "You can configure LogObject and ACTLOGLEVEL in 'utility/logging.h'. More verbosity more memory usage."
#warning "Not defined ENC28J60_CONTROL_CS. Use borad default SS pin setting. You can configure in 'utility/Enc28J60Network.h'."
#warning "Not defined ENC28J60_CONTROL_CS. Use borad default SS pin setting. You can configure in 'utility/Enc28J60Network.h'."
#warning "You can configure LogObject and ACTLOGLEVEL in 'utility/logging.h'. More verbosity more memory usage."
#warning "Not defined ENC28J60_CONTROL_CS. Use borad default SS pin setting. You can configure in 'utility/Enc28J60Network.h'."
#warning "You can configure LogObject and ACTLOGLEVEL in 'utility/logging.h'. More verbosity more memory usage."
#warning "Not defined ENC28J60_CONTROL_CS. Use borad default SS pin setting. You can configure in 'utility/Enc28J60Network.h'."
#warning "You can configure LogObject and ACTLOGLEVEL in 'utility/logging.h'. More verbosity more memory usage."
#warning "Not defined ENC28J60_CONTROL_CS. Use borad default SS pin setting. You can configure in 'utility/Enc28J60Network.h'."
#warning "You can configure LogObject and ACTLOGLEVEL in 'utility/logging.h'. More verbosity more memory usage."
#warning "You can configure LogObject and ACTLOGLEVEL in 'utility/logging.h'. More verbosity more memory usage."
#warning "You can configure LogObject and ACTLOGLEVEL in 'utility/logging.h'. More verbosity more memory usage."

I have the latest version of Blynk library v0.4.4. I also use UIPEthernet library v1.59 for Arduino-IDE Version 1.5.5 and higher from link in the sketch. I use Arduino IDE 1.6.10.

What can I do with this problem?


#4

I have problems to with Uno and enc28j60 . With other no blynk sketchs and ethercard library work ok. I think is a problem with uipethernet library. After some minuts or hours the enc hangs. A possible solution is stop and start the enc with powerOff() and powerOn() functions every 30 minuts, but my skills in C are small for do it.


#5

@jnogues maybe try to get external IP at timed intervals and if it fails, reset Arduino.


#6

Inside the library are the powerOn() and powerOff() functions and I think is the solution.


#7

I have an ENC hooked up to my Mega but it’s not something I use. Maybe a regular ENC user will take a look at the problem or perhaps I’ll set mine running to see if it hangs. I only ever run it for a few minutes for testing purposes.


#8

Probably cassyarduino or aquarius could help us!!


#9

Do You also have a problem with warnings while sketch is compiling in Arduino IDE? I’m afraid that it can be a main problem.


#10

No. All works ok, for a time. The problem is with enc28j60 shield. After a time hangs. The time could be minuts or hours.
Somebody is using this shield 24h/7d ? And works ok?


#11

Ok, so maybe you know why I get lots of warnings?

Edit: I’m new in Blynk, so I don’t know what is good. What are you using to Blynk? Maybe ESP8266 NODEmcu v3 will be good option?


#12

I use this library: https://github.com/UIPEthernet/UIPEthernet, IDE 1.8.1, blynk 0.4.4 whith a example sketch adding this function, execute every minut by simpleTimer for test it

void publishMillis()
{
   unsigned long m=millis()/1000L;
   Blynk.virtualWrite(V15,m);
   Serial.println(m);
   Enc28J60.powerOff();//leds on enc28j60 off!!
   delay(100);
   Enc28J60.powerOn(); leds on enc28j60 on!!
}

Is not a elegant solution but if it works…
After 2 hours working ok!
Edit: don’t work!!


#13

WeMos D1 Mini or ESP8266 Mini Clone (I use clones and they’re great)


#14

Normally I use nodeMcu and UNO+wiznet5100shield, but I have some boards with enc28j60 than I want use with blynk. I’m fighting for do it. Now I try another option:

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

More news later…

One hour working…


#15

So You defined this function in your sketch, and you’re using it in loop?

Like this:

void loop()
{
  Blynk.run();
  timer.run(); // SimpleTimer is working
  publishMillis();
}

Good?


#16

Hopefully not as that goes against all things Blynk.
Presumably @jnogues is using the recommended method of calling the function with SimpleTimer.


#17

In loop() NO!!! I call it every 10 minutes via SimpleTimer.
At this moment 3 hours working.


#18

Ok, now I understand. But I don’t know what is arduino_mac?

Edit: I know that it is mac addres, but where can I find it?


#19

Now stops! This is not the solution!!:smiling_imp:


#20

New day, new forces… Now I’m trying this branch of UIPEthernet:
https://github.com/seydamir/arduino_uip
It includes a patch for silicon errata 12 of the chip. ( https://github.com/seydamir/arduino_uip/commit/bf5daee9f29d6da4070acbcb501772fd84531b8b )
One hour and working…
Edit: 4 hours working!! a new record!!