Raspberry Pi Desk Notifier

I was thinking to make a Desk Notifier which will notify me about my new email, Facebook & Twitter notification and finally I made it. I used the coolest single board computer Raspberry Pi to bring the thing in reality. This Desk Notifier will notify you about your new Gmail, Facebook notification and will show you the total number of new emails, total number of likes of your Facebook page, total number of notifications of your Facebook account and number of your Twitter followers. You can easily modify it to show others information such as number of tweets, number of friend requests, number of messages etc. I used only two seven segment for each information to show and for that it can show maximum 99 notifications. You can easily extend it if you like.

Step 2: Setup Raspberry Pi

To get started with Raspberry Pi you need an operating system. NOOBS (New Out Of the Box Software) is an easy operating system install manager for the Raspberry Pi. If you already bought a sd card with pre-installed operating system then just escape this step. If not follow NOOBS SETUP guide. You can follow the video from Raspberry Pi Foundation.

Step 3: Setup & Test of Email Notification

You need to download and install few things in order for Python to be able to properly check your Gmail inbox and show the number of unread email in the seven segment display. Connect your Raspberry Pi to your PC using Putty and enter the following command to 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

After executing all the command successfully try the following code snippet.

Attachments

Step 4: Setup & Test of Facebook Notification & Like Count

We will access our Facebook account using Facebook Graph API. Most request of Graph API need an access token as a parameter. An access token is unique to the combination of a logged in user or page and the Facebook App that makes the request. A token is associated with a Facebook app to handle the permissions that the user has granted to the app.

Attachments

Step 5: Setup & Test of Twitter

To access your Twitter account you need Access Key. Click here to learn how to get Twitter Access Key. Got it? Now, we need to download tweepy, an excellent python module to access Twitter API. To download and install just type the command:

sudo pip install tweepy

We are ready with Access Key and required module. It is the time to make fun with it. Copy the code snippet and save it to twitter-test.py.

Attachments

Step 6: Interfacing of Raspberry Pi & MAX7219 LED Driver

The MAX7219 lets us control lots and lots of LEDs using just a few Raspberry Pi pin-outs. No hassles with multiplexing, latching, refreshing or using up all your outputs – it handles everything for us. We just send commands to the MAX7219 and we can control up to 64 LEDs (a 8x8 LED Matrix) or eight seven (8 including the decimal point) segment displays, you can even chain multiple MAX7219s together to drive loads more. All this via just a few pins.

Both the Raspberry Pi and the MAX7219 support SPI (Serial Peripheral Interface), a good idea then to the get the RPi to talk to a MAX7219 via its very own SPI interface. By default SPI protocol is turned off but you can enable it very easily and can send and receive data.

We have completed connection. Now, lets enable SPI interface of Raspberry Pi. To do this,

1. Open terminal and type:

sudo raspi-config

A configuration window will appear like below.

2. Press down arrow key and select Advanced Options & click Enter.

3. Select SPI and click Enter

4. It will ask for confirmation, just press Enter to yes.

5. After confirming a new window will appear asking you like to load kernel default or not. Select yes.

5. You may ask to restart your Pi. Restart it. Now your SPI interface is enable.

Cascading, power supply & level shifting

The MAX7219 chip supports cascading devices by connecting the DIN of one chip to the DOUT of another chip. You can control lots of seven segment display or led matrix by cascading several MAX7219 IC.

Raspberry PI can only supply a limited amount of power from the 5V and 3.3V rail, so it is recommended that any LED matrices or seven segment are powered separately by a 5V supply, and grounded with the Raspberry PI. It is possible to power one or two LED matrices directly from a Raspberry PI, but any more is likely to cause intermittent faults & crashes.

Raspberry Pi GPIO ports used 3.3V for SPI, and MAX7219 IC operate on 5V so a simple level shifter should be employed on the DIN, CS and CLK inputs to boost the levels to 5V. It is possible to drive the IC directly by the 3.3V GPIO pins and in case of mine it works well. As I am driving the IC from 3.3V GPIO pins directly for that I used 3.3V supply for the VCC pin of the IC. I experimented with 5V but I got better stability from 3.3V supply. A 3.7V Li-ion battery works very well. You can use Li-ion battery directly to bias MAX7219 IC.

Step 7: Make the Circuit Diagram

The circuit diagram is designed by Eagle schematic editor. Source file is attached below. If you notice, a 10k resistor is connected between ISET and VCC pin of MAX7219CNG LED driver is. This resistor act as current limiter. I used 10k for 40mA segment current. You can find details about the value of this resistor to manufacturer datasheet.

Eight common cathode seven segment LED display is used for displaying four information. Two 7 segment for each information and for that it can show maximum value of 99. You can use more display for displaying greater value. The reason for using common cathode display is that, MAX7219 driver IC can drive common cathode display only.

