element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog Watchdog Timer for the Raspberry Pi
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Raspberry Pi requires membership for participation - click to join
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
GPIO Pinout
Raspberry Pi Wishlist
Comparison Chart
Quiz
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: mistertee
  • Date Created: 19 Jul 2016 10:15 AM Date Created
  • Views 5875 views
  • Likes 1 like
  • Comments 19 comments
Related
Recommended
  • autostart
  • watchdog timer

Watchdog Timer for the Raspberry Pi

mistertee
mistertee
19 Jul 2016

Like all PCs the Raspberry Pi is likley to hang up during operation due to unexpected events not being catered for in the code. In an unattended application where the program automatically starts this can be a problem as there is no one around to restart the RPi. If there is no keyboard or HDMI monitor this is by power cycling. The Raspberry Pis internal watchdog timer has a poor reputaion - there are many comments about it being unreliable. This post presents a simple external watchdog timer.

 

Although there are dedicated power supply monitoring chips this solution uses components that are likley to be in most electronic hobbyists kit - based around the popular 555 timer.

 

image

 

The programme has to supply a Hi going pulse every few seconds. If there is no pulse for more than about 60 seconds the 555 output on Pin 3 will go low. This is coupled through to the on-board reset pin of the Raspberry Pi through a capacitor to issue a low going pulse which resets the Pi.

 

A capcitor is used here so that only a pulse going from Hi to Low will reset the raspberry Pi. A constant Lo voltage which is present while the raspberry Pi is starting up will have no effect.

 

If a shorter time is required then either reduce the value of R1 (1Mohm) or reduce the value of C1 (100 uF).

 

The LED pulses every time a Hi Pulse is issued to provide a visual indication to the user that everything is fine. The 555 timer does not easily provide a retriggerable monostable function that is required for a watchdog timer. Diode D1 is used to discharge the capacitor every time a pulse is received.

 

The reason the delay before a reset is set at more than 60 seconds is that the Raspberry Pi takes more than 30 seconds to start up.

 

Click here for a guide to setting the Raspberry Pi to autostart.

 

image

 

The image above shows the connection to the Reset pin of the Raspberry Pi.

 

Summary

 

Althogh the Raspberry Pi has an in-built watchdog timer, this has a poor reputaion. This watchdog timer is a reliable way of resetting the Raspberry Pi in remote applications where there is a risk of it hanging up due to the code not handling unexpected events correctly.

  • Sign in to reply

Top Comments

  • mistertee
    mistertee over 8 years ago in reply to mcb1 +1
    True - I am sure there is a much better chip out there. 555 timers are like Marmite - you either love it or hate it. I had some in stock (doesn't one always) and couldnt be bothered to order a new IC and…
Parents
  • shabaz
    shabaz over 8 years ago
    Like all PCs the Raspberry Pi is likley to hang up during operation.

    Hi Seggy,

     

    Just to flesh out things a bit, perhaps an application could be likely to hang, generally the Linux kernel is not likely to hang unless there is a very severe issue like a build issue, hardware fault or power related issue.

    It is worth mentioning that if the board ever does lock up, this should be investigated; because for the hardware watchdog to have to ever take action on a Linux platform is "severe".

    Possible reasons could be a poor power supply perhaps, or bad cooling strategy, and for these the hardware watchdog action is like a sticking plaster and does not fix the underlying issue(s).

    The underlying issues should therefore be resolved if the watchdog timer actually has to ever take action.

    Finally, if users are experiencing application hangs then these do not require a hardware watchdog timer.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 8 years ago in reply to shabaz

    Would using a proper brown-out IC (with the similar pulse before time-out) be preferable than this approach.

     

    I do agree that simply resetting it could mask another issue that requires resolving.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mistertee
    mistertee over 8 years ago in reply to mcb1

    True - I am sure there is a much better chip out there. 555 timers are like Marmite - you either love it or hate it. I had some in stock (doesn't one always) and couldnt be bothered to order a new IC and pay postage and wait 2 days.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz over 8 years ago in reply to mcb1

    Hi Mark,

     

    That's a good point, power-related issues that require a reset could be handled with brown-out detection driving the reset.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mistertee
    mistertee over 8 years ago in reply to shabaz

    Would you guys be able to recommend one that you've used before?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • mistertee
    mistertee over 8 years ago in reply to shabaz

    Would you guys be able to recommend one that you've used before?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • shabaz
    shabaz over 8 years ago in reply to mistertee

    I've not used one for the Pi, so this will only be a general comment - manufacturers like On Semi have these devices, programmed to different threshold voltages.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mistertee
    mistertee over 8 years ago in reply to shabaz

    Thanks for both your comments. Out of interest do both you guys work for Element 14 or just have a lot of spare time?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz over 8 years ago in reply to mistertee

    We do not work for E14, but like you, we actively use the Pi (and other SBCs).

    Your statement  regarding it being "likely to hang during operation" was something to be concerned about.

     

    Digging deeper now that it turns out it was actually a Python application issue which would not result in the board hanging, my concern disappears.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mistertee
    mistertee over 8 years ago in reply to shabaz

    OK thanks. I will change the post now to make this more explicit.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 8 years ago in reply to mistertee

    or just have a lot of spare time

    Haha ... less since I frequented this place. image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube