Raspberry Pi as a Northern light forcast device - PiAurora
Aurora is a beautiful natural light display in the sky particularly in the high latitudes.It is caused by the collision of energetic charged particles with atoms in the high altitude atmosphere. The prediction of viewing aurora is based on Geomagnetic Activity-The Kp Index (you can read more here )
You can check the geo magnetic latitude and the minimum Kp value needed by clicking here (NOAA).
Current extent and position of the auroral oval can be viewed below
Here is a simple Northern light (Aurora Borealis) warning (alert - if i miss it i feel bad so i wrote warning :)) device based on a Raspberry Pi. Basically it connects to noaa.org to get the Kp values and if the predicted value goes above a set limit, it powers on an led connected to the GPIO pin of the Raspberry Pi. To make it simple only one led is used with a green color ( i used one of the channel in an RGB module).
To give some visual effects 'like' the Aurora, a pulse width modulation is used with varying intensities. This is achieved by using the servoblaster project, which provides an efficient (DMA based) way to produce PWM with minimal cpu usage. I just placed a waterbottle in front of the led to get a nice visual effect!
The forcast on Pi works by a pythonscript which check the current kp value with the threshhold value and triggers the lights
See it in action below
Partial code which parse the kp value from noaa is given below. Linked it with servoblaster and used a cronjob to check the kp values every 30minutes/1hr. If you have any trouble in completing the stuff, post it as a comment. Until then the rest of the code is kept as an exercise to keep the interest on coding with pi and python :-)
#!/usr/bin/env python import sys import urllib import re import io from StringIO import StringIO def getLine(data, line_no): buffer = StringIO(data) for i in range(line_no - 1): try: next(buffer) except StopIteration: return '' #Reached EOF try: return next(buffer) except StopIteration: return '' #Reached EOF url = 'http://www.swpc.noaa.gov/wingkp/wingkp_list.txt' u = urllib.urlopen(url) txt = u.read() u.close() temp = StringIO(txt) count_lines = len(temp.readlines()) lineE = getLine(txt,count_lines-1) lineE.split() elements=re.findall("[-+]?\d*\.\d+|\d+", lineE) kp=elements[len( elements)-1] print kp