AtTiny45 USB LED Mail, Twitter & Pidgin Notifier

The atTiny45 USB LED E-mail, Twitter and Pidgin Notifier

This is an interesting little modification that i have completed on my EeePC901.  Based on an Atmel aTiny45 processor it's function is relatively simple, but as it is built from scratch, the build took some interesting twists and turns.  Not only that, but it also has a nice little social story that for me was part of what made it such an engaging little project.

My Led notifier uses a relatively small parts list:

  • An Atmel AtTiny45 Microprocessor
  • A 5mm RGB (Red, Green and Blue) LED
  • 2 diodes (almost any kind will do, but I used MK96 5B410 Diodes as they were the first out my spares box)
  • 5x 68R 1/4w resistors
  • 1x 1.8K 1/4w resistor
Pretty small set of parts. 

Background to the project

So where did this project begin?  Well I am not 100% sure when I decided to build an LED notifier.  I originally saw Dave Hillier's Blog a while ago.  Dave gives details on his project which adapted a glowing light cube into a Gmail notifier.  I remember being impressed with his project and  I bookmarked it. I
t was based on an Atmel processor and I had ordered a programmer.

I don't think though that I would have built Dave's notifier had it not been for this thread on EeeUser.  Dave had designed his front-end software to check his Google mail account and light up if a new e-mail arrived.  Personally I do have a g-mail account, but it is not my only one.  Thunderbird is my main e-mail client and it downloads from several accounts.

In the thread someone I already know, AlphaCentuari (AKA Dennis), (owner of this blog) gives details on a notifier he had built using a Picaxe controller.  Dennis had put some good work into his project, both programming the Picaxe and also developing a front end script that checked Thunderbird, Twitter and Pidgin for incoming IM's, email message and twits.  The scope of this project made it much more suited to my needs. 

However, Dennis's project used what I considered to be a fairly convoluted method to attach the LED to the EeePC.  Basically Dennis had used a USB to serial converter to attach to his EeePC.  Then the Picaxe talked to the serial signal from the converter.  This is fine for an external device, but to include internally meant some hardware that I felt was superfluous. 

I entered the discussion on the thread and pointed Dennis to Dave's project.  If Dennis had not been generous enough to switch over to the Attiny version, I doubt that I could have completed this wonderful little device. 

Building the The atTiny45 USB LED E-mail, Twitter and Pidgin Notifier

This is the schematic for the LED notifier.  It's pretty simple stuff.  The AtTiny connects to the usb port.  To give a brief explanation. 

Pin 8 of the Attiny45 is connected to the V+ of the USB port.  However this circuit needs to run at 3.3v or thereabouts.  In order to take the 5v of the USB port and bring it down to the correct voltage two diodes are used.  This takes advantage of the fact that when power passes through a diode it drops voltage by around 0.7v.  So having two in series is a simple way of getting to the correct voltage.  This is very compact and negates the need to use voltage regulators (and associated additional components) in the circuit.

Pins 7 and 5 connect to the D+ and D- signal lines of the USB port.  68R resistors limit the current and the 1.8k resistor is used to pull up the line to pin 5.

Pins 6, 3 and 2 are the Red, Green and Blue outputs to the LED,  the schematic shows 3 LEDs, but a single RGB LED has pins for the 3 inputs. 

Pin 4 and the cathodes of the LED's connect to the ground of the USB.  The 68R resistors here are to limit the current passing through the LEDs. 

I decided to build initially a prototype to try out the LED notifier.  Using protoboard, I decided not to bother with adding a proper usb connector.

Stripboard has by good fortune the correct widths to be simply shaped and inserted into the usb port. I glued some card to make sure the USB contacts were pressed correctly against the contacts.

Testing the LED, I found that the clear RGB LEDs in my parts bin were acutally quite difficult to see when lit.  I fashioned a diffuser by soaking a tissue in superglue and covering the LED lense.  The visual effect is not dissimilar to that of a sugared Jelly.  This did lead me to have to think about how I would diffuse the LED light when fitting one to my EeePC.

After some trials and tribulations getting my LED prototype programmed and working, I eventually had a functioning prototype. I sent a programmed chip to Dennis as well to let him experiment with the USB controlled device. 

My main issue was not in fact programming the chip.  Dave Hillier has published his source code here.  He included a makefile which I managed to compile on my linux operating system.  I had to install some additional programs to get the compile to happen.  But once I did I used the make command to produce first the hex file for the Attiny45 and then to program it.  My main problem was that once I had compiled the program that communicated to it I was pretty useless when it came to running the program.  Linux is a package that is new to me and I am still learning!  A bit of help from both Dave and Dennis and I got there though...

There are three main pieces of software that I had to compile and use:

  • The firmware for the Attiny45
  • A program written by Dave Hiller called set-led, this send the actual commands to the device.  It can be directly run from the command line to test the device.  In Linux the command is "sudo set-led rgb 255 0 0" (for a red light).  I eventually worked out how to add this program to the usr/bin folder and give root priviliges to it.
  • A script to talk to Thunderbird, Twitter and Pidgin, written by Dennis (AlphaCentuari) which runs the Set-led program at the correct time.

