Software

Setting up the Raspberry Pi

  1. Download the New Out Of the Box Software (NOOBS) and place it on the SD card by following the directions here.

  2. Get the Raspberry Pi running by following the official Quick Start Guide. Choose the (default) Raspbian operating system.

  3. Get accurate internet time by running the following commands in the terminal window:

    sudo apt-get install ntpdate
    sudo ntpdate -u ntp.ubuntu.com
    
  4. Update the operating system to the latest version:
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get dist-upgrade
    
  5. If you plan to use the WiFi, set it up. We used an Edimax EW-7811Un USB WiFi dongle and followed the instructions here. Note that this particular adapter has a power-saving feature that will cause it to go to sleep after a period of inactivity (about 10 hours in our experience). If you want to be able to connect to the Pi at all times, for example for debugging purposes, it is best to disable this feature by creating a file,
    sudo nano /etc/modprobe.d/8192cu.conf
    

    and adding the lines,

    # Disable power management
    options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
    

    Hit Ctrl-X to exit. See this thread for more details.

  6. If you haven’t done it during setup, run sudo raspi-config and enable the camera module.

  7. To disable the camera LED (which may scare the birds and produces artifacts in low-light pictures), run

    sudo nano /boot/config.txt
    

    and at the end of the file add a line,

    disable_camera_led=1
    

    Hit Ctrl-X to exit.

Setting up the bird feeder software

  1. Get a copy of our code from GitHub to the Raspberry Pi. There are various ways to do this, but the simplest is to install git,

    sudo apt-get install git
    

    and then use the command,

    git clone https://github.com/tpudlik/Birdfeeder.git
    

    This will create a directory Birdfeeder in the current working directory containing a copy of the code.

  2. Install picamera, the Python library for the Raspberry Pi camera, by typing

    sudo apt-get install python-picamera
    
  3. Install the pip Python package manager:
    sudo apt-get install python-pip
    
  4. If you want to upload your photos to Dropbox, install the Python Dropbox API:
    sudo pip install dropbox
    
  5. If you want to upload your photos to Twitter, install the Python Twitter API:
    sudo pip install twython
    
  6. If you want to upload your photos to Flickr, install the Python Flickr API:
    sudo pip install flickr-api
    
  7. Install the Python GPIO library:
    sudo apt-get install python-dev
    sudo apt-get install python-rpi.gpio
    
  8. Install Pillow, an image processing library. This may take a while.
    sudo pip install pillow
    

    Currently, this package is only used if you tweet the pictures. If you intend to only store them locally, or to use Dropbox or Flickr, you can omit this dependency.

Configuring Dropbox, Flickr and Twitter

If you want your pictures automatically uploaded, rather than merely stored locally on the device, you will want to set up Dropbox, Flickr or Twitter integration. You can use any or all of them, and enable or disable their use at any time through configuration options. This section describes the initial, one-time setup.

Dropbox

You will need to register an application with Dropbox and save its
credentials.

  1. Go to Dropbox for Developers and click on the Create app button.
  2. When asked “What type of app do you want to create?”, choose “Dropbox API App”. For storage, choose “Files and datastores”. It is OK, and in fact desirable, to limit the app’s permissions to its own folder. Finally, provide a name for the app.
  3. You will be taken to your new app’s dashboard. It lists two secret keys, App key and App secret. You will need them for the next step.
  4. On the Pi, navigate to the Birdfeeder folder (where our code is located) and edit the dropbox_authentication.py file:
    nano dropbox_authentication.py
    

    Change the value of app_key and app_secret to the values you got from the dashboard. Exit nano using Ctrl-X.

  5. Run,

    python dropbox_authentication.py
    

    and follow the prompts. You will have to go to the Dropbox website and enter your username and password. When you’re done, a file access_tokens.py will appear in the folder (if it wasn’t there already).

Flickr

The process is almost identical to the one for Dropbox. However, unlike with Dropbox, you may want to set up a separate Flickr account for your bird feeder. Otherwise, your carefully edited regular submissions will be drowned out by the bird feeder’s photo stream!

  1. Go to Flickr Services and apply for a (free) non-commercial API key. Fill out a short form.
  2. You will be taken to your new app’s dashboard. It lists two secret keys, App key and App secret. You will need them for the next step.
  3. On the Pi, navigate to the Birdfeeder folder (where our code is located) and edit the flickr_authentication.py file:
    nano flickr_authentication.py
    

    Change the value of app_key and app_secret to the values you got from the app’s dashboard. Exit nano using Ctrl-X.

  4. Run,

    python flickr_authentication.py
    

    and follow the prompts. You will have to go to the Flickr website and enter your username and password. When you’re done, the files flickr_access_token.txt and access_tokens.py will appear in the folder (if they weren’t there already).

Twitter

If you set up Dropbox or Flickr already, you will encounter no surprises here.

  1. Go to the Twitter App Console, log in, click on Create New App, and fill out the required fields.
  2. On the application’s dashboard, under “Application Settings”, note the value of “Access level”. If it is not “Read and Write”, modify the app permissions.
  3. Also on the dashboard, select the Keys and Access Tokens tab and note the values of “API key” and “API secret”. You will need these next.
  4. On the Pi, navigate to the Birdfeeder folder (where our code is located) and edit the twitter_authentication.py file:
    nano twitter_authentication.py
    

    Change the value of app_key and app_secret to the values you got from the dashboard. Exit nano using Ctrl-X.

  5. Run,

    python twitter_authentication.py
    

    and follow the prompts. You will have to go to the Twitter website and enter your username and password. When you’re done, a file access_tokens.py will appear in the folder (if it wasn’t there already).

Lets birds leave you postcards.