All about laptops and netbook!
Archive for May, 2009
HowTo: make a small LED email notifier
May 27th
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
New Asus Eee PC 1000HV for Italy and Eeebuntu Base 3.0 Now Available
May 23rd
Italy is to get the new Asus Eee PC 1000HV soon as part of a new launch expansion while Asus France is looking to slim down its Eee PC range.
The Eee PC 1000HV is basically the same as the Eee PC 1000HE but with one defining difference: enhanced graphic abilities. The new 1000HV is to receive the ATI Radeon HD 3450 with 256MB of dedicated memory while the previous lines have the integrated Intel GMA 950 graphics. So it looks to be the netbook that can handle some heavy gaming duties. The 1000HV will carry with it the 1.66Ghz Intel Atom N280 processor.
Meanwhile, Version 3.0 of the Eeebuntu Base custom Linux distribution for Asus’ Eee PC netbook line is now available. Eeeubuntu Base Edition 3.0 is based on the recently released Ubuntu 9.04 Jaunty Jackalope, which we recently covered. The new Ubuntu 9.04 kernel is said to already decently support netbooks, but the Eeebuntu uses a further customised kernel that is specially suited for the hardware and hotkeys that are found on the Eee PC. This is great news for those who may want to just have something simple to download and install without needing much tinkering.
what have fireflies got to do with BASIC?
May 22nd
During the last days I’ve been quite excited about a certain idea I want to report about here, and which I think is quite an entertaining project. During one of my web journeys I recently happened to stumble upon this link over at instructables.com and was fascinated: I was looking at a 5×5 LED matrix that initially blinked its LEDs randomly, but somehow “magically” (with the support of 25 light-dependent resistors) synchronized them very slowly, to finally reach a state of absolute synchronicity – and all this with 25 totally independent control circuits, all based on 25 single atTiny13 microprocessors!! The whole thing should be considered as being a model of large swarms of thousands of male fireflies in sout-eastern asia, which are capable of synchronizing their blinking to attract more female fireflies over a greater distance. For more detailed explanations about the background (and how to set up a physical logic model using AtTiny13 chips and C coding) I want to forward you to the instructables link above as well as to this scientific paper explaining the underlying mathematical theory behind this..
And, of course, to a video of “the real McCoy” – real fireflies sitting in a tree, blinking like there would be no tomorrow:
To put it shortly: I decided I wanted something like this hanging on my wall too!
..but since neither the AtTiny nor its “C” language appeal to me, and since further I’m NOT in posession of any ATMEL programmer to accomplish this new goal of mine, I decided that I needed to use something simpler. I instantly thought of the “picaxe” microcontrollers (which are intended for schools originally, sold by a company called “rev-ed.co.uk”, these things are basically a customized “microchip” PIC microcontroller with a bootloader enabling easy direct programming via serial cable, and programmable in a very easy-to-learn BASIC dialect), which would surely allow me to arrive at a nice blinking and syncing LED array in not too much time.
Now while I have not started to assemble any circuit yet, I already have written a small piece of BASIC code which, I think, is quite easy to understand and fun to read – and so I will present it here for the amusement of my dear readers.
here it is:
; *** FIREFLY.BAS ************ Version 1.1 beta ******* SELF-SYNCHRONIZING NETWORK OF LED FIREFLIES ***
; this program is intended for simulation of a swarm of fireflies by many individually controlled LEDs, designed
; to run on a PICaxe08M with a LDR connected to pin 1 and one LED wired to pin 2 (each firefly needs one PICaxe)
; Since they are totally independent besides of sharing the same reset switch, one can easily combine any number of
; fireflies to form a large array of blinking, self-organizing LEDs… pressing the “reset” switch will of course disturb
; the fireflies and their uniform blinking pattern, like walking right into a swarm would disturb real blinking fireflies too,
; probably, and it takes awhile before they start blinking and syncing again…
; ————————————————————————————————————————————————–
; Copyright (c) 22/05/2009
; Dennis Schulze; variables
symbol Power = w4 ;determines how urgently the firefly wants to pulse or how hard it “desires” to do so
symbol Brightness=w3 ;this later contains the reading of the LDR value
symbol Ambient =w2 ;initial ambient light intensity value is stored here for comparison reasons
symbol Counter = b2 ;Counter needed for initialisation blinking loop
symbol RndDelay = b1 ;this will be seeded with a random number for individual delay time; constants
symbol Daylight=195 ; above this light intensity threshold the firefly does not glow at all (i.e. if its not “night”)
symbol MaxPower = 80 ; Urgency threshold that triggers an immediate pulse;counters
let Counter = 1 ;reset all counters
let Power = 1 ;
gosub pulse ; firefly wakes up;randomize a bit to give individuality – “the learning phase” during sunset!
for Counter = 1 to 10 ; read out ten times…read 0, w0 ; …a random value from EEPROM..
readadc10 1, Brightness ; ……and the current LDR value….
w0 = w0 + Brightness ; combine the values giving a seed….
random w0 ;….which is used for seeding RANDOM with some highly individual value
write 0, w0 ; seed stored for next readout cycle, “randomness accumulates”
pause 100
next Counter
let RndDelay = b1 * 24 ; now use last 8bit of the random word w0, multiply with 24 to give max 6 sec delay
let Counter = 1 ; reset counter; initialisation blinking loop
for Counter = 1 to 5 ; blink five times
gosub pulse
pause 700
next Counterpause 500 ; wait a little bit
readadc10 1, Ambient ; then read out ambient light intensity and store value in “Ambient”
pause RndDelay ; pause for an “individual” (hopefully) amount of time before doing anything else
main: do ; main loop
let Power = Power + 1 ; slowly start incrementing the fireflie’s desire to blink..
readadc10 1, Brightness ;…while watching the surrounding fireflies too!if Brightness >= Daylight then ; unless its daytime (fireflies are sleeping during daytime!)…
sleep 3
goto main
endifif Brightness > Ambient then ;……perceiving pulses from other fireflies will
Power = Power + 30 ;..strongly increase our fireflys desire to pulse with them!
endifif Power > MaxPower then ; if the desire is strong enough…
gosub pulse ; …the firefly bursts out a light pulse
let Power = 1 ; what a relief for the firefly! “desire” is reset to initial value
endif ; (equals satisfaction about just having pulsed)loop ; starts building desire for another pulse again (while slowly approximating the other’s frequencies)
;subroutine
pulse:
high 2 ; give a short flash of light
pause 300
low 2
return
Thats all for now, only code and no soldering yet. Thus the code is not functional since not tested, and it still has some flaws (like for example the needed initial randomness in blinking rate is not implemented yet), but rest assured that I will update on this blog as soon as physical results can be presented. I just need to order the needed chips and stuff. In the meantime you can read more about the project over at the picaxe forums where I started a topic about this self-organizing stuff too, and got many great replies concerning ideas for good “true” random number generation and other stuff.


Recent Comments