Monday, 16 April 2012

Physical Priority GMail notifier and retro mailbox with display, sound and flag

A brief history of GMail retro mailbox.

[from the previous post] While I am taking a little break last week for mid sem break, I decided to do a physical Gmail notifier , as if all notifications from my gtalk , phone and tablet are not enough . 
Well , the catch is this will notify me only for the important messages . So I can turn off notifications from other gmail clients notifying me of unwanted mails.
The design is simple ,using gmail's priority inbox feature)I fetch the important mail from gmail rss feed ( using python script and send data to arduino using pyserial .

What it does

The incoming important mail will raise the mail flag, display the mail title in LCD (scrolling) , light up notifier LED and play melody.

Watch a short demo video: 

The followings are photos of mail in priority inbox or lack of that.

Yahoo! You've got a mail. 
Woohoo! You've no mail

Tutorial : How to 

You will need :
Software list:

Hardware list
  • Arduino Uno or duemilanove board
  • LCD
  • Servo motor
  • Piezo speaker
  • LED 
  • 100 Ohm resistor
  • variable resistor
  • Mini breadboard
  • paper and sessior to make your own box

Step 1. Fetch Software

 Install software if you do not have them already.
Pyserial is python module for serial communication. Feedparser is module for parsing the emails. Pyserial installation is easy since it is exe file (if you use windows). However, feedparser installation could be tricky if you are a newbie to python like me. You need to add python directory to Windows' "PATH" envionment variables. Then use the command prompt to install feedparser as mentioned in feedparser documentation page. (Hit me up in the comments for any problem).

Step 2: Get Connected

Connect hardware components as follows.

Image is produced by using Fritzing.


Step 3: Get codes.

 Upload Arduino sketch file. You can change melody as you like. You can compose a new one all the notes are in pitches.h. Mine is a simple alarm melody that I like . simple piano score  B,G,A,D, , D,A,B,G.

 * This code reads serial port for email.
 * If mail is present, it will turn on LED, display on LCD and scroll the display,
 * raise flag and play defined melody
 *copyleft by Aung Thiha
 *created in April 12 
 *last modified April 15 
 *This code is in public domain
#include <LiquidCrystal.h>
#include "pitches.h"
#include <Servo.h>
#define MAX 45     // servo maximum degree. I am making it turn counterclockwise so 0 degree to 45 degreee. It depends on your servo position and configuration
#define MIN 0      // servo minium degree

LiquidCrystal lcd(12,11,5,4,3,2);
int ledPin =13;
char ser;
String email ="";
int servoPin = 9;
// notes in the melody: you can write any melody you like
// this is a tune I like. so I coverted the piano note 
int melody[] = {NOTE_B5,NOTE_G4,NOTE_A5,NOTE_D4,0,NOTE_D4,NOTE_A5,NOTE_B5,NOTE_G4,0};

// note durations: duration for a note to play. 4 = quarter note, 8 = eighth note, etc.:
// Not important for this tune, but u need to change it if you want to run other other tunes
int noteDurations[] = { 4,4,4,4,4,4,4,4,4,4};
Servo flag;

