Smart Rainsensor for the IBM Wunderground API

I missed the app VirtualRainSensor (no longer working for the new wunderground API). So I built my own solution based on the Sitesensor App and on a PHP script “raincalc.php” running on my webserver.

The logic is very similar to VirtualRainsensor - comparing rain and evaporation needs for some days in the past and some days in the future (period is selectable). The evapotranspiration calculation bases on temperature, humidity, windspeed etc… My own weather station is connected to wunderground. From there I get the historical data and the forecasts.

The raincalc.php script runs on my webserver and is periodically called by the Sitesensor App. Sitesensor triggers the rain switch of my irrigation system. This script handles the large JSON response from Wunderground (I got problems to do this with LUA). This script needs only a hand full parameter changes (StationID, ApiKey,…) and it should run on most webservers. In the SiteServer app the request URL has to be adapted. Then the Smart Rainsensor should also run for other weather stations. (6.2 KB)

The response of raincalc.php condenses the results into 8 variables in JSON format. They are shown in the control tab of Sitesensor.

  • field1: state of the rainsensor
    If the total need of irrigation in the day period under consideration is negative, then you get the state “StopWater”. (You can also get “StopWater” after some dry days - or you can also get “RunWater” while it is raining!)
  • field 5: days of the period under consideration. Generic,
    in this case are the days |-4|-3|-2|yesterday|today|tomorrow|+2| selected. This field serves as column heading for the fields 6 to 8.
  • field 2: Total sum of rain in the day period under consideration (mm)
  • field 6: Daily sums of rain in mm (days see field 5)
  • field 3: Total sum of evapotranspiration in the day period under consideration (mm)
  • field 7: Daily sums of evapotranspiration in mm (days see field 5)
  • field 4: Total need of watering in the day period under consideration (in mm = evapotranspiration minus rain)
  • field 8: Daily need of watering in mm (days see field 5)

Below you see the appropriate configuration of SiteSensor:

More detailed information (unfortunately in german) do you find here
overview over the components
outline of the procedures and configuration

1 Like