Hello, I'm trying to design a circuit to turn a Raspberry Pi (RPi) on/off using a single toggle switch.
For those unfamiliar with the RPi, it'll turn on immediately power is supplied but shutdown must be initiated in the software by the user and the shutdown procedure must complete before power is disconnected.
The basic operating principle of my circuit is a follows:
Toggle switch closed:
- The transistor activates and closes the 3V relay; the RPi powers up.
- The capacitor is charged.
- A RPi GPIO pin is held high. The voltage is set by the 20k/30k voltage divider
Toggle switch opened:
- The GPIO pin immediately goes low. This triggers a script on the RPi to initiate shut down
- The capacitor discharges, holding the transistor closed and the RPi powered long enough for shut down to be completed.
This is the first circuit I've truly designed from scratch so I'm looking for feedback on a few points, as well as any general comments:
- Is the general operating principle sound?
- Are any additional components needs for protection? (e.g. I included a flyback diode)
- How do I select a model of transistor to use?
- Should I use a polarized (electrolytic) capacitor?
Please keep in mind I'm an inexperienced (but very willing to learn hobbyist), so go easy!