FreeWX related code

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.

FreeWX -> twitter

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.

How-To

  1. Download the program and unzip it. Open freewxtwitter.php in Notepad or some other text editor. You will need to change at minimum three lines:
    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).
  2. Upload the two files to your web server.
  3. Open your browser and open http://www.yourserver.com/freewxtwitter.php to test your work. You should get a tweet like the following:
    02-21, 21:57 - 34°F ( 37°F /  13°F / WC 27°F) -  3.3mph / 67° 
    G 5.2mph - Rain: 1" since Midnight
    
    In 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.
  4. Feel free to customize the other $config variables to modify the output to your liking. Re-upload & test.
  5. Create a cron job or Windows scheduled task to automatically load the page at whatever interval you'd like.

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

Donations in any amount are gladly accepted!

$
(Any amount accepted.)

News


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