3/16/2011 EDIT: The Wing Kp Predicted Geomagnetic Activity Index model is now deployed and operational. Costello is now considered non-operational and will be discontinued on 23 Mar 2011. Comments and questions are welcomed at SWPC.CustomerSupport@noaa.gov
The Wing Kp Predicted Geomagnetic Activity Index model is known to perform well for large geomagnetic storms and includes both a 1 hour and a 4 hour advance prediction of activity. Wing Kp 7-day model output is available in ascii data list format at http://www.swpc.noaa.gov/wingkp/wingkp_list.txt and via Anonymous FTP at ftp://ftp.swpc.noaa.gov/pub/lists/wingkp
Build a visual indicator of the Northern Lights using the Arduino. Know when to go outside and look up, no matter where you live!
For years I have struggled to find a good way of alerting me to Northern Lights activity. I have tried email alerts and real-time monitoring software. Nothing worked well and I would regularly miss good displays.
Enter the Costello Geomagnetic Activity Index. Simply put, this is a prediction of auroral activity. It is pretty reliable and gives about an hour's notice of northern lights activity. The problem is, of course, you have to keep checking the web page to catch any jump in the Index.
What we will build is a visual representation (an LED display) of the current level of auroral activity. The build consists of three main parts: a PHP Web scraping script, a Processing script, and an Arduino script. The LED lights green for low activity, blue for moderate, red for high activity and white for GET OUTSIDE NOW! I have mounted this in an old clock face so it is always visible in my living room. Essentially this is a poor man's Ambient Orb costing under $40 to build compared to the Ambient Orb's $150 + S/H + $6.95/mo for custom monitoring.
Right off the bat I wish to thank Tod E. Kurt for his Spooky Arduino projects and his help getting me through my own stupidity. It is his scripts this project is based on and I strongly recommend checking out his blog for great Arduino projects.
Step 1: The PHP script
This is my first project using the Arduino outside of the usual "hello world" scripts. I've had to learn the Arduino software, the Processing software, Apache configuration and a bit of PHP to pull this off. There are most likely more elegant ways of doing this, but it works.The first of the scripts is the PHP Web scraper. The Costello Index is calculated and fed to a FTP server text file(there is http output as well, but the FTP info is more recent.) We need to pull only the most recent Predicted Index from the text file. The PHP script parses out the needed information, converts the Index number into a hexadecimal representation of color in the form #RRGGBB and then writes that to a text file to your server.
Parsing PHP.zip579 bytes
Step 2: Set up the server - the easy way
Unless you have a web host with PHP enabled, follow this awesome Instructable to set up an Apache server in just a few minutes.
How to install a web development environment on localhost
I tried several free web hosting sites that were supposed to be PHP enabled. I never did find one that fit my needs and most were just exercises in frustration. This Instructables showed me how to install Apache, MySQL, and PHP in just a few minutes. This turned out to be far easier than I had expected.
Place your PHP script in the appropriate folder. You will need to forward the appropriate ports if you use a router. If you have a dynamic IP address check out DynDNS to easily keep your server reachable.
Step 3: Processing
Processing language bridges the gap between the Web and the Arduino. This script must be modified to match your setup.Processing first calls the web scraping PHP script which then updates the hex color text file. Processing grabs the text file and spits the color value to the serial port where the Arduino is listening. This is repeated every 15 minutes.First, after plugging in your Arduino, find out which port your system assigned to it. In Windows, this is found in Control Panel/ System/ Hardware/ Device Manager/ Ports. Mine was COM13. Change the portstr command on line 7 of the Processing script to match that port. Next, Set the urlstr variable in the 9th line to the URL of the text file output by the PHP script. Then set the urlstr2 variable in the following line to the URL of your PHP script.
Processing Script.zip47 KB
Step 4: Arduino script
The Arduino is the hardware heart of the project. The Arduino script is the unmodified serial_rgb_led_too script from Tod Kurt's Spooky Arduino. The script is loaded on the Arduino and needs no further attention. Wire up your LEDs to pins 9,10, and 11 of the Arduino and the Ground pin using resistors appropriate for your LEDs. I recommend breadboarding first to make sure you have everything going to the correct pins and resistor values are correct. I used a single RGB LED from SparkFun.Check your wiring by starting the Arduino software and opening the serial monitor. Enter #FF0000 and Red should light up, #00FF00 and green should become active, #0000FF and Blue lights. You can now set your PHP script to mix these colors in any way desired.
Step 5: Putting it all together and suggested modifications
Once everything is set in place you will simply need to plug the Arduino into a USB port and start the Processing script. Updates are handled every 15 minutes automatically.I used the Arduino Diecimila because I'm just getting started. If you are going to build this I would recommend an Arduino varient such as the Adafruit USB Boarduino. This will save you some cash over the standard Arduino board. Adding more monitors - The Arduino has plenty more I/O pins available. Have it ring a bell or show you the weather(.pdf warning).Tweak it for your latitude! Adjust the set point triggers in the PHP script. At my latitude, ~47 degrees North, I can see the Northern Lights if the Kp index is over 5 and it is a dark night. If you live further South you should adjust the triggers to higher numbers.Make it wireless! Hack a Fonera router and hook it to the Arduino. All you would need then is power.
Step 6: A final thank you and a moment of silence
Thank you, again, to Tod Kurt for his help during a late night brain blockage.Thank you, also, to my friend belteshazzar for being a fellow geek and for his words of encouragement.And, finally, a moment of silence for Mark Haun's Aurora Alarm project. I miss the email alerts.