In this Instructable we will build a fun desk gadget to alert you when a new email arrives in your inbox.
New to Raspberry Pi? If this Ible is a bit over your head, or you need a quick refresher on Raspberry Pi, I recently authored a Raspberry Pi guide to help you get up to speed before you have a crack at this project!
Step 1: Materials
Raspberry Pi (RadioShack #277-196)
protoboard (RadioShack #276-168)
(5x) 220 ohm resistor (RadioShack #271-1111)
(5x) white LEDs (RadioShack #276-017)
n-channel MOSFET (RadioShack #276-2072)
10K resistor (RadioShack # 271-1126)
Micro USB cable (RadioShack #26-2738)
2A USB AC power supply (RadioShack #55075817) web only
22 gauge wire (RadioShack #278-1218)
5mm thick Plywood
3mm thick Plywood
(4x) 1.5" 8/32 machine screw
(4x) 8/32 nut
(2x) 4/40 nut
(2x) .75" 4/40 machine screw
hot melt glue
Read a schematic
Solder a simple circuit
Modify a program (no actual programming required)
Step 2: Setting Up the Raspberry Pi: OS and Networking
We'll need to configure the Raspberry Pi before we get things up and running. I'll be making several web-connected Pi projects using the Netgear Wi-Fi adapter, so I've created a brief companion guide for setting up the wireless connection and links to properly setting up the Pi. Follow along here:
Step 3: Setting Up the Raspberry Pi: Updating and Downloads
We'll need to download a few more things in order for Python to be able to properly check our inbox and use the GPIO.
Enter into the terminal:
sudo apt-get install python-dev
sudo apt-get install python-pip
sudo pip install feedparser
sudo easy_install -U distribute
sudo apt-get install python-rpi.gpio
Step 4: Setting Up the Raspberry Pi: Python Code
Before we can use the device, we'll need to edit the Python code so it's linked to an email account. First, download the attached program 'elights.py' and open it up in a text editor. You can copy it over to the Pi with a flash drive, but if you're new to Python, typing it manually will help you become familiar with the syntax.
Start up the GUI on the Pi with:
Once the desktop environment has loaded, open up IDLE (not IDLE 3). Once the shell starts up, create a new window under File->New. Copy or type the program into the editor. You'll need to edit two lines of the program to contain your credentials. Where the red comments point to USERNAME and PASSWORD, change the default quoted words to match your information. USERNAME will just be the part of your email address before the @.
Hit ctrl-s to save the file. Be sure to keep the name as elight.py, as it needs to be exact for the next steps to work.
Once you've properly saved the file, open up the terminal (LX terminal program on the desktop). Type in:
sudo chmod +x email_light.py
This will turn our python program into an executable.
Step 5: Set Up the Raspberry Pi: Final Touches
Now that we've got the program, we'll need to have the Pi run it automatically. To do this, we'll be editing one of the initialization files so that our program will run as soon as the Pi boots up and without having to log in.
Enter the following into the terminal:
sudo nano /etc/rc.local
You'll see a bunch of commented out text (prefixed by '#') explaining the file. Skip to the end of the text and type in:
sudo python home/pi/email_light.py &
Hit 'ctrl+x' followed by 'y' to save and confirm your edited file
This will run our python program when the Pi boots up. The ampersand at the end will make it run in the background.
Safely shutdown the Pi with:
sudo shutdown -h now
Step 6: Build the Circuit: Layout
To illuminate our little sign, we'll be using several LEDs in parallel. Since the output pins on the Raspberry Pi can only supply a few mA of current, we'll be using a power MOSFET as a switch to power them directly from the 5V source pin. We're using the IRF510, which is an N-Channel MOSFET, so when the Pi sends a logic HIGH signal to the MOSFET will connect all of the LEDs to ground.
Step 7: Build the Circuit: Resistors
Place the five 220 ohm resistors spaced evenly across the board. Before clipping, bend the leads of the resistors that are towards the edge of the board so that they all connect and solder them in place.
Place the one 10K ohm resistor on the third column in and connecting to the power rail.
Step 8: Build the Circuit: LEDs and MOSFET
Place the LEDs with the anodes towards the resistors and the cathodes on the inner power rail.
Place the MOSFET in the upper right with the 10K resistor on it's leftmost pin.
Step 9: Build the Circuit: Wires and Heat Shrink
Using some of the clipped leads of the LEDs, bend two pieces into tiny jumpers.Place one leading from the inner power rail (connected to the LEDs) to the middle pin of the MOSFET. Place the other leading from the other power rail to the rightmost pin of the MOSFET.
Cut a 10 inch length of red, yellow, and black wire.
Solder the yellow wire in the same row as the 10K resistor and the leftmost MOSFET pin.
Solder the black wire in the outer power rail closest to the MOSFET.
Solder the red wire to one of the LED anodes.
Cut three small lengths of heat shrink tubing and slide them down the wires.
Cut the two female jumpers in half and solder one end to each of the three wires.
Slide the tubing down and heat it in place for a strong connection.
Step 10: Build the Frame: Design
I designed the case for the New Email Notification light in Adobe Illustrator and cut it out on and Epilog 120 watt laser. The entire frame was cut from 1/4 inch plywood.
For the next steps you'll need to have downloaded and cut out the attached file "mailboxComplete."
Step 11: Build the Frame: Base
Align the RasPi over the two offset holes in the middle of the base.
While holding the Pi in place, flip the two pieces over and slide the two 4/40 screws through the holes.
Switch to holding the screws, and then flip the board back over.
Place the nuts onto the screws and tighten.
Step 12: Build the Frame: Stand
Slide the two stand pieces together.
Step 13: Build the Frame: Mailbox
Print and cut out the attached template for the window. The text can be easily modified to whatever you like.
Place the cut out over the inside of the window and hold it in place with a few pieces of masking tape.
Take the assembled circuit and place it along the inside of the large backside piece of the mailbox. Put a few dabs of hot glue on the back of the circuit board and place it centered, making sure not to overlap the tabs.
Fish the wires through the eyelet in the mailbox and down through the eyelet on the top baseplate.
Slide the four side panels into the slots on the bottom piece of the mailbox.
Place the top panel of the mailbox and slide it onto the tabs.
Put the square peg piece into the flag and slide it into the hole on the back of the box.
Step 14: Build the Frame: Final Assembly
Turn the mailbox sideways and put the long 6/32 screws through the four holes.
Slide four wooden spacers onto each screw.
Plug the red wire into pin 2 of the RasPi GPIO headers.
Plug the black wire into pin 6.
Plug the yellow wire into pin 7.
Align the base plate with the Raspberry Pi with the four screws.
Slide the base plate onto the screws and attach the 6/32 nuts to the underside.
Plug the Lenmar USB power supply in to the wall and the micro USB into one of the ports.
Plug the other end of the micro USB into the Raspberry Pi.
Step 15: Going Further
You're done! I decided to give my box a coat of black paint, but it would look equally great in any color.
The miniature inbox notification system is functional and fun, but that doesn't mean it can't be made better!
Sound effects: with the addition of a small amplified speaker, it wouldn't be too much work to have the Python program play a notification chime or noise of your choosing.
Text-to-speech: maybe not for every single email, but it would be cool to hear the Raspberry Pi tell you how many emails are in your inbox, or perhaps even read them aloud!