Introduction: Raspberry Pi Snail Mail System

I devised this project as something to do to get my children interested in programming, electronics and technology and to get some experience with the Raspberry Pi, low power, small, ARM powered computer. The project is to build a computer system to monitor your mailbox or letter box and let you know when the postman has arrived and you have new mail - real physical mail, or snail mail, that is! It takes a picture of the mail on the doormat and sends that via Gmail to your email inbox.

It uses the general purpose input/output (GPIO) on the Pi to provide some switch inputs and an LED indicator and to drive a 32 character display to provide user feedback (16 characters on 2 rows). It also uses any generic webcam that works with the Pi.

You will need:
Raspberry Pi + SD card loaded with Raspbian Wheezy OS
powered USB hub with a 5V power supply.
micro USB cable to power the Pi
network connection or USB wifi dongle for the Pi
webcam
SainSmart 1602 I2C display
Logic level shifter
Some connection to the Pi GPIO - IDC connector, ribbon cable and electonics prototyping breadboard
resitors
LED
microswitches
a length of thin wire
Some kind of box (we used lego)

The Python code required is on GitHub:
https://github.com/paulbarber/raspi-gpio.git
Required files:
take_picture_and_email.py
send_gmail_attachment.py
lcd_display.py
i2c_lib.py

Run with:
sudo python take_picture_and_email.py
(root access with sudo is required to access the GPIO)

Use the instructions on http://www.raspberrypi.org to setup the Pi in the standard way with Raspbian “wheezy” OS.
Follow these instructions to set things up.

Enable GPIO control:
sudo apt-get install python-smbus
sudo modprobe i2c-dev
sudo modprobe i2c-bcm2708

We used the simple webcam image saver, fswebcam
sudo apt-get install fswebcam

Create a gmail account for the pi and use google api.
See: http://mitchtech.net/connect-raspberry-pi-to-gmail-facebook-twitter-more/
Did this:
sudo apt-get install python-pip python2.7-dev    (which did a lot, including Python 2.6!)
sudo easy_install -U distribute
sudo pip install feedparser

Raspberry Pi with the Sainsmart 1602 LCD I2C I2C
See: https://www.instructables.com/id/Raspberry-Pi-I2C-Python
For Rev 2 Pi, need to use: i2cdetect -y 1 to see what is on i2c.
Comms only work if display is powered by 3.3v, so a logic level converter to 5v is needed.
We used a SparkFun logic level converter, can be bought from cool components for < £2.
https://www.sparkfun.com/products/8745

Wiring:
Please see the circuit diagram.
Three GPIO pins are used, for 2 switches (take photo and exit/quit) and one LED.
The take photo switch must be attached to your letter box in some way.
The 2 I2C pins, 3.3V, 5V and ground are taken to the LCD display via the logic level shifter.