Close

Updated RPi On/Off Circuit

A project log for Pi Chart

A wireless nautical chart plotter based on a Raspberry Pi and a sunlight readable screen.

Erland LewinErland Lewin 02/07/2016 at 09:242 Comments

I updated the Raspberry Pi On/Off circuit to include a signal to the Raspberry Pi so it detects when the Pi is turned off.

I'm also thinking now of not having a momentary switch for the power switch.

Here's the new circuit. Again, detailed component values have not been selected. The 10 ohm resistor symolises the Pi's load. I'll attach the iCircuit file to the Hackaday project.:

Here's the script (/home/pi/shutdownMonitor.py) that turns off the Pi when it detects that the power switch has been turned off:

# Import the modules to send commands to the system and access GPIO pins                                                                                      
from subprocess import call
import RPi.GPIO as gpio
import time
import os

# Define a function to keep script running                                                                                                                    
def loop():
    time.sleep(60)

# Define a function to run when an interrupt is called                                                                                                        
def shutdown(pin):
     print "shutting down..."
     os.system( "sudo shutdown -h now" )
     # call('halt', shell=False)                                                                                                                              

gpio.setmode(gpio.BCM) # Set pin numbering to board numbering                                                                                                 
gpio.setup(23, gpio.IN ) # , pull_up_down=gpio.PUD_TRI) # Set up pin 7 as an input                                                                            
# gpio.add_event_detect(23, gpio.RISING, callback=shutdown, bouncetime=200) # Set up an interrupt to look for button presses                                  
gpio.add_event_detect(23, gpio.FALLING, callback=shutdown, bouncetime=200) # Set up an interrupt to look for button presses                                   

loop() # Run the loop function to keep script running                                                                                                         
It is started from /etc/rc.local like this:
python /home/pi/shutdownMonitor.py &

Discussions

ESharpAxe wrote 03/02/2016 at 06:07 point

I like your project. I wonder if your electronics might need more than 500 mA.

  Are you sure? yes | no

Erland Lewin wrote 03/02/2016 at 20:25 point

Thanks for your interest!

Yes, the PiChart device will need more than 500 mA, especially driving the screen.

The On/Off circuit will only be limited by the current that top P-MOSFET transistor can handle.

Note that I spun off the On/Off circuit into its' own Hackaday project: https://hackaday.io/project/9885-raspberry-pi-bake-off

  Are you sure? yes | no