Posts: 23
Joined: Wed Mar 28, 2018 4:04 pm

Hardware Watchdog Issue with GPIO

Mon Feb 04, 2019 11:01 pm

Hi there,

I've fixed a hardware watchdog (switchdoc labs dual watchdog timer) to my Pi (3b+) and are having some issues. The watchdog is used to power a relay to power cycle the pi. I have a program that sends a heart beat to pat the watchdog from pin37. Once the program is up and running the watchdog works fine and will trigger a reset if the heart beat doesn't appear for the allotted timeout period. However, if the program hasn't been run then the watchdog timer appears to be stuck. When the pi boots the voltage between pin37 and GND is 1.65V. The watchdog specifies that the trigger pin (pin37) should be held high impedance and then pulled to ground to pat the dog. In order to unstick the watchdog, the line...

bcm2835_gpio_set_pud(WATCHDOG, BCM2835_GPIO_PUD_OFF);

... is called and this sets the timer counting again. After this point, the voltage will move between 4.9V (I assume this is high impedance) and GND (when pulled to ground by pin37). The watchdog needs to be able to reset the pi if the program fails to run and at the moment, this isn't happening unless the program is run in the first place.

Any thoughts greatly appreciated, thanks

User avatar
Posts: 6253
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Hardware Watchdog Issue with GPIO

Tue Feb 05, 2019 6:16 pm

Note: I haven't got one of these, so this is theoretical.

Looking at the SwitchDoc site, there appears to be two versions; the one called "Version 110216-01-001" has "Open Drain buffers added to the Grove Watchdog inputs" whatever that means, so "You no longer have to leave the inputs float for the watchdogs to operate"
Which version do you have?

On boot-up, most GPIOs - including GPIO 26, header pin 37 - are configured with pull-down. You have to allow it to float high to enable the timer to start, and that is what that line appears to be doing.
Before that is run, there's the 50k internal pull-down fighting with the device's pull-up, resulting in the 1.65V you're seeing.

Now for the big Gotcha.
You're seeing 4.9V on the Pi's GPIO? That's going to kill your Pi - 3v3 is the maximum safe voltage a GPIO should ever see!

By the sound of it, you're powering the device from 5v. Don't do that! Consider your wrist well and truly slapped!
It can (according to the spec. sheet) run from 3v3 , so use pin 2 rather than pin 2 or 4.
If you want to use a 5v relay, power that from 5v, but power the watchdog from 3v3.

Return to “C/C++”