Terminal TTY-1

root@ag33k.net:/bin $ ll root@ag33k.net /src $


I built a simple gmail notifier that pops up a flag when you have new email

After seeing an email notifier on hackaday that rings a hotel reception bell when you have a new email I decided to work on the idea.

I like the idea of a flag or semaphore system to show a new email or other notifications.

I found that Gmail uses an ATOM feed for email so set about making a tool that would work with it to create a nice flag.

Using C# and a gmail library I was able to authenticate and get the ATOM feed. From here on in it was just a matter of getting the tag from the XML.

Im no XML expert but after an hour of tinkering I managed to get it working.

This is the code for the C# console application, this is at the moment a work in progress as I need to add a configurator or command line arguments for it to be usefull as a standalone program.

At the minute I cannot get it to quit without CTRL+C, I will figure out key pressing without pausing the loop and add it in.

The code require a library called GmailHandler, I have the file here and you just add it as an existing item as a class.

The code

C# console application

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.Threading;
using System.Xml.XPath;
using System.IO.Ports;

namespace GmailNotifierSerial
    public class Options
        public string username = "";

        public string password = "";

        public int comport = 3;
        public int refresh = 3000;

    class Program

        static void Main(string[] args)
            var options = new Options();
            var parser = new CommandLineParser(options);

            if (!parser.ParseCommandLine(args))
                return 1;

            string port="COM"+options.comport;
            SerialPort arduino = new SerialPort(port); // set this to your com port of your arduino

            GmailHandler gmailfeed = new
            GmailHandler(options.username, options.password);
            Console.WriteLine("Starting Gmail App");
            string q = "";
            while (q=="")
                XmlDocument myxml = gmailfeed.GetGmailAtom();

                XmlNodeList xnlist = myxml.GetElementsByTagName("fullcount");

                int newemail = int.Parse(xnlist[0].InnerText);

                if (newemail > 0)





Arduino code and wiring

You will need:
  • 1 x Arduino (any will do)
  • 1 x Servo
  • 1 x Power source as usb cannot power the servo
  • 1 x Flag for the notification
  • Breadboard and jumper wires

The code is very easy and is available here

// 19/09/2012
// ag33k

#include  // include servo libraries

Servo gmail; // create a servo instance called gmail

int servopin = 9;   // use this for the pin number for the servo
int input;          // input from the serial interface
char buffer;        // buffer for serial if needed in future

void setup() {
  Serial.begin(9600);        // Open serial at speed 9600
  gmail.attach(servopin);    // attache the servo instamce gmail to the pin servopin

void loop() {

  if (Serial.available()) { // check for available data in serial buffer
    input=Serial.read();    // get the byte as an integer
    if (input==1){           // check if it is a '1'
      gmail.write(0);        // set servo to angle 0
    }else if (input==3){     // check if it is a '3'
      gmail.write(120);      // set servo to angle 120


Connect the wiring as per this image

Once you have it wired and uploaded on the Arduino edit the config for the gmail app and run it.