
Personal project code by Tim Poulsen of Skypanther.
FreeWX is free software developed by Andy Keir that collects, displays, stores and uploads weather data. I use it to upload data from my Oregon Scientific WM-918 weather station to my personal blog, to Weather Underground, and to maintain long-term records of weather data. This page lists my contributions to the weather collective.
Recently, I decided that it would be great to get regular twitter "tweets" updating me to the current weather conditions. My weather station is in my detached garage, monitored by a computer there. I could load my blog page, but frankly I rarely remember.
Finding nothing already built to do this, I wrote my own PHP script to send out weather tweets. It reads the raw data file that FreeWX is already uploading to my web server. It parses that data, pulls out the most important data (or most important to me). Then it sends a tweet. I automated the script with a cron job — my web server runs the script once per hour. I created a separate twitter account for my weather station, though you could probably just use your main account. I "follow" my weather station's twitter account so that I now get an hourly tweet listing the conditions...sweet!
Requirements: PHP version 5 with curl enabled. You might get away with PHP 4, particularly on a Linux box though I couldn't get it to work. If using a URL for line #30 (see below), you'll need fopen wrappers enabled such that URLs are allowed.
17. $config['$twitter_username'] ='TWITTERUSERNAME'; 18. $config['$twitter_psw'] ='TWITTERPASSWORD'; 19. $freewx = file_get_contents('PATH_TO_FREEWXRAW.TXT');Replace the uppercase text with your real values. You can use either a file path (like /var/www/html/freewxraw.txt) or a URL (like http://www.example.com/freewxraw.txt).
02-21, 21:57 - 34°F ( 37°F / 13°F / WC 27°F) - 3.3mph / 67° G 5.2mph - Rain: 1" since MidnightIn order, the fields are: date, time - outside temp, (high temp / low temp / wind chill or heat index) - avg wind speed / avg direction max (gust) wind speed - rain fall since changeover time.
The FreeWX -> twitter tool is offered for free under the GNU GPL license. It uses the twitter.class.php file created by Antonio Lupetti and Scott Sloan, licensed under the Creative Commons license. You're free to use the program, modify it and even redistribute it, but you must do so within the limitations of the GPL.
Discuss it in the forums.
Donations in any amount are gladly accepted!
Announcing FestOS ver 2.3! 2009-12-8
FestOS goes open source! 2009-12-8
Announcing FestOS ver 2.2! 2009-12-8
Announcing FestOS ver 2.1! 2009-10-7