Mount and sync a USB drive on RPi Ubuntu with GPIO

Actions:image
  1. So first the USB is plugged in.
  2. It is automounted using a GPIO button press. Flash red if this fails.
  3. Blue light will flash light during rsync cp (copy). If an error occurs show red LED and turn off blue LED.
  4. Send email with results on completion.
  5. Unmount USB and show steady blue LED indication turn off blue LED.

Continue reading “Mount and sync a USB drive on RPi Ubuntu with GPIO”

RPi GPIO: Adding switches and lights

Goal:

Create a pair of LED’s and push buttons on my RPi which can run scripts. ?One will shut down the Pi (updated here), the other will rsync a directory to a USB. Also I will read the status of a UPS. This may/will become more complicated since the UPS doesn’t have any useful interface (requiring an Arduino to:

  • Watch the UPS battery voltage and tell the RPi to power down.
  • Monitor whether mains power is applied.
  • Once mains is re-powered, restart the RPi after a UPS shut down using the hardware reset pins on the Pi.)
Instructions:
  1. As in these RPi ubuntu instructions I installed python.. I removed sudo from the last command to make the command output happy
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-pip
pip install RPi.GPIO
  1. Initially I set up a breadboard as in this youtube video (using the linked files)
    from time import sleep
    import RPi.GPIO as GPIO
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(12, GPIO.OUT)
    while 1:
     GPIO.output(12, False)
     sleep(1)
     GPIO.output(12, True)
     sleep(1)

    Continue reading “RPi GPIO: Adding switches and lights”

running scripts on Ubuntu 101

These instructions show a simple script that returns “Hello world”.

I moved my script to /usr/local/bin/ (as recommended here) so it can run without the full path.. pretty cool.

Notes.

I can create aliases:

alias l='ls -l'

as well as functions:

today() {
    echo -n "Today's date is: "
    date +"%A, %B %-d, %Y"
}

I added a bin directory to my home directory, and added it to .bashrc to allow execution from there:

export PATH=$PATH:directory