void setup(){

void loop(){
  if (Serial.available()) {
   ser =;     //read the serial port
          //if incoming character is 0, no mail, LED is low 
         if (ser == '0'){
             //lcd.write("You got no mail!");           
          //if other characters, servo flag turns, Lcd display and play sound"
         else if(ser > '0') {
           email += ser;
           getEmail();  //parse email function ,code block is below
           printEmail(); //print email ,code block is below
           playSound(); // play melody
           email ="";  // reset email

 *parse  the email from incoming characters.
 *adding each character to email string

void getEmail(){
      char nextChar =; 
      email += nextChar;
 * print email and scroll it
void printEmail(){
  int emailLength = email.length();
  //scroll it to left until the final char of email is displayed on LCD
  for (int positionCounter = 0; positionCounter <emailLength-12; positionCounter++) {
/*This code play tune from melody array . 
* literally from public domain code
* from arduino Tone tutorial
void playSound(){
   // iterate over the notes of the melody:
  for (int thisNote = 0; thisNote < 10; thisNote++) {

    // to calculate the note duration, take one second 
    // divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int noteDuration = 2000/noteDurations[thisNote];
    tone(8, melody[thisNote],noteDuration);

    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
    int pauseBetweenNotes = noteDuration * 1.30;
    // stop the tone playing:

Then save the following codes as pitches.h
 * Public Constants

#define NOTE_B0  31
#define NOTE_C1  33
#define NOTE_CS1 35
#define NOTE_D1  37
#define NOTE_DS1 39
#define NOTE_E1  41
#define NOTE_F1  44
#define NOTE_FS1 46
#define NOTE_G1  49
#define NOTE_GS1 52
#define NOTE_A1  55
#define NOTE_AS1 58
#define NOTE_B1  62
#define NOTE_C2  65
#define NOTE_CS2 69
#define NOTE_D2  73
#define NOTE_DS2 78
#define NOTE_E2  82
#define NOTE_F2  87
#define NOTE_FS2 93
#define NOTE_G2  98
#define NOTE_GS2 104
#define NOTE_A2  110
#define NOTE_AS2 117
#define NOTE_B2  123
#define NOTE_C3  131
#define NOTE_CS3 139
#define NOTE_D3  147
#define NOTE_DS3 156
#define NOTE_E3  165
#define NOTE_F3  175
#define NOTE_FS3 185
#define NOTE_G3  196
#define NOTE_GS3 208
#define NOTE_A3  220
#define NOTE_AS3 233
#define NOTE_B3  247
#define NOTE_C4  262
#define NOTE_CS4 277
#define NOTE_D4  294
#define NOTE_DS4 311
#define NOTE_E4  330
#define NOTE_F4  349
#define NOTE_FS4 370
#define NOTE_G4  392
#define NOTE_GS4 415
#define NOTE_A4  440
#define NOTE_AS4 466
#define NOTE_B4  494
#define NOTE_C5  523
#define NOTE_CS5 554
#define NOTE_D5  587
#define NOTE_DS5 622
#define NOTE_E5  659
#define NOTE_F5  698
#define NOTE_FS5 740
#define NOTE_G5  784
#define NOTE_GS5 831
#define NOTE_A5  880
#define NOTE_AS5 932
#define NOTE_B5  988
#define NOTE_C6  1047
#define NOTE_CS6 1109
#define NOTE_D6  1175
#define NOTE_DS6 1245
#define NOTE_E6  1319
#define NOTE_F6  1397
#define NOTE_FS6 1480
#define NOTE_G6  1568
#define NOTE_GS6 1661
#define NOTE_A6  1760
#define NOTE_AS6 1865
#define NOTE_B6  1976
#define NOTE_C7  2093
#define NOTE_CS7 2217
#define NOTE_D7  2349
#define NOTE_DS7 2489
#define NOTE_E7  2637
#define NOTE_F7  2794
#define NOTE_FS7 2960
#define NOTE_G7  3136
#define NOTE_GS7 3322
#define NOTE_A7  3520
#define NOTE_AS7 3729
#define NOTE_B7  3951
#define NOTE_C8  4186
#define NOTE_CS8 4435
#define NOTE_D8  4699
#define NOTE_DS8 4978

Then get python script. Open new Window >> paste codes >> saved it under any name 
with .py extension. Put in your email, password, change serial port that is same as port on
arduino.I pointed the path to "important" label to get priority mails. You can change that 
to specific label just by pointing to your label instead of important. You can set your own 
filters and label as explained in the link.Reminder about python: index is very important in
python. Copy exactly as follow.

import serial, sys, feedparser,time
#Settings - Change these to match your account details
mySerial= serial.Serial('COM5',9600) #change port to  your setting.

while True:
        gmail = feedparser.parse(PROTO + USERNAME + ":" + PASSWORD + "@" + SERVER + PATH)
        unread = len(gmail.entries)
        #"print ("Unread:{0}".format(unread)) #uncomment if you want it to dispaly on your desktop
        if unread ==0:
                #print("no mail")
        elif unread>0:
                gmail_latest = gmail.entries[0]
                title = gmail_latest.title
                author =
                #print (title)
                #print (author)
                mySerial.write("[{0}] {1} ".format(unread,title))

Step 4. Test it

Run python script by using F5.

You can always disable some function to suit your need. e.g You might not want sound or display the message at certain time. Then you just need to disable that part of code on arduino. I wrote it in code block exactly to do just that.
If something is wrong , check the connection.

Step 5. Put genie in the box :)

Create the box as creative as you can. I create a cube just because I love the cube design. (not because of Steve Jobs btw.)

Yahoo! You've no mail :)

You have got a mail :(

There are links that give me inspiration and some codes :)

1)   I got feedparser python code
2) I got LCD title display idea. but link for download is not working . so I need to write mine.
3) for all the resources


  1. Thanks for sharing, nice post! Post really provice useful information!

    Giaonhan247 chuyên dịch vụ vận chuyển hàng đi mỹ cũng như dịch vụ ship hàng mỹ từ dịch vụ nhận mua hộ hàng mỹ từ website nổi tiếng Mỹ là mua hàng amazon về VN uy tín, giá rẻ.

  2. Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! 2011 Aged/Old Gmail

  3. Just admiring your work and wondering how you managed this blog so well. It’s so remarkable that I can't afford to not go through this valuable information whenever I surf the internet! Buy Old Gmail Accounts

  4. I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. hotmail entrar

  5. Yahoo mail is an web based email service. Yahoo mail service can be accessed through different devices including computer, tablets, smart phones, and more. Users with a valid Yahoo account can sign into Yahoo com to access the features of Yahoo mail. A smile web browser can be used to sign into Users can also download Yahoo app to their mobile phone and login to their account. yahoo mail sign in

  6. buy smart carts online. organic smart cart. are the high potency distillate free from any solvents. If this product was accurate with its claim.

  7. hiring movers in California

    So, you have decided to take a step ahead and make the very difficult decision of your life that is to relocate or plan a move. This will be the most stressful time you will ever have if you haven’t planned it properly. If you’re planning to move your house or business to an entirely new state or place then you must be cautious about how you will take the things and most importantly, how will you carry them? Right, if yes then choosing the right moving company is what you have to do.

  8. Latest News Dental Success Blo

    Townie News Wire. Events. Upcoming Events Townie Webinars. More. Free e-Books Townie Poll Townie Perks Student Membership · Download .Most Active Blogs. Skip Navigation ... Dentaltown Learning Online. By Howard ... 11/6/2018 · Dental Success Blog ... The Best Practices Show with Kirk Behrendt.