The most important canine in the history of UNIX is called biff, and its name was used to name the program which notifies users of incoming mail. The biff program notifies the user’s terminal when it is told to do so by the comsat server process after receiving a report of incoming mail.
With the advent of Web-based and desktop e-mail clients, the popularity of biff has diminished as these systems usually have some other way of notifying a user of new mail. Even so, as a first little Arduino project, I’ve created an alternative biff-like system in the form of a US letter box. (Some more examples).
I want to keep this simple, concentrating on trying to understand what the Arduino is capable of, and looking into doing fun things with it.
Even though I have an Ethernet shield for my Arduino, I’m using a serial connection here, which many will prefer, as it lowers the cost of the total setup. Speaking of which, here is what I used:
- Arduino Duemillanove, but any other board will suffice.
- An inexpensive 5V servo motor.
- Four (4) LEDs, any colour.
- Piezzo buzzer.
- Half a bar of white chocolate.
Depending on what type of e-mail setup you have, there are a number of ways how to determine you have new messages (i.e. unread e-mail) in your mail box. You’d have to modify this portion if you want, for example, to find out how many unread messages you have in Apple’s Mail.app, Outlook, or whichever.
On UNIX these two are typical:
With a trivial comsat-type daemon you run on UNIX/Linux. This UDP-based service is sent a UDP datagram by a mail delivery agent as soon as your (and anybody else’s) mailbox on the system gets a message deposited on it. Note, that you’ll be able to use this only if you don’t already use a system-wide comsat service. There are several programs out there which inform comsat of new mail: one of these, is the versatile [procmail] delivery agent.
I’ll be discussing a small Perl program which queries your IMAP account to determine the number of unread messages waiting for you.
If you’ve been following closely, you’ll have noticed there is a fundamental difference between these two methods. Using comsat, we are informed that one (1) new message has arrived each time it arrives, whereas the second, gives us a total count of unread messages each time we query the server. Keep this in mind for now, and we’ll see later, how I handle this. (I’ll be using a “protocol” to tell the Arduino whether to increment or to set the count of unread messages.)
This is what the finished “product” looks like:
The biff machine consists of the parts stuffed into a box. My young “art designer” was responsible for the colours. :-)
The sketch running on the Arduino handles the serial communication, reading a
line of text (using the Arduino [String library]) from the serial
connection, incrementing or setting the message counter depending on whether
the input line starts with a “
+” or “
=” respectively. If the unread count
is non-zero, the letterbox “arm” is raised, and the unread count is displayed
in binary on the four LEDs. (You can use more if you like – simply change the
BITS to match.) Note that I force the unread count to the
maximum value allowed by
BITS to ensure that all LEDs are lit, because an
overflow of bits could indicate all LEDs off, even though unread count is set.
I tested the sketch with the serial monitor in the IDE, sending it either a
+1E (one new message) or something like
=5E (a total of five unread
When the Arduino modifies the unread count, it emits a beep on the piezo buzzer; you can [make it play a nicer sound], however, if you desire.
The Perl program below connects to the [serial proxy] on the machine to
which my Arduino is connected via USB. The serial proxy translates a TCP
connection to a port you specify in
serproxy.cfg to a particular serial
The wiring on the breadboard isn’t difficult, although mine is looks very messy. (Remeber, it is my first time…) ! Here is the board layout (with one LED only), done with [Fritzing] (a nice program – if only I could lay the wires out nicely). [!] You’ll notice I’m using the marvellous [1 cent Arduino undershield] (Open Source too! :-) ) to fasten the microcontroller to the breadboard.
As far as the “finished” product is concerned, ahem, here are some pictures: first the inside of the box: ! and then the “biff machine” with a raised flag and showing eleven unread messages: ! What I’ve learnt, you ask? Well, quite a bit:
- Arduino is a huge bit of fun.
- I need a new pair of eye glasses so that I can correctly identify the teeny tiny little bits and pieces. I’m not kidding.
- My “enclosure” sucks, and it is a very far cry from [professionalism].
: : http://jpmens.net/media/2009/DSC_0297.jpg : http://www.arduino.cc/en/Tutorial/TextString : http://jpmens.net/media/2009/ZZ7346C9D0.jpg : http://www.arduino.cc/es/Ejercicios/Piezo : http://www.arduino.cc/en/Main/Software : http://jpmens.net/media/2009/DSC_0291.jpg : http://fritzing.org/ : http://jpmens.net/media/2009/biff.jpg : http://jpmens.net/media/2009/biffboardlarge.jpg : http://todbot.com/blog/2007/11/14/the-1%C2%A2-arduino-under-shield/ : http://jpmens.net/media/2009/DSC_0295.jpg : http://jpmens.net/media/2009/DSC_0298.jpg : http://en.wikipedia.org/wiki/Laser_cutting