Dave has written his own script that as I said earlier talks only with Gmail.  Dave's script is able to run in either Windows or Linux.  The script that i am using which was written by Dennis, only works within Linux as Thunderbird and Pidgin are capable of using the Dbus (unavailable in Windows) to send notifications.  I had to install an add on to Thunderbird to allow it to send notifications.

With software installed and the script now configured to run from startup (this is done by adding a shortcut to the notifier script in the startup applications manager (System=>Preferences=>Startup Applications in Eeebuntu) my prototype was working perfectly.

Next thing to do was to install the LED in my EeePC. 

I considered various options for the LED placement, but decided that the best place for it was at the top edge of my screen.  This had the advantage that the LED could be seen from any direction and also if the lid was closed.  It means that i can leave the EeePC running on mains power on say my coffee table and see easily if a mail or IM message arrives.  The LED lights in different colours depending upon what is being notified. 

The first job was to disassemble the EeePC completely, including removing the LCD screen from its case. 

Once I had done so I found a spot that would suit the LED.  In the Eee there are two WiFi ariels and a camera in the area at the top of the screen.  This limited placement to near either the left or right hand corners.  I picked the right hand side.

Next I ground out a rough hole using my Dremel and a grinding stone.  I got it near correct, the close up here makes it look far less perfect than the naked eye sees.  Using the grinding tool had a pleasant unintended effect.  The plastic on the screens bessel is soft and melted slightly.  This makes it look as though it is moulded to accept the LED.  It maked it look as though the LED was part of the origional design. 

Since taking the picture the rough edges have been trimmed with a craft knife making the whole job look a little neater again. 

The LED itself required a little reshaping in order for it to fit comfortably in the slot.  LEDs have a ring around the base that allows them to be panel fitted.  A quick grind with the dremmel and this was removed on two sides to allow the LED to sit in the tight space inside the case. 

I also had to grind out a little of the plastic strengthening in the case to allow the wires to clear the LCD screen. 

You can see in the picture that I taped the wiring for the LED down where it sits behind the screen.  For this I used conductive aluminium tape.  I had some to hand, and I thought that as the LED will be controlled using PWM (Pulse Width Modulation) it was a suitable precaution to prevent interference. 

You can also see in the picture that the LED appears to be opaque.  I needed to diffuse the light of the LED to make the light visible.  I experimented a bit to try and find ways to diffuse the light.  Options that I tried were sanding the bulb, gluing clear acrylic rod to the LED and also making diffusers from acrylic sheet.  In the end the best solution I found was to spray the LED with several coats of a product called "Plasti-Kote Glass Frosting" that i found in the art store.  Several coats of it gives the LED the appearance of an opaque light bulb.  The LED when lit lights up very evenly, particularly useful when colours are mixed eg. Red and Blue gives a fantastic purple.

The screen was reassembled and I was ready to put together the controlling circuit. 

Dennis has developed a PCB which uses surface mount parts to create the device.  During the design I suggested a couple of changes to the board that would make it suitable for use internally.  However for this build I wanted to show how the more accessible through hole AtTiny45 version could be used. 

Realistically, there is not space inside the EeePC901 that I have to make a circuit using through hole components on a prototype board.  However I did find a spot where the circuit could be made "Deadbug" style.  "Deadbugging" means soldering components directly to the legs of the chip.

Within the base of the EeePC there is two cavities to the left and right of the battery.   There is enough space in these cavities to hold a chip and the resitors needed.  I soldered these together and where possible heatshrinked everything to ensure short circuits could not happen.  

I have to admit that this was my second attempt at the circuit.  I competed the first only to snap the legs off the chip when I tried to fit it.  I had used my origional prototype's chip which had been in and out of chip holders a few times during testing and programming.  Evidently I had weakened the legs somewhat.  The second chip proved a lot more durable.

USB wise I already had a hub from my Touchscreen Mod installed in the EeePC.  This I used to connect to.

I reassembled and tried out the LED.  I am happy to say that the LED worked first time. 

The LED notifier lights up and is extremely visible from anywhere in the room.  Even whilst typing this up, the red light has come on a couple of times.  Eeebuntu normally sends a notification in the top right corner of the screen when a mail comes in.  However when focused on typing into another area, I sometimes miss out on the notification or notice it just as it fades.  The Red LED really stands out!

Now some money shots :)

Pretty Cool?  

Better than cool, the The atTiny45 USB LED E-mail, Twitter and Pidgin Notifier is a useful tool.  The only downside to this modification is that I can see myself becoming a complete slave to my e-mail.  When that light flashes I just HAVE to know who has mailed me...

For the script that Dennis wrote that monitors Gmail, Twitter and Pidgin click here and visit his blog.  (May I be as bold as to suggest a small donation to him as a thankyou) if you read through his blog entry you will find a link to the files