How to Obtain Weather Data Using ACE

Discussion created by jkotwal on Mar 19, 2009
Latest reply on May 2, 2009 by jkotwal


Many customers need or want to get external weather data. Websites like Yahoo, Weather.gov, and Wunderground.com provide XML RSS feeds with weather conditions. How do we get this data into PI?


We can use ACE to load the XML files from the internet and output the data to PI.

  1. Find a provider for the weather information you require. The example below uses Yahoo weather. The address is http://weather.yahooapis.com/forecastrss?p=94577, where 94577 is the zip code for the desired location.
  2. Create the tags in PI for the weather data that you would like to capture. In the example below temperature, pressure, humidity, wind direction and windspeed are being recorded.
  3. Open Visual Studio. Go to Tools > PIACEWizard > New... Create a new ACE module and executable. Add the weather tags as output tags.
  4. Add code to parse through the XML file and extract the required data. See the code below for an example.
  5. Test and register the module.

Visual Basic Code:

PublicOverridesSub ACECalculations()
' Retrieve XML document
Dim reader As XmlTextReader = New XmlTextReader("<http://weather.yahooapis.com/forecastrss?p=94577>")
' Skip non-significant whitespace
reader.WhitespaceHandling = WhitespaceHandling.None
' Read nodes one at a time
While reader.Read()
    If reader.Name = "yweather:condition" Then      'current conditions
        SL_Temp.Value = reader.GetAttribute("temp") 'get temperature
    ElseIf reader.Name = "yweather:wind" Then       'wind information
        SL_WindDirection.Value = reader.GetAttribute("direction") 'get wind direction
        SL_Windspeed.Value = reader.GetAttribute("speed")  'get wind speed
    ElseIf reader.Name = "yweather:atmosphere" Then 'atmospheric information
        SL_Humidity.Value = reader.GetAttribute("humidity") 'get humidity
        SL_Pressure.Value = reader.GetAttribute("pressure") 'get pressure
This method can be used to pull any xml formatted data off the web. The XML and HTML interfaces can do the same thing, but this is pretty convenient if you already have ACE.