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 (https://mail.google.com/gmail/feed/atom/important) 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
 *www.engineeringthecure.blogspot.com
 */
#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(){
  Serial.begin(9600);
  lcd.begin(16,2);
  pinMode(ledPin,OUTPUT);
  flag.attach(servoPin);
}

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

 
  delay(1000);
 
    
}
/*
 *parse  the email from incoming characters.
 *adding each character to email string
 */

void getEmail(){
    while(Serial.available()>0){
      char nextChar = Serial.read(); 
      email += nextChar;
    }
}
/*
 * print email and scroll it
 *
 */
void printEmail(){
  int emailLength = email.length();
  lcd.setCursor(0,0);
  lcd.print(email);
  delay(500);
  //scroll it to left until the final char of email is displayed on LCD
  for (int positionCounter = 0; positionCounter <emailLength-12; positionCounter++) {
    lcd.scrollDisplayLeft(); 
    delay(500);
  }
  lcd.clear();
  lcd.print(email);
  
}
/*This code play tune from melody array . 
* literally from public domain code
* from arduino Tone tutorial http://arduino.cc/en/Tutorial/Tone
*/
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;
    delay(pauseBetweenNotes);
    // stop the tone playing:
    noTone(8);
  }
    
}



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
USERNAME="youremail@gmail.com"
PASSWORD="yourpassword"
PROTO="https://"
SERVER="mail.google.com"
PATH="/gmail/feed/atom/important"
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:
                mySerial.write(0)
                time.sleep(10)
                #print("no mail")
        elif unread>0:
                gmail_latest = gmail.entries[0]
                title = gmail_latest.title
                author = gmail_latest.author
                #print (title)
                #print (author)
   
                mySerial.write("[{0}] {1} ".format(unread,title))
                time.sleep(20)
        mySerial.flushOutput()





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 :(




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


1)http://j4mie.org/blog/how-to-make-a-physical-gmail-notifier/   I got feedparser python code
2)http://blog.tinyenormous.com/2008/12/08/arduino-lcd-gmail-subject/ I got LCD title display idea. but link for download is not working . so I need to write mine.
3) Arduino.cc for all the resources

