Windy Community
    • Unread
    • Categories
    • Groups
    • Go to windy.com
    • Register
    • Login

    Php script to upload WeatherFlow Tempest data

    Scheduled Pinned Locked Moved Windy Stations
    3 Posts 2 Posters 1.3k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      simcom | Premium
      last edited by

      Hi,

      I am using the following php script to grab data from my WeatherFlow Tempest station and then successfully upload them to Windy.com.
      A cron job is used to run it every 5 minutes.
      No additional weather software is needed.

      Enjoy,
      Kostas

      /*
       * This php script grabs data from a WeatherFlow Tempest station and 
       * uploads them to Windy.com.
       * Use a cron job to run it every 5 minutes.
       * No additional weather software is needed.
       */
      
      // Download data from WeatherFlow Tempest station (use your own Token)
      $url = 'https://swd.weatherflow.com/swd/rest/observations/station/111120?token=XXXXXXXXXXXX';
      
      $curl = curl_init();
      curl_setopt($curl, CURLOPT_URL, $url);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl, CURLOPT_HEADER, false);
      $data = curl_exec($curl);
      curl_close($curl);
      
      // Decode data so they can be used
      $data = json_decode($data);
      
      // Calculate variables
      $ts = urlencode($data->obs[0]->timestamp);
      $temp = urlencode($data->obs[0]->air_temperature);
      $wind = urlencode($data->obs[0]->wind_avg);
      $winddir = urlencode($data->obs[0]->wind_direction);
      $gust = urlencode($data->obs[0]->wind_gust);
      $rh = urlencode($data->obs[0]->relative_humidity);
      $dewpoint =  urlencode($data->obs[0]->dew_point);
      $mbar = urlencode($data->obs[0]->barometric_pressure);
      $precip = urlencode($data->obs[0]->precip);
      $uv = urlencode($data->obs[0]->uv);
      
      
      // Upload data to Windy.com (use your own Windy API-KEY)
      $url3 = "https://stations.windy.com/pws/update/API-KEY?winddir=$winddir&wind=$wind&gust=$gust&temp=$temp&precip=$precip&mbar=$mbar&dewpoint=$dewpoint&rh=$rh&uv=$uv";
      
      //var_dump($url3);   //test only
      
      $curl3 = curl_init();
      curl_setopt($curl3, CURLOPT_URL, $url3);
      curl_setopt($curl3, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl3, CURLOPT_HEADER, false);
      $data3 = curl_exec($curl3);
      curl_close($curl3);
      
      //var_dump($data3);   //test only
      
      
      1 Reply Last reply Reply Quote 0
      • S Offline
        simcom | Premium
        last edited by

        Sorry but there is a mistake at the beginning of the script:

        // Download data from WeatherFlow Tempest station (use your own Token)
        $url = 'https://swd.weatherflow.com/swd/rest/observations/station/111120?token=XXXXXXXXXXXX';
        

        Instead of [111120], you should use [your own station id]. This [111120] is just my own station id.

        Cheers,
        Kostas

        1 Reply Last reply Reply Quote 0
        • M Offline
          marinatin | Premium
          last edited by marinatin

          Is this still working? Have many people deployed with success? @simcom would you be willing to help me deploy this remotely for a small lake resort? I'm not the technical.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Windy Community  |  Powered by excellent NodeBB
          Terms of Use     Privacy Policy     Windy.com