Physical GMail Notifier v2
Feb 23
Projects Arduino, VB6 3 Comments
Based on original idea by Jamie Matthews
What is it?
When you’ve got new mail, in your GMail inbox, a led blinks. By modding the source you can make new alerts, like sound alerts, vibration alerts, there’s no limits.
WOW! 3 blinks! I’ve got 3 new mails!!
This project is composed by 2 parts:
- Software side
- Hardware side
Software side
Written in VB6, this app only does 2 things. It checks if you have new mails, and it tells to the hardware part how many new mails there are.
Hardware side
Based on Arduino, the hardware read from the usb port how many new mails there are.
If there are 0 new mails, it does nothing.
If there are 1-9 new mails, it blinks X times, where X is the new mail count. Hey, it’s not a simple “blink blink”… Led fades on and off, it’s smooooth!
If there are 10+ mails, led turn on and keep on until you read (or delete!) mails.
Cool? No, not rly. Here’s the cool part:
1- Software and firmware are FREE and OPEN SOURCE
2- You can do this without any programming or electronic skill: just plug in cable, install drivers, and run app.
3- Rly cheap. Part list: an Arduino Diecimila (~15€), an usb cable (~5€), a LED (~0.1€), a GMail account (free!), a PC (hey you already have one, i’m sure), an internet connection (uh?). —-> TOT: 20.10€. Oh, i forgot. If Arduino is TOO EXPENSIVE (…) you can build it by yourself; it’s opensource, too!
Let’s begin!
Software Side, written in Visual Basic
Files needed:
- MS Visual Basic 6 runtimes – http://support.microsoft.com/kb/290887
- MS Comm Control 6.0 (mscomm32.ocx)
- MS Internet Transfer Control 6.0 (msinet.ocx)
The main (and only) form looks like this:

There are a few buttons.. but don’t worry you don’t have to use them if you don’t want to play around with Arduino.
On the top left you can see a text box and a button to send data to Arduino. Just in case you want to test how arduino reacts to some bytes.
In the center there are the manual check mail button (guess what: it checks for new mail.) and the big debug textbox. Everything PGN2 does is logged here.
Sending data to serial is quite simple:
Public Sub SendToArduino(Text As String) On Error Resume Next With Serial .DTREnable = False 'oh, some settings. .RTSEnable = False 'this, too. .PortOpen = True 'we open the port... .Output = Text 'we send the string... .PortOpen = False 'and we close the port! Remember: always close the door. End With End Sub
I think it’s clear, isn’t it?
Arduino accepts 1 char at time, so… what to do if there are 100 new mails?? I think it’s quite boring to see a led blinking 100 times. I prefer it works in this way:
no new mails: led off
1-9 new mails: led blinks n times
10+ new mails: led always on
but.. how to send “10″ if Arduino only accepts 1 char?
No problem. We don’t send “10″. We send “:”. If Arduino receive “:” it knows this means there are a lot of new mails.
Now the big problem is how to check mail.. Hey Google offers a “feed” version of your inbox! Try to paste this address into your browser:
https://username:password@mail.google.com/mail/feed/atom
Please do not put the symbol “@” in your username. Use “+” instead. Example:
https://bill+gmail.com:linuxsucks@mail.google.com/mail/feed/atom
With visual basic we can parse this page with the Internet Transfer Control.
Private Sub CheckMail() On Error GoTo ERRR 'error handling. a must. Log ("Checking mail...") Dim STRTemp As String 'in "strtemp" we put the whole web page STRTemp = INet.OpenURL("https://" & Username & ":" & _ Password & "@mail.google.com/gmail/feed/atom") STRTemp = Right(STRTemp, Len(STRTemp) - InStr(1, LCase(STRTemp), "fullcount") - 9) 'ok with this step we delete all the crappy things to the left of our mail count STRTemp = Left(STRTemp, InStr(1, STRTemp, "<") - 1) 'and with this step we remove the right part, too. So, we've got only the mail count! Log ("New Mail(s): " & Int(STRTemp)) If Int(STRTemp) > 9 Then STRTemp = ":" 'if we have more than 9 mails, we tell arduino to keep the led on SendToArduino (STRTemp) 'send to arduino the mail count! Exit Sub ERRR: Log ("Error in CheckMail: " & Err.Description) Resume Next End Sub
Hardware side, Arduino language
Ok, so now we have sent a byte to the serial port. Now, the hardware part.
Arduino language is quite easy to understand. The whole code is here!
int outPin = 11; // Output connected to PWM pin 11 int mail = 0; // mail count int val; // Value read from the serial port int pwm = 0; // Led PWM control int myloop = 0; void setup() { Serial.begin(9600); Serial.flush(); } void loop() { // Read from serial port if (Serial.available()) { val = Serial.read(); Serial.println(val); if ((val > 48) && (val < 59)) mail = val-48; // 48=0mails 49=1mail 50=2 ... 57=9 58=: // : is more than 9 mails, so we keep led always on else mail = 0; } if (mail == 0) analogWrite(outPin,0); if ((mail > 0) && (mail < 10)) { for(myloop = 1; myloop <= mail; myloop+=1) // loops N times (N = new mail count) { for(pwm = 0 ; pwm <= 255; pwm+=5) // fade in (from min to max) { analogWrite(outPin, pwm); // sets the value (range from 0 to 255) delay(20); // waits for 20 milli seconds to see the dimming effect } for(pwm = 255; pwm >=0; pwm-=5) // fade out (from max to min) { analogWrite(outPin, pwm); delay(20); } } delay(2000); // waits 2 seconds before beginning next loop } if (mail == 10) analogWrite(outPin,40); //or if there is A LOT of mail, it keeps led on }
Done. That’s all.
All you need to do is to edit your PGN2.ini file with your settings (username, password, com port…)
Here’s a few links:
- all files used in this project
- Arduino
- Source codes
And what I plan to do:
[ ] Better GUI -VB
[ ] Encrypted password storage -VB
[ ] Maybe, different blinking style (fade on, blink N times, fade off) -Arduino
[ ] TrayIcon -VB
[ ] Remove the 65 seconds limit (vb timer control limits interval to 65536 ms) -VB
Help is appreciated, and comments too!
Home
RSS
Twitter
Facebook
Jun 20, 2010 @ 21:15:11
!
Jan 02, 2011 @ 08:17:36
do i need a special program to run the visual basic code? If so what is it ? Or do i just type it into note pad?
Jan 03, 2011 @ 07:35:50
you need microsoft visual basic 6!