I used 8 LED into four pin, each has two parallel LED which will blink when new notification or email arrived. Pin header SV1 is used to connect with Raspberry Pi and power source.

Attachments

Step 8: Design of PCB

PCB layout was designed using Eagle software. Four display group was created containing two seven segment in each group as I want to show four information. I created a provision for connecting LEDs above the displays. I did not implement it now but you can use it to blink when a new notification will come. In the last stage you will see i used the logo of Gmail, Facebook & Twitter at the bottom of the display to specify which information it is showing. You can use led at the bottom of the logo to make it bright. Option is there, you can use it in your own way.

Attachments

Step 9: Make the PCB (Toner Transfer Method)

I made the PCB for my project using toner transfer method. Toner transfer method is an excellent method for DIY PCB making. There are many excellent methods are available in the internet about DIY PCB making, so I don't like to explain it here. If you are interested about toner transfer method then you can follow:

Step 10: Drill the PCB

After etching the PCB you have to drill the PCB board. I use home made mini drill to drill the PCB. For details just follow the instructables: DIY Pcb Hand Drilling Machine.

Step 11: Solder All the Components

If you had made and drilled your PCB now it is the right time to put all the components to the PCB board and solder them. Some soldering technique is required to do the job nicely. Are you new in soldering? Have no previous experience in soldering? Don't panic! Soldering is an easy task!! Just follow the links:

Step 12: Make the Box (Cut PVC)

A box is required to fit all the component and Raspberry Pi. I made the box using 4mm thick PVC board. Just cut the board as your requirement depends on the size of your box. I made the box of dimension 20mm x 9mm x 5.5mm. For that I made:

2 pcs 20mm x 9mm

2pcs 20mm x 5.5mm

2pcs 9mm x 5.5mm

If you have access to leaser cutter then you can make more nice and elegant box using plywood.

Step 13: Make the Box (Use Hot Glue)

As I have no enough tools to make a nice box, I used hot glue to make a DIY box and I discovered that it is strong enough to make a box for such project. I just use the glue only inner side of the box and enough for it. I uploaded some image of my PVC box. Make your box without the upper part. For upper part follow the next step.

Step 14: Make the Box (Upper Part)

Yes, it is the time to make the upper part of our box. Make four holes according to the seven segment display to fix the circuit previously made. Consider the distance between the holes when making the hole. Make a measurement using roller. I used pencil to make the draft drawing to the back side of the board. This will help you to make the hole perfect.

Step 15: Attach the Circuit to the Upper Part

If you cut your board perfectly it will fit with the circuit board made earlier. Attach the circuit board to the upper part of the box. If it fit perfectly then congratulation! Now you can test your circuit either it is working or not. I am sure your circuit will work perfectly. I attached some image of working circuit. It is not our complete project. Just for demo testing.

Step 16: Let's Test

We are almost ready to test our circuit and configuration. Before testing we need some more download. To communicate with MAX7219 from Raspberry Pi we will use max7219 Python module. To download and install the module type the following commands:

We are completely ready to go. Type the following command into terminal

python

You will get like bellow

Now, type the following commands

import max7219.led as led

device = led.sevensegment()

device.write_number(deviceId=0, value=3.14159)

Is the value of pi is displayed into your display board? Congratulation!!! You made it.

Step 17: Complete Your Setup

Now fix the upper part along with the circuit to the box included with Raspberry Pi. Run the python program attached with the next step. The notifier will notify you about your new unread email, your Facebook notifications, total like of your Facebook page, Total follower of your Twitter account. You can easily modify the program to display others information such as friend requests, total unread Facebook message etc. Even you can use it to display the time & date as use it as a desk clock.

Are you ready to run the complete program? Follow the net step.

Step 18: Run the Complete Program

We completed all of the steps to make the physical thing. Now it is the high time to make the thing live using complete Python program. Clearly follow the program and replace "xxxxxxxxxxxxxxx" marks with your information.

You can download the source file attached below. Run the program using the following command:

sudo python iot-dashboard.py

If it works fine then CONGRATULATION!!!!

If you want to load the program automatically after reboot of raspberry pi then follow the instructions:

1. Make your file executable using the command:

sudo chmod +x iot-dashboard.py

You can test it by running the program directly by typing:

./iot-dashboard.py

Even though you didn't call upon Python the program should still run the same as if you'd typed python iot-dashboard.py. The program can only be run by calling it with it's full location /home/pi/iot-dashboard.py or from the current directory by using ./ as the location.

2. Make the program auto running:

In order to have a command or program run when the Pi boots, you can add commands to the rc.local file. This is especially useful if you want to be able to plug your Pi in to power headless, and have it run a program without configuration or a manual start.

2.1 On your Pi, edit the file /etc/rc.local using the editor of your choice. You must edit with root, for example:

sudo nano /etc/rc.local

2.2 Add commands below the comment, but leave the line exit 0 at the end, then save the file and exit.