Watchdog on 2.0
-
Not that I know anything... About anything... Yeah, I'm new here...
What about using a hardware WDT? For instance the freetronics one?
http://www.freetronics.com.au/collections/modules/products/watchdog-timer-module
I have sensors up in my attic and have been thinking about using a hardware WDT.
During the summer, it gets really hot up my attic, and I hate going up there.
Rob
</end first post>
IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n>So yeah .. the mqttclient will try to reconnect until .. like ever I just tested it for like 30 seconds but I don't think there will be a "timeout".
-
Not that I know anything... About anything... Yeah, I'm new here...
What about using a hardware WDT? For instance the freetronics one?
http://www.freetronics.com.au/collections/modules/products/watchdog-timer-module
I have sensors up in my attic and have been thinking about using a hardware WDT.
During the summer, it gets really hot up my attic, and I hate going up there.
Rob
</end first post>
@treborjm87 The Atmega328P has already an buildin hardware watchdog. It will reset your node if you don't feed it via
wdt_reset(); -
@treborjm87 The Atmega328P has already an buildin hardware watchdog. It will reset your node if you don't feed it via
wdt_reset();@cimba007 -- I really didn't know that the Arduino already had a WDT... But, what if it is the Atmega that is locked up? I suspect that my clone Arduinos are susceptible to heat and are unable to reset themselves... (Yeah, a bigger issue that what this topic is about). Thanks for the information!
Rob
-
@treborjm87 The fault is not with your cloes but .. well .. how should I put it .. the Watchdog on almost all "Arduino pro mini" clones from china is broken. Normally the watchdog gets disabled during bootloader (just after the reset) but on these clones the default bootloader dosn't do this .. leading to an infinite boot loop.
This issue can be solved by connecting an Arduino set up as ISP-Programmer and burning the current Arduino bootloader.
As the pro minis come unsoldered I made myself a little adapter consisting only of male pin headers where I can put the pro mini in. The pins are not connected very good but pressing the pro mini in place I can very easylie reflash the bootloader before I put them into my projects.
-
@treborjm87 The fault is not with your cloes but .. well .. how should I put it .. the Watchdog on almost all "Arduino pro mini" clones from china is broken. Normally the watchdog gets disabled during bootloader (just after the reset) but on these clones the default bootloader dosn't do this .. leading to an infinite boot loop.
This issue can be solved by connecting an Arduino set up as ISP-Programmer and burning the current Arduino bootloader.
As the pro minis come unsoldered I made myself a little adapter consisting only of male pin headers where I can put the pro mini in. The pins are not connected very good but pressing the pro mini in place I can very easylie reflash the bootloader before I put them into my projects.
@cimba007 --- That's great information!
I'll try this out!
Thanks for letting me butt into your topic...
Rob
-
Not that I know anything... About anything... Yeah, I'm new here...
What about using a hardware WDT? For instance the freetronics one?
http://www.freetronics.com.au/collections/modules/products/watchdog-timer-module
I have sensors up in my attic and have been thinking about using a hardware WDT.
During the summer, it gets really hot up my attic, and I hate going up there.
Rob
</end first post>
@treborjm87 I have Jon Oxers page bookmarked. Looking into this is a possibility myself.
-
IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n> IP: 192.168.178.87<\r><\n> 0;255;3;0;9;Attempting MQTT connection...<\n>So yeah .. the mqttclient will try to reconnect until .. like ever I just tested it for like 30 seconds but I don't think there will be a "timeout".
@cimba007 That's kind of what I figured. When I got home I tested trying to send something from one of my nodes without power cycling my gateway. No luck. I setup a mock sensor and had it blasting out messages. Nothing. Power cycled the gateway, everything started responding. I disconnected power from gateway and turned off the mqtt server. Booted both back up and they recovered. So my next step is going to have to be to hook a serial connection up and hope I can catch it the next time it goes bad. Cause it looks like either the radio or the arduino is locking up. I may just flash the working watchdog bootloader to it and enabling the watchdog. I saw in the core that there is already the watchdog reset. So do I just need to enable it with something like
wdt_enable(WDTO_8S);in the setup?
Thanks!
-
I checked the sourcecode and it seems that only parts of the watchdog are implemented. I enabled the watchdog the following way:
At the beginning of the sketch
#include <avr/wdt.h>Later at
void before() { wdt_disable(); // maybe redundant wdt_enable(WDTO_8S);And finally at the loop
void loop() { wdt_reset();Advanced reading:
The sleep() method on mysensors does something special with the watchdog. It enabled the interrupt flag and defines an empty
// Watchdog Timer interrupt service routine. This routine is required // to allow automatic WDIF and WDIE bit clearance in hardware. ISR (WDT_vect) { }When the Atmega328p engages sleep mode the watchdog timeout is overwritten with your designated sleep period. The watchdog then times out and calles the service routine (ISR). After the ISR-routine finished the interrupt flag is disabled. This leeds to an reset at the next imeout of the watchdog.
Normal reading again ;-)
Luckyly the sleep() routine is smart enough to save and restore your custom watchdog settings. When the watchdog times out (as the interrupt flag is not set) the Atmega328p resets. In the bootloader the watchdog is disabled until you enable it in thebefore()-Method again. -
I checked the sourcecode and it seems that only parts of the watchdog are implemented. I enabled the watchdog the following way:
At the beginning of the sketch
#include <avr/wdt.h>Later at
void before() { wdt_disable(); // maybe redundant wdt_enable(WDTO_8S);And finally at the loop
void loop() { wdt_reset();Advanced reading:
The sleep() method on mysensors does something special with the watchdog. It enabled the interrupt flag and defines an empty
// Watchdog Timer interrupt service routine. This routine is required // to allow automatic WDIF and WDIE bit clearance in hardware. ISR (WDT_vect) { }When the Atmega328p engages sleep mode the watchdog timeout is overwritten with your designated sleep period. The watchdog then times out and calles the service routine (ISR). After the ISR-routine finished the interrupt flag is disabled. This leeds to an reset at the next imeout of the watchdog.
Normal reading again ;-)
Luckyly the sleep() routine is smart enough to save and restore your custom watchdog settings. When the watchdog times out (as the interrupt flag is not set) the Atmega328p resets. In the bootloader the watchdog is disabled until you enable it in thebefore()-Method again. -
wdt.h is included on Arduino IDE.
This example show how it's work:#include <avr/wdt.h> int counter=0; void setup(){ wdt_disable(); Serial.begin(9600); Serial.println("Starting..."); delay(1000); wdt_enable(WDTO_8S); } void loop(){ wdt_reset(); Serial.println(counter); counter++; if(counter==5){ while(true){} } delay(500); }```