Electronic – Sharing GND with a device

groundraspberry pi

I've built a watchdog circuit for my Raspberry Pi using a NE555. In the astable configuration I'm counting ~5 minutes and then I kill the switch unless there is a signal from GPIO that discharges the C of the 555. I have a mosfet RFP70N06 with the gate directly connected to the OUT of the 555, and when C is 2/3 full out goes to GND, the mosfet is open and the power of the RPi is gone.

schematic

simulate this circuit – Schematic created using CircuitLab

My question is about the ground. The RPi does not initially share the supply ground as the rest of the circuit, since the GND of the supply of the RPi is on the Drain of the MOSFET. But then I'm using a GPIO pin, and I also used one of the GND pins on the header.

Since the RFP70N06 has an Rds=0.014 ohm I have my RPi with a 0.014 resistor on its ground, but from the GPIO header I have GND directly to the GND of the supply.

Does this makes sense? Should I be using an opto-coupler for the GPIO? I don't want a track on the PCB of the RPi being used as fuse.

Best Answer

Problems with the circuit:

1) low side switching means your pi is floating. Might be tricky for interfacing to other things. Generally, USB devices all should sit at ground potential.
Solution : high side switching with a P MOSFET.

2) the GPIO ground will keep it powered, it bypasses your MOSFET! Nothing wrong with powering the Pi from the 5V and GND pins on the GPIO header, by the way.

3) A watchdog needs to depend on action not just state. What if the Pi crashes while the pin is high? The watchdog won't reboot it.
Solution: have your timer reset by an edge, not a level. Another 555 will work, as a monostable they are edge triggered, not retriggerable. OR:
Use AC coupling of the pin through a capacitor, then rectify that.

4) You have no resistor between 470uF and 2n2222, so switching it on hard might damage the transistor. Add a small resistor.

Last comment - the Pi has an internal watchdog, have you considered using this? It seems you can operate the WDT manually, so it reboots unless you write to a system device within 10 seconds or so. So you can use it to reboot even if your Python program crashes, not just some esoteric system crash.