48 comments:

  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ẻ.

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  5. 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.

    ReplyDelete
  6. 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.

    ReplyDelete
  7. Superslot

    ซุปเปอร์สล็อต เราคือผู้ให้บริการสล็อตออนไลน์มีตัวเกมสล็อตให้เลือกเล่นจำนวนมากบนมือถืออันดับ 1 ทั้งฟรีเครดิต 50 ,100 , 150 , 200 ที่สามารถ

    ReplyDelete
  8. Superslot

    ซุปเปอร์สล็อต เราคือผู้ให้บริการสล็อตออนไลน์มีตัวเกมสล็อตให้เลือกเล่นจำนวนมากบนมือถืออันดับ 1 ทั้งฟรีเครดิต 50 ,100 , 150 , 200 ที่สามารถ

    ReplyDelete
  9. raw feeding, dog Are you a cat or dog owner looking to maximize nourishment for your furry family members? As a pet parent, you naturally strive to provide your pets with the best lifestyle options available

    ReplyDelete
  10. dog health
    Are you a cat or dog owner looking to maximize nourishment for your furry family members? As a pet parent, you naturally strive to provide your pets with the best lifestyle options available.

    ReplyDelete
  11. Reviews Yard

    At Reviews Yard Blog, we are committed to creating unique and customized content for our users that is useful for detailed information. We focus on applied information and a range of topics that can impact users in different technology areas.

    ReplyDelete
  12. reviewsyard.org

    At Reviews Yard Blog, we are committed to creating unique and customized content for our users that is useful for detailed information. We focus on applied information and a range of topics that can impact users in different technology areas.

    ReplyDelete
  13. english tutoring toronto Build your English foundational skills - including reading, writing and critical analysis - in our private English tutoring program

    ReplyDelete
  14. gogoanime

    GogoAnime - Watch anime online in high quality for free. Watch anime subbed, anime dubbed online free. Update daily, fast streaming, no ads, no registration ...

    ReplyDelete
  15. instalateri Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.

    ReplyDelete
  16. nonton bokep online Bokep Indo, Bokep Barat, Bokep Asia, Bokep Gay, Bokep Semi.

    ReplyDelete
  17. Thank you for oder my Gigs. Please share the details guide in the project

    shaw internet plans

    ReplyDelete
  18. animekiss The best place to watch dub and sub anime online and absolitely for free - KissAnime. With over 10000 different animes - KissAnime is the best source for anime ...

    ReplyDelete
  19. nzeta Thisare a private website offering our users online application services which include assistance with their application for Electronic Travel Authorization for travel to India. 

    ReplyDelete
  20. globalspoint Donec eleifend tortor a nibh dictum pellentesque. Donec congue turpis at commodo euismod.

    ReplyDelete
  21. voyance telephone espoir. I would recommend my profile is important to me, I invite you to discuss this topic...

    ReplyDelete
  22. Yacht excursions Cyprus A debt of gratitude is in order for giving late reports with respect to the worry, I anticipate read more.

    ReplyDelete
  23. buy tik tok followers Increase your exposure on social media! Check out our deals and buy Instagram Followers, Buy Youtube Subscribers, and more! Fast, cheap, and 24/7 Support.

    ReplyDelete
  24. buy tik tok followers Increase your exposure on social media! Check out our deals and buy Instagram Followers, Buy Youtube Subscribers, and more! Fast, cheap, and 24/7 Support.

    ReplyDelete
  25. buy tik tok followers Increase your exposure on social media! Check out our deals and buy Instagram Followers, Buy Youtube Subscribers, and more! Fast, cheap, and 24/7 Support.

    ReplyDelete
  26. buy tik tok followers Increase your exposure on social media! Check out our deals and buy Instagram Followers, Buy Youtube Subscribers, and more! Fast, cheap, and 24/7 Support.

    ReplyDelete
  27. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. high dofollow backlinks

    ReplyDelete
  28. I am very much pleased with the contents you have mentioned. I wanted to thank you for this great article. Үндістанға туристік виза

    ReplyDelete
  29. Nations in the Orient utilize two schedules. The Lunar Calendar is utilized for stately purposes and deciding the Animal Sign of the year. It is this Lunar New Year which you are altogether acquainted with from placemats at your #1 Chinese eatery. This schedule starts on the second New Moon after the Winter Solstice, which this year falls on January 26 And then, at that point there is the Solar Calendar. reiki near me

    ReplyDelete
  30. They empowered the clients to open bookkeeping pages and MS Word records from their mail accounts. Low spam scores

    ReplyDelete
  31. Thank you for sharing. I hope it will be useful for many people who are searching for this topic. The introduction of the Azerbaijan electronic visa has made it extremely convenient and simple for people to apply for and obtain an Azerbaijan online visa to enter Azerbaijan. There is no formality involved as the applicant does not need to visit the Azerbaijan Embassy or Consulate and the entire application process is conducted online.

    ReplyDelete
  32. buy twitch followers While many mainstream developers have been releasing a lot of graphically rich and intense games for the PC and various other platforms, many of them require your hardware to meet certain requirements and almost all of them can eat a huge chunk out of your wallet. Of course if you are looking for a way to kill time and have fun while doing it, there are still many free games that are being released by smaller developers.

    ReplyDelete
  33. I was welcomed by a companion and I keep the ball rolling. I got 50 welcomes when I have my record and I run out of them in extremely fast progression. Nowadays its free and anybody can have it in fast and simple tasks like 1, 2, 3. Gmail was the first in giving 1 GB free space to email, around then both Hotmail and yippee were offering 10 MB or so with the expectation of complimentary records. cheap web hosting India

    ReplyDelete
  34. This post is very useful, thanks for this post. The India evisa cost depends on your nationality and your required visa.

    ReplyDelete
  35. The content you shared with us is great. Thanks for sharing it. You can apply for an emergency visa to India by clicking the link we just provided. Thanks for adding value to the post.

    ReplyDelete
  36. https://www.buyyoutubesubscribers.in/2021/11/30/how-to-increase-youtube-views-by-yourself/ Do you want to get famous on YouTube? Of course you do, everyone does. The question is "How do you stand out from the crowd?" While many people post videos without any strategy at all hoping to have a video go viral, there are better ways to grow a fan base on YouTube. Others will try to buy more YouTube views in an attempt to make it look like they are more popular than they are in reality. Unfortunately, this strategy is going to backfire. This strategy is not going to help you establish a connection with viewers and grow a sustainable fan base for your channel.

    ReplyDelete
  37. https://dynamichealthstaff.com/jobs-in-dubai-for-nurses Every time something new comes out and gets outrageously popular - and people start making money from it - someone comes along to sound the death bell. It's normal and happens with almost everything - from fashion to electronics, to yes - even online writing. For a few years now, some have been saying that "SEO copywriting is dead." As the developer of an SEO content writing course, I received an email from a reader wanting me to explain if this was true. He wrote, in part: "Regarding SEO writing: [Named SEO professional] says SEO copywriting is dead. He proposes [something else] to replace it. In his article on this topic he makes a convincing case. Perhaps you might care to read it and see what you think." He provided links to a couple of articles, which I did read. Following is my opinion on the death of SEO copy writing.

    ReplyDelete
  38. https://hostinglelo.in YouTube is without doubt very popular thanks to the tons of videos it has. It has therefore also opened channels of making money not just for artists but also other people uploading videos to the site. In this era of online transformations where people are also looking for ways to make money without being employed or having to leave their homes, YouTube is an amazing channel to achieve just this. Here are some of the proven ways through which you can make money on YouTube.

    ReplyDelete