Mega freezes

When there is no internet connection in my Mega triggered watchdog. Watchdog 40 second.

Hey klbsss,

Can u give us more informations?
-Hardware configuration
-Programmcodes u’ve written
-Detailed information of your issue

Greetings Philipp

klbsss are you using WTD on the Mega?
Does it work without Blynk?
Does Blynk work without WTD?

I am guessing you are not using WTD as I believe the maximum timeout is 8 seconds.

```volatile int counter;  //Сторожевой таймер -счетчик
#define counterMax 5  //Number of times of ISR(WDT_vect) to autoreset the board. I will autoreset the board after 8 secondes x counterMax -- 8*5
ISR (WDT_vect)
{
        counter += 1;
        if (counter < counterMax - 1) {
            wdt_reset(); // Reset timer, still in interrupt mode
                         // Next time watchdogtimer complete the cicle, it will generate antoher ISR interrupt
        } else {
            MCUSR = 0;
            WDTCSR |= 0b00011000;    //WDCE y WDE = 1 --> config mode
            WDTCSR = 0b00001000 | 0b100001;    //clear WDIE (interrupt mode disabled), set WDE (reset mode enabled) and set interval to 8 seconds
                                               //Next time watchdog timer complete the cicly will reset the IC
        }
}
void wdt_long_enable()
{
    counter = 0;
    cli();    //disabled ints
    MCUSR = 0;   //clear reset status
    WDTCSR |= 0b00011000;    //WDCE y WDE = 1 --> config mode
    WDTCSR = 0b01000000 | 0b100001;    //set WDIE (interrupt mode enabled), clear WDE (reset mode disabled) and set interval to 8 seconds
    sei();   //enable ints
}

void wdt_long_disable()
{
    wdt_disable();
}
```

without WDT my mega hangs dead with blynk

1 Like

Blynk_v0.3.1
mega + esp-01 - AT22SDK100-2015-03-20-boot1.2 ( powered aside)

code very big

DEBUG
[20023] Cmd not sent
[35064] Cmd not sent
[50084] Cmd not sent

klbsss,

I see WDT at 8s X 5.

I think I might have experienced a similar issue. I am not using WDT at present but I will be implementing it shortly for our projects. One of our Blynk buttons resets our Arduinos but obviously it only works if the code is running correctly. Maybe one of our sensors has a problem that a reset might fix.

In our setup() just before the call to Blynk.begin(auth) we have a 33 second delay. I know Blynk tries to reconnect every 5 seconds but I think there is also a 30 send timeout in the ‘gateway’ software. So with our 33 second delay it allows the gateway to reset and all is fine. We comment out the delay most of the time but we might need to use it in out final production devices.

When I refer to gateways I mean the linux scripts or window bat files that open the port to the Blynk server.

You might try the 30+ second pause on reboot to see if this helps. If it doesn’t please provide more details about you are connecting to Blynk (USB Serial, Ethernet Shield, WiFi shield etc).

For reference we are usually using USB serial as our gateway connection via a Windows laptop. Just looking to use bridge or Python code to connect the Arduino to Blynk via a Raspberry Pi USB port.