2

I am able to create a shutdown (and reboot) button for a plain Raspi harnassing the fact, that shorting Pin 5 to GND will reboot the Pi if shutdown.

However, when adding the HifiBerry HAT things become more complicated, as Pin 5 is used for I2C and as stated by HiFiBerry, some other GPIO-Pins are used as well.

Now to my question: Will the following curcuit work with the Amp+ HAT?

enter image description here

In the shutdown script I would be monitoring Pin 13 for LOW state and send sudo shutdown -h now.

#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""shutdown script for Raspberry Pi

watch LOW level on pin 13 to enter sleep mode
status led on pin 15: ON = ready, BLINK = confirm button
"""

import RPi.GPIO as GPIO
import os
import time

# use the pin number as on the raspi board

GPIO.setmode(GPIO.BOARD)

# set pin 15 as output and HIGH, pin 13 is input

GPIO.setup(15, GPIO.OUT)
GPIO.output(15, True)
GPIO.setup(13, GPIO.IN)

# start the loop for every .5 seconds, waiting for LOW on pin 13
# then 2 short flashes with led to confirm and shutdown to sleep mode

while True:
    if not GPIO.input(13):
        GPIO.output(15, False)
        time.sleep(.1)
        GPIO.output(15, True)
        time.sleep(.1)
        GPIO.output(15, False)
        time.sleep(.1)
        GPIO.output(15, True)
        os.system("sudo shutdown -h now")
    time.sleep(.5)

Will currents drawn from Pin 5 influence the function of the HAT in this setting?

0

If #5-GPIO3 truly is being used for I2C by the HiFiBerry, you should be OK, at least from a circuit damage perspective, since I2C IO's only sink, which is what your push-button would be doing when pressed. There is, however, a chance of odd behavior due to the fact you'd be asserting an unexpected low on that I2C line.

Since the RPi I2C ports are pulled up on the RPi PCB, you may not need the 10K pull-up. Also, it wasn't clear what it was intended to do, but there may be an opportunity to remove the diode as well.

  • I am accepting your answer since the most important aspect of the question was whether the curcuit would harm my Pi. The idea of the diode was, to avoide a permanent UP signal on PIN #5. – tim6her Jun 1 '16 at 12:53
  • Has anybody test this? Does it actually work? Any adverse side-effects? – mmo Sep 8 '18 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.