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 Ethernet Gateway

Watchdog on Ethernet Gateway

Scheduled Pinned Locked Moved General Discussion
ethernetgatewayattiny45watchdog
32 Posts 9 Posters 20.6k Views 1 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.
  • axillentA axillent

    @BulldogLowell wdt_enable alone cannot be sufficient

    first of all you need a bootloader having watchdog support
    official bootloader is not working with watchdog
    optiboot is working
    other alternative is to kill a bootloader but you will need ISP programmer to download sketches

    second wdt_reset need to be embedded into many places across sketch and library sources

    BulldogLowellB Offline
    BulldogLowellB Offline
    BulldogLowell
    Contest Winner
    wrote on last edited by
    #5

    @axillent said:

    second wdt_reset need to be embedded into many places across sketch and library sources

    OK, so for now it's a hardware plan!

    axillentA 1 Reply Last reply
    0
    • BulldogLowellB BulldogLowell

      @axillent said:

      second wdt_reset need to be embedded into many places across sketch and library sources

      OK, so for now it's a hardware plan!

      axillentA Offline
      axillentA Offline
      axillent
      Mod
      wrote on last edited by
      #6

      @BulldogLowell why not to play around with your own copy of the sources?

      with success you can be a contributor of this nice feature

      sense and drive

      BulldogLowellB 1 Reply Last reply
      0
      • axillentA axillent

        @BulldogLowell wdt_enable alone cannot be sufficient

        first of all you need a bootloader having watchdog support
        official bootloader is not working with watchdog
        optiboot is working
        other alternative is to kill a bootloader but you will need ISP programmer to download sketches

        second wdt_reset need to be embedded into many places across sketch and library sources

        tekkaT Offline
        tekkaT Offline
        tekka
        Admin
        wrote on last edited by tekka
        #7

        @axillent said:

        second wdt_reset need to be embedded into many places across sketch and library sources

        It's in general good practice to enable the watchdog to avoid deadlocks. What works best in my experience is to set the wdt to 8s and reset the wdt timer at the beginning of the main loop (as long as it takes max. 8s).

        Important: Avoid blocking functions and delay() - substitute delay() for mysensors::wait(), where the wdt is reset.

        The problems with the ethernet shield W5100 are discussed everywhere, resetting the arduino won't help in that case, but rather implementing an external watchdog that power-cycles the shield...

        1 Reply Last reply
        0
        • axillentA axillent

          @BulldogLowell why not to play around with your own copy of the sources?

          with success you can be a contributor of this nice feature

          BulldogLowellB Offline
          BulldogLowellB Offline
          BulldogLowell
          Contest Winner
          wrote on last edited by
          #8

          @axillent said:

          you can be a contributor of this nice feature

          OK, I'll give it a stab.

          @tekka said:

          What works best in my experience is to set the wdt to 8s and reset the wdt timer at the beginning of the main loop (as long as it takes max. 8s).

          you mean generally, or you are using it already on this application?

          tekkaT 1 Reply Last reply
          0
          • BulldogLowellB BulldogLowell

            @axillent said:

            you can be a contributor of this nice feature

            OK, I'll give it a stab.

            @tekka said:

            What works best in my experience is to set the wdt to 8s and reset the wdt timer at the beginning of the main loop (as long as it takes max. 8s).

            you mean generally, or you are using it already on this application?

            tekkaT Offline
            tekkaT Offline
            tekka
            Admin
            wrote on last edited by
            #9

            @BulldogLowell both, i'm using the wdt with Optiboot and MYSBootloader. Reading MCUSR during bootloading will give a hint on the reset cause...

            tekkaT 1 Reply Last reply
            0
            • tekkaT tekka

              @BulldogLowell both, i'm using the wdt with Optiboot and MYSBootloader. Reading MCUSR during bootloading will give a hint on the reset cause...

              tekkaT Offline
              tekkaT Offline
              tekka
              Admin
              wrote on last edited by
              #10

              Here a simple sketch:

              #include <avr\wdt.h>
              
              void setup() {
                // set watchdog to 8s
                wdt_enable(WDTO_8S);
              }
              
              void loop() {
                // watchdog reset
                wdt_reset();
                
                // do some stuff that does not take longer than 8s
               // else watchdog will trigger
              }
              
              BulldogLowellB 1 Reply Last reply
              0
              • tekkaT tekka

                Here a simple sketch:

                #include <avr\wdt.h>
                
                void setup() {
                  // set watchdog to 8s
                  wdt_enable(WDTO_8S);
                }
                
                void loop() {
                  // watchdog reset
                  wdt_reset();
                  
                  // do some stuff that does not take longer than 8s
                 // else watchdog will trigger
                }
                
                BulldogLowellB Offline
                BulldogLowellB Offline
                BulldogLowell
                Contest Winner
                wrote on last edited by
                #11

                @tekka said:

                Here a simple sketch:

                yes, got that far ;) I thought you meant you had it working on a gateway.

                Working with the (as @axillent said) the gateway, with all of its nuances and making it extensible for (the majority?) of the standard sensor sketches would be the challenge.

                axillentA 1 Reply Last reply
                0
                • BulldogLowellB BulldogLowell

                  @tekka said:

                  Here a simple sketch:

                  yes, got that far ;) I thought you meant you had it working on a gateway.

                  Working with the (as @axillent said) the gateway, with all of its nuances and making it extensible for (the majority?) of the standard sensor sketches would be the challenge.

                  axillentA Offline
                  axillentA Offline
                  axillent
                  Mod
                  wrote on last edited by
                  #12

                  @BulldogLowell setting watchdog to timeout after 8 seconds can support you in most situations without a need to dig into library source

                  But you will be not guaranteed from all cases, it is possible that your arduino will be reset in normal situation where reset is not needed. But actually the same will happen if you will attach external watchdog as you state in you first post here

                  sense and drive

                  BulldogLowellB 1 Reply Last reply
                  0
                  • axillentA axillent

                    @BulldogLowell setting watchdog to timeout after 8 seconds can support you in most situations without a need to dig into library source

                    But you will be not guaranteed from all cases, it is possible that your arduino will be reset in normal situation where reset is not needed. But actually the same will happen if you will attach external watchdog as you state in you first post here

                    BulldogLowellB Offline
                    BulldogLowellB Offline
                    BulldogLowell
                    Contest Winner
                    wrote on last edited by
                    #13

                    @axillent said:

                    But you will be not guaranteed from all cases, it is possible that your arduino will be reset in normal situation where reset is not needed. But actually the same will happen if you will attach external watchdog as you state in you first post here

                    I have a lot more flexibility with hardware, i believe.... there is an (8s) limit on the Atmel watchdog, no?

                    axillentA Dan S.D 2 Replies Last reply
                    0
                    • BulldogLowellB BulldogLowell

                      @axillent said:

                      But you will be not guaranteed from all cases, it is possible that your arduino will be reset in normal situation where reset is not needed. But actually the same will happen if you will attach external watchdog as you state in you first post here

                      I have a lot more flexibility with hardware, i believe.... there is an (8s) limit on the Atmel watchdog, no?

                      axillentA Offline
                      axillentA Offline
                      axillent
                      Mod
                      wrote on last edited by axillent
                      #14

                      @BulldogLowell said:

                      I have a lot more flexibility with hardware, i believe.... there is an (8s) limit on the Atmel watchdog, no?

                      it is a limit of atmega328, other MCU can differ

                      but it is still possible to organize longer period by activating WDT ISR handler
                      this will be not the best practice but it will work
                      the best practice is to set very short timeout and to put wdt_reset() at all required points

                      sense and drive

                      1 Reply Last reply
                      0
                      • hekH Offline
                        hekH Offline
                        hek
                        Admin
                        wrote on last edited by
                        #15

                        What happens with watchdog while sleeping?

                        axillentA 1 Reply Last reply
                        0
                        • hekH hek

                          What happens with watchdog while sleeping?

                          axillentA Offline
                          axillentA Offline
                          axillent
                          Mod
                          wrote on last edited by
                          #16

                          @hek said:

                          What happens with watchdog while sleeping?

                          it depends on what do you want :)
                          if i'm not mistaken LowPower library you are using is using watchdog while sleeping
                          actually watchdog is only one timer running while POWER_DOWN
                          it is a common way to wake up because of watchdog event from the deepest sleep if you need to wake up by time, not by external event

                          sense and drive

                          1 Reply Last reply
                          0
                          • G Offline
                            G Offline
                            Gambituk
                            wrote on last edited by
                            #17

                            Hi, i would be interested in any more updates along this line. In my case my gateway is mostly stable as far as i can tell. several weeks without issues. My problem is that most of my nodes seem to lockup, so i would be totally interested in making them more robust either by software or if necessary with external chip as overlord watchdog

                            1 Reply Last reply
                            0
                            • BulldogLowellB BulldogLowell

                              @axillent said:

                              But you will be not guaranteed from all cases, it is possible that your arduino will be reset in normal situation where reset is not needed. But actually the same will happen if you will attach external watchdog as you state in you first post here

                              I have a lot more flexibility with hardware, i believe.... there is an (8s) limit on the Atmel watchdog, no?

                              Dan S.D Offline
                              Dan S.D Offline
                              Dan S.
                              Hero Member
                              wrote on last edited by
                              #18

                              @BulldogLowell Any progress on this? My Ethernet gateway is quite reliable after solving power supply issues and implementing soft spi. But about once a month it stops and rebooting it makes it operative again. The failure seems to be periodic--once a month. May be a clue there--something reaching a limit? At any rate, any failure rate where I can't start it up without physically rebooting is too much.

                              1 Reply Last reply
                              0
                              • M Offline
                                M Offline
                                maha
                                wrote on last edited by
                                #19

                                millis() has a rollover after approximately 50 days. Could that be something?

                                Dan S.D 1 Reply Last reply
                                0
                                • M maha

                                  millis() has a rollover after approximately 50 days. Could that be something?

                                  Dan S.D Offline
                                  Dan S.D Offline
                                  Dan S.
                                  Hero Member
                                  wrote on last edited by
                                  #20

                                  @maha Don't know. But your question did trigger the thought of using milils() to periodically trigger a reboot. Rather than check for a lockup with a watchdog routine I may try just rebooting it at a shorter time interval, e.g., every 2 weeks, than I have experienced the lockups using millis to measure the interval.

                                  1 Reply Last reply
                                  0
                                  • Dan S.D Offline
                                    Dan S.D Offline
                                    Dan S.
                                    Hero Member
                                    wrote on last edited by
                                    #21

                                    Added a 8 sec Watchdog to my ethernet gateway and it's up and running now. Time will tell if it cures the occaisional lockups by automatically resetting. Will report back the results

                                    1 Reply Last reply
                                    0
                                    • hekH Offline
                                      hekH Offline
                                      hek
                                      Admin
                                      wrote on last edited by
                                      #22

                                      FYI: Watchdog reset is automatically called by process() nowadays in the development-branch.

                                      https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/MySensor.cpp#L509

                                      Dan S.D 2 Replies Last reply
                                      1
                                      • hekH hek

                                        FYI: Watchdog reset is automatically called by process() nowadays in the development-branch.

                                        https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/MySensor.cpp#L509

                                        Dan S.D Offline
                                        Dan S.D Offline
                                        Dan S.
                                        Hero Member
                                        wrote on last edited by
                                        #23

                                        @hek I assume this is with the intent to allow a watchdog reset on sensor sketches in the future, but does not apply to the Ethernet gateway sketch?

                                        1 Reply Last reply
                                        0
                                        • hekH hek

                                          FYI: Watchdog reset is automatically called by process() nowadays in the development-branch.

                                          https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/MySensor.cpp#L509

                                          Dan S.D Offline
                                          Dan S.D Offline
                                          Dan S.
                                          Hero Member
                                          wrote on last edited by
                                          #24

                                          @hek Please disregard my prior message. I looked further and see that the watchdog reset is part of the sensor wait routine and is in the current 1.4 version of MySensors.cpp

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          21

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 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