Power to the People of Iran



Hello...
..and welcome to eeeGadgets! This blog is dedicated to everything associated with the wide (and interesting) field of mobile computing. The main focus is on presenting all the various hardware modifications I made to my eeePC, but I will also give short reviews of other interesting Mobile Internet Devices I come across. Further I want to share some tips and tricks I found out to be helpful in getting the most performance out of Ubuntu linux...
On the right side under "LABELS" you can navigate between various assorted article categories. Also, on the very bottom of the site you will find some useful weblinks, as well as a small broadband connection speed test (which can be very useful sometimes).
If you want to, you can subscribe to my RSS news feed too, to be always up to date about my latest articles - simply click on "subscribe now!" in the little box on the right side. Alternatively, you can subscribe to my simple email newsletter by clicking here.
For questions, feedback, suggestions, criticism and everything else, don't hesitate to contact me:
emailfuerdennis@web.de

....have fun reading!

If you like my site and want to support me , you can always donate to my personal "coffee funds" using the PayPal "donate" button further down on the right! :)
Dennis

Wednesday, May 27, 2009

HowTo: make a small LED email notifier

I guess after my last articles bearing somewhat randomized topics it is time for a real "eeeGadget" again.. So, what about having multi-color LED signaling incoming email (and ICQ instant messages) for you, visually with various blinking colors for assorted message types, even when your netbook's lid is closed, for example? This is easily done using just a small circuit centred around a cheap 8-pin "picaxe08M" microcontroller, a USB/serial adapter cable and some python scripting (well - it surely can be done in a million different ways, but thats how I approached things!)...
















The whole idea is based on Toms original design of a LED mail notifier, but I refined things a bit (specifically the py script part) to better suit my needs (also big thanks go out to Pete from nermal.org for his assistance/ideas regarding python coding!).. The device listens to instructions sent over the (emulated) serial port of my usb/serial converter by two python scripts. Those scripts regularly check my gmail account for new incoming mail (done by the first script which is called every ten minutes as a CRON scheduler job) and - this is where the other script comes into play - continuously listen to dbus system alerts concerning new instant message arrival, which are issued by Pidgin (my favorite instant messenger) as soon as a new instant message is being received (thanks to a Pidgin dbus notifying plugin). This can also be done with Thunderbird (email client), provided the necessary thunderbird dbus plugin is installed.
But first lets have a look at the hardware:


wiring schematic of the PICaxe circuit


The hardware part is simple (see schematic above). It consists of only six resistors, one common cathode RGB LED, a picaxe08m microcontroller (and some 9-pin female serial port connector) . The picaxe listens on Input 3 to bytes sent by the python script(s), and encodes Outputs 0, 1 and 2 according to the last three bit of each byte received. If it receives the ascii sign "1" the LED comes up red, "2" causes a green color and so on (there are seven possible colors). If it receives "8" the picaxe switches off the LED. It can be easily built on some piece of veroboard - but for the sake of being able to build this into my eeePc's interior (it has to be really small and tiny) I decided to design a small PCB using only surface-mount components (besides of three wire bridges).
this is scaled up to 200 percent already!

The python script that gathers email information is using the python "feedparser" library to fetch an RSS/atom feed of my gmail account's inbox two times in succession, each five minutes. If the number of mails in my "inbox" mail folder has increased (meaning new mail has arrived) the LED slowly flashes in red for, lets say, seven times when I have seven new emails. As soon ( a few minutes later actually) as I have read all my emails, the atom feed is updated with the new overall mail number "zero", and the LED doesn't light up anymore. The script is launched regularly every ten minutes by cron scheduler, so overall it observes my email inbox folder nonstop every five minutes. I reckon this is a bit often, but as long as it doesn't hurt...
The other script listens nonstop on the dbus for incoming alerts from Pidgin Instant Messenger, and decides whether the incoming message is from

a) a known person ("buddy")
b) a certain domain (for example all messages from employees of one company)
c) unknown person

Then the corresponding byte sequence is sent to the picaxe (who is using the last three bits of each byte to decide which pin to put high or low). For each of the three types of message the python script sends out the right bytes with the proper delay, so the LED is flashed accordingly: in case A it flashes fast and green for a few seconds, for B it flashes fast, red and not long (only a short burst) and for C it blinks three times very slowly in blue.
Both scripts also give some info output on the console, but can perfectly run in the background too since they don't need user interaction.. Only problem for windows users, the pidgin/dbus thingie doesn't work outside linux since there exists no dbus extensions for win32 (not yet, but a windows port of dBus is in development!). The email notifier does work with WinXP though.



fuzzy picture of the secret prototype :)

UPDATE
You can download the needed python scripts and PICaxe basic code here
http://www.mediafire.com/file/qyykwnxj4mk/notifier_gmail.py
http://www.mediafire.com/file/5q0y5mzzmhd/notifier_pidgin.py
http://www.mediafire.com/file/qzmznxjgjln/twinkle.bas
Heres a small script to test your circuit (cycles through all colors one time)
http://www.mediafire.com/file/qdjdlycjgmz/LEDtest.py
Also here's the PCB layout
http://www.mediafire.com/file/mf5iyytohyo/twinklePCB.bmp

The scripts are written for python 2.6/linux and need to be customized a bit,
for example you need to change the buddy ICQ number entries to match your
buddy list, and adjust the /dev/ttyUSBxxx to your serial port's name...
Also you may need to install python-serial and python-time from the
ubuntu repositories, then it should work.

UPDATE2
This all is "deprecated" as they say in linuxland. In other words it should be considered "public alpha" release and has been superseded by my all-new and shiny dBird notifier script collection as detailed in the article ABOVE. (just wanted to mention it here too)
cheers

No comments:


Broadband Connection Test:

Just click on "Speedtest starten" to evaluate your actual downlink in MBit/sec (takes 10 seconds approx.)


(c) dsl-speed-messung.de - DSL Speed Test