Community Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Local Weather Browser

First Round:

Summary:

      I had discovered a website a few years ago called Weather Underground www.wunderground.com.  It provides data for hundreds to thousands of personal weather stations with data updated every 5-10 minutes.  I had used an interface in Excel to extract the data for a project.  I figured this would be a good exercise to see if I can do the same thing in LabVIEW.

     I wanted to be able to plot all of the weather data such as temperture, dew point, humidity, rainfall, and some other parameters.  I wanted to give the user a means to use a web browser to search the website to discover the ID code of any weather station site they might be interested in.  Also, they can select the current or a historical date.

     As a result of this exercise, I was able to gain some experience using ActiveX event callbacks (I had only ever used them in a NI LabVIEW training class) and also experimented with some Regex codes (which I usually avoid because it looks like a secret language.)

Function:

      To be able to graph weather data for a desired date from a personal weather station of the user's choosing.

Steps to execute code:

  1. Download the .zip file and unzip to a directory on your hard drive.
  2. Run the main VI called Weather.VI
  3. Press the Find Station button.
  4. Another window pops up that behaves like a web browser.  Go to the PWS Network section to the lower right.  Choose your state or country, then hit View.
  5. When the next page loads, look for your weather site of interest.  Click the hyperlink to that site.
  6. When you have found a valid site, a Site ID appears at the top and the boolean glows green.  Hit the Close button.
  7. The Site ID is now present in the main VI.  Select a new date if desired.  (It defaults to the current date).
  8. Hit the Get Data button to retrieve the data from the website.  It will be graphed to the right.
  9. Drag the cursor on the temperature graph around.  All the weather data pertaining to the location of the cursor will be show to the far right.  Wind direction is also shown on a gauge indicator.
  10. Pick a new site then Get Data if desired.  Or pick a new date then Get Data if desired.
  11. When done, hit Stop.  Your last weather site will be saved to a configuration file to be loaded as the default the next time you run the program

Second Round:

Summary:

      The requirement for the second round is to add a communication mechanism between independently running VI's.  I decided to use the classic TCP/IP server client architecture.  I started with the Named Service TCP Client and Named Service TCP Server example VI's that are packaged with LabVIEW and can be found through the Help / Find Examples menu.  I had actually never looked at these specific examples before, and I discovered the named service feature which I think would have numerous advantages over using port numbers as shown in the regular Data Client and Server examples.  With those, you have to determine a port number to establish as the communication link.  While there are lists of available numbers, there is no guarantee that a particular number may not already be in use by some other program.  While there are mechanisms to detect such problems and work around them, it still seems like a large programming hassle to discover an unused port and somehow publish it so that the client program can find it and connect to it.  With the named service, you can ignore the port number and come up with a name that should be unique enough that it is very unlikely that any other program would be using it and causing a conflict.

     I decided to create a VI that acts as a storage database of the collected weather data.  A TCP client was added as a consumer loop to my previous VI (Weather.vi) from Round 1 of the contest.  This VI will send the data to the new server VI called Weather - Database.vi.  A command instruction and other data that is packaged as a variant are flattened to a string for transport through the TCP functions.  The new VI stores the flattened data in a Configuration .ini file.  I am using this as an easy to implement database type of file.  It stores data in sections (each section represents a specific weather station) and as keys within that section (each key represents a specific date).  This made it fairly easy to store the data within a file where I can later retrieve it based on station and date and let LabVIEW handle all of that work behind the scenes.  A true database implementation would be better if the datafile grew too large, but for the time being, this serves my purpose.  Also, if the data is updated later on, it will automatically overwrite the previous data.  The new database VI was actually derived from the previous VI since it already had the front panel event handling loop.

     For the purpose of this exercise, I hardcoded the IP address so that it loops back to the local host (127.0.01).  Thus both VI's must run on the same PC.  But one of the nice advantages of TCP/IP communication is that it is not necessary.  By using the IP address or machine name of another PC, the server VI could be running on a different PC.

Function:

     To be able to graph weather data for a desired date from a personal weather station of the user's choosing.

     To be able to store the data collected from the web in a file format.  That data can be later retrieved and viewed offline.

Steps to execute code:

  1. Download the .zip file and unzip to a directory on your hard drive.
  2. Run the main VI called Weather.VI
  3. Press the Find Station button.
  4. Another window pops up that behaves like a web browser.  Go to the PWS Network section to the lower right.  Choose your state or country, then hit View.
  5. When the next page loads, look for your weather site of interest.  Click the hyperlink to that site.
  6. When you have found a valid site, a Site ID appears at the top and the boolean glows green.  Hit the Close button.
  7. The Site ID is now present in the main VI.  Select a new date if desired.  (It defaults to the current date).
  8. Hit the Get Data button to retrieve the data from the website.  It will be graphed to the right.
  9. Drag the cursor on the temperature graph around.  All the weather data pertaining to the location of the cursor will be show to the far right.  Wind direction is also shown on a gauge indicator.
  10. Pick a new site then Get Data if desired.  Or pick a new date then Get Data if desired.
  11. Hit the Store Data button to send the data to the Weather - Database.vi.  If this is not already running, it should start automatically.
  12. If you want to stop the Weather - Database.vi from the current front panel, click the stop server button.
  13. When done, hit Stop.  Your last weather site will be saved to a configuration file to be loaded as the default the next time you run the program

  1. Weather - Database.vi is the independent VI that acts as a server for storing data.  It can be run by itself to retrieve data from its storage file and view on its front panel.  (Its front panel is very similar to Weather.vi)
  2. Run the server VI called Weather.vi
  3. Press Retrieve Data to load the data from the configuration file.
  4. Pick the desired weather station from the listbox.  It only shows stations for which you have previously asked to store the data.
  5. Pick the desired date from the listbox.  It only shows the dates for which you have previously asked to store the data for that station.
  6. The weather data that was stored to the file will be displayed on the graphs and indicators.

Screenshots:

Round 1:

Main Front Panel:

Weather_FP.png

Browser Front Panel:

browser_FP.png

Round 2:

Main Front Panel:

Weather_FP.png

Server Database Front Panel:

Weather - Database_FP.png

VI Snippet:

Main Block Diagram:

Weather_BD.png

Browser Block Diagram:

browser_BD.png

Round2:

Main Block Diagram:

Weather_BD.png

Server Database Front Panel:

Weather - Database_BD.png

VI's attached below

Weather.zip        Round 1 VI's (Saved as LV 8.6)

Weather2.zip      Round 2 VI's (Saved as LV8.6)

Download All
Contributors