[local server+ENC28J60] Heartbeat timeout


I work for a while on a ethernet project with NANO+ENC28J60.
To improve realibility, I’ve done several improvements:
-lighter sketch/variable size (83% sketch - 74% memory variables)
-lighter library uipethernet
-no widget terminal use (it made the project crashing more often)
-local server on rasp zero
-new bootloader on NANO for using watchdog and winning space

I’m nearly happy of the result now.
But I still have some heartbeat-> disconnect->watchdog issues I would like to understand.
The problem is still present if I use a very light sketch (see below), and happens sometimes (not always) on several devices at the same time.
The devices and the server are on the same LAN, so I don’t think about a network issue but more a server issue.

So the question is what could I check on the raspberry? Which file? (the admin page don’t seems to be useful for that…)

What I can see on serial when it happens ->

_[28408864] Heartbeat timeout: 28408864, 28392863, 28406866_
_[28408865] Disconnected_
_[28408886] Connecting to
_[28433732] Connecting to
_[28458734] Disconnected_
_[28458735] Connecting to
_[28483736] Connecting to
_[0] Using static IP_
_[1052] IP:
_[1053] _
_   / _ )/ /_ _____  / /___
_  / _  / / // / _ \/  '_/_
_ /____/_/\_, /_//_/_/\_\_
_        /___/ v0.4.8 on Arduino Uno_
_[1164] Free RAM: 467_
_[1186] Connecting to
_[2714] <[02|00|01|00] _
_[2715] <4dxxxxxxxxxxxxxxxxxxxxxxxae_
_[2760] >[00|00|01|00|C8]_
_[2761] Ready (ping: 46ms)._
//JUST CONNECT+WD R7   ->to test stability connection & debug (23648/1357)
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save flash space
#define BLYNK_DEBUG           // Optional, this enables lots of prints
#define BLYNK_NO_BUILTIN        // Disable built-in analog & digital pin operations to spare flash space
#define BLYNK_NO_FLOAT          // Disable float operations to spare flash space
#define BLYNK_NO_INFO           // Skip device info to spare flash space
#include <BlynkSimpleUIPEthernet.h>   // ENC28J60 ethernet BLYNK library
#include <avr/wdt.h>            // Watchdog library

char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";//R7////////////////////////////

  char Flag_Init_Boot='0';
  byte Counter_WD = 0;      // Count number of times ISR is called.
  unsigned long lastRunTime=0;
  float test=0;

// Mac address should be different for each device in your LAN
//byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };   //Original mac address
byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xAA, 0xA7 };             // modify the last 2 colomn hexa dicimal only ex.. (0xAA, 0xA1 };)

IPAddress localip ( xxxxxxxxxxxxxxx);       // your arduino i.p address, through ENC28J60
IPAddress mydns (xxxxxxxxxxxxxxxxx);
IPAddress gateway ( xxxxxxxxxxxxxxxxx);
IPAddress subnet  (xxxxxxxxxxxxxxxxxx);
IPAddress serverip (xxx, xx, xxx, xxx);           // your local server i.p address  
void setup() {
  Serial.begin(9600);                           // start serial for output  
  Blynk.begin(auth, serverip, <PORT>, localip, mydns, gateway, subnet, mac); // full IP config to spare 2.5k sketch

void watchdogSetup(void) {
cli();                   // disable all interrupts  PS: la fonction disable, puis enable ne fonctionne pas => j'utilise la méthode de config directe des registres WDTCSR et MCUSR
MCUSR = 0;               //to re-enable the interrupt by clearing the flag 1 in the bit WDRF -> automatique avec NANO OPTIBOOT au démarrage et après reset
wdt_reset();             // reset the WDT timer

WDTCSR |= (1<<WDCE) | (1<<WDE);   // Enter Watchdog Configuration mode:
WDTCSR = (1<<WDIE) | (0<<WDE) | (1<<WDP3) | (0<<WDP2) | (0<<WDP1) | (1<<WDP0);  // Set Watchdog settings:  ->interrupt only 8sec
Serial.println(F("WDT SETUP OK"));

ISR(WDT_vect) { // Watchdog timer interrupt code - be careful not to use functions they may cause the interrupt to hang and prevent a reset.
Serial.print(F("WD INTERRUPT COUNT="));Serial.println(Counter_WD);
 if (Counter_WD < 8)    //byte CounterMax_WD = 22;   // Timer expires after about 8x8sec = 64 secs (with WD timer=8 sec) -->>test 22 (~3minutes) KO, parfois reste planté!
   wdt_reset();     // start timer again (still in interrupt-only mode)
 else               // then change timer to reset-only mode with short (16 ms) fuse
  Serial.println(F("GO RESET IN 8SEC"));
  cli();                                // disable all interrupts
  WDTCSR |= (1<<WDCE) | (1<<WDE);       // Enter Watchdog Configuration mode:
  WDTCSR = (0<<WDIE) | (1<<WDE) | (1<<WDP3) | (0<<WDP2) | (0<<WDP1) | (1<<WDP0);    // Set Watchdog settings:  ->reset only 8sec

void loop(){  
unsigned long currentTime = millis();
while (Blynk.connected()==false) {Blynk.disconnect(); Blynk.connect();}  //wait connection serveur//semble mieux reprendre la connexion que Blynk.run(); //reste true ~10sec qd la connexion est perdue -> cfr heartbeat? & la boucle tourne au ralentis (~15sec) qd =false -> cfr fonctions discoonnect/connect?


  if (Flag_Init_Boot=='0'){                                         //envoi initial vers serveur BLYNK
  Blynk.notify(F("DEBUG R7"));
  if (currentTime - lastRunTime >= 5000) {            
  lastRunTime = currentTime;
  Serial.print("Serial= ");Serial.println(test);
  Blynk.virtualWrite(V19,String(test)); // affichage sur page LIVE = widget poids

wdt_reset();Counter_WD=0;   //reset timer watchdog & compteur interrupt  

Not really sure what you are looking for… but have you looked at the server log files?

I hope to find there informations about my disconnecting issues…

I’ve checked. It’s well the “blynk.log” file?
There is too few lines inside so I’ve to wait another issue to check.
Is it possible to increase the number of logs to keep?

@Alx-I there are different levels of logging available as per the entry in server.properties.
Increase the log level for test purposes and then return to the normal level when you find the problem.

I do that!