Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. General Discussion
  3. Watchdog on 2.0

Watchdog on 2.0

Scheduled Pinned Locked Moved General Discussion
2.0mqttwatchdog
19 Posts 6 Posters 9.6k Views 6 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • treborjm87T treborjm87

    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>

    cimba007C Offline
    cimba007C Offline
    cimba007
    wrote on last edited by cimba007
    #10
    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".

    CrankyCoderC 1 Reply Last reply
    0
    • treborjm87T treborjm87

      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>

      cimba007C Offline
      cimba007C Offline
      cimba007
      wrote on last edited by
      #11

      @treborjm87 The Atmega328P has already an buildin hardware watchdog. It will reset your node if you don't feed it via

      wdt_reset();
      
      treborjm87T 1 Reply Last reply
      0
      • cimba007C cimba007

        @treborjm87 The Atmega328P has already an buildin hardware watchdog. It will reset your node if you don't feed it via

        wdt_reset();
        
        treborjm87T Offline
        treborjm87T Offline
        treborjm87
        wrote on last edited by
        #12

        @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

        1 Reply Last reply
        0
        • cimba007C Offline
          cimba007C Offline
          cimba007
          wrote on last edited by
          #13

          @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.

          treborjm87T 1 Reply Last reply
          0
          • cimba007C cimba007

            @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.

            treborjm87T Offline
            treborjm87T Offline
            treborjm87
            wrote on last edited by
            #14

            @cimba007 --- That's great information!

            I'll try this out!

            Thanks for letting me butt into your topic...

            Rob

            1 Reply Last reply
            0
            • treborjm87T treborjm87

              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>

              CrankyCoderC Offline
              CrankyCoderC Offline
              CrankyCoder
              wrote on last edited by
              #15

              @treborjm87 I have Jon Oxers page bookmarked. Looking into this is a possibility myself.

              Home Automation Tinkerer
              www.CrankyCoder.net

              Controller: HomeAssistant in Kubernetes
              Gateway: MQTTClientGateway
              MySensors: 2.3

              1 Reply Last reply
              0
              • cimba007C cimba007
                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".

                CrankyCoderC Offline
                CrankyCoderC Offline
                CrankyCoder
                wrote on last edited by
                #16

                @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!

                Home Automation Tinkerer
                www.CrankyCoder.net

                Controller: HomeAssistant in Kubernetes
                Gateway: MQTTClientGateway
                MySensors: 2.3

                1 Reply Last reply
                0
                • cimba007C Offline
                  cimba007C Offline
                  cimba007
                  wrote on last edited by
                  #17

                  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 the before()-Method again.

                  R 1 Reply Last reply
                  0
                  • cimba007C cimba007

                    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 the before()-Method again.

                    R Offline
                    R Offline
                    Reza
                    wrote on last edited by
                    #18

                    @cimba007

                    hi
                    where i can download this library : "#include <avr/wdt.h>" ?

                    1 Reply Last reply
                    0
                    • Artemiy117A Offline
                      Artemiy117A Offline
                      Artemiy117
                      wrote on last edited by
                      #19

                      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);
                        
                      }```
                      1 Reply Last reply
                      1
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      5

                      Online

                      11.7k

                      Users

                      11.2k

                      Topics

                      113.0k

                      Posts


                      Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • MySensors
                      • OpenHardware.io
                      • Categories
                      • Recent
                      • Tags
                      • Popular