CustomCGI

From WeatherCat Wiki (Mahler)
Revision as of 10:06, 28 April 2018 by Admin (Talk | contribs)

Jump to: navigation, search

Custom CGI

The Custom CGI feature allows you to transmit real-time weather data to a server on the Internet in an efficient fashion.

Two simple php scripts are supplied by way of example (found in the ‘Server Scripts’ folder of the WeatherCat distribution). The first takes the data from WeatherCat and saves the data as a text file on your server. The second displays the data in a web page.

To set up WeatherCat for Custom CGI follow these steps.

1. In the WeatherCat miscellaneous files (available to download from the WeatherCat page open the ServerScripts folder found at the top level and upload the following two scripts and text file to your server:
a). submit_weather.php
b). watch_weather.php
c). weather_data.txt
(You may need to set the permissions of the files as appropriate for your server.)
The submit_weather script is the script WeatherCat sends the current weather data to. The watch_weather script is loaded in your browser to see the current weather data. The weather_data.txt file is where the submit_weather script stores the data.

CustomCGI.png

2. Enter the URL to the submit_weather.php script into the URL in the CustomCGI preferences - enter it exactly as above, just change the URL to your script. You'll probably only have to modify the www.yourserver.com part of the URL. The script by default expects the user name to be joeblog and the password to be xxxxxx.
3. Hit the start button.
4. In your web browser open http://www.yourserver.com/watch_weather.php
If all has gone well, you should see live weather from your weather station. If not, check the URL's and the location of the scripts on your server. Check if your hosting provider allows you to run scripts; also check where you should put them.
5. IMPORTANT: When everything is running correctly, edit the submit_weather script to change the user name and passwords!


Notes:

1. Please feel free to modify the scripts to suit your needs. The submit_weather script can be modified to save the data in any format you require - for example some flash based gauges need XML formatted data.
2. You may have other scripts you want to drive - you can write CGI's in whatever language you prefer - we have used PHP here as a simple example.
3. Any CGI you write must take the data as formatted by WeatherCat - you cannot change the format of the data WeatherCat sends.
4. The data WeatherCat is sending is displayed live in the Custom CGI preferences tab as it is transmitted.
5. We may add further data items to the request in the future, so your CGI should be able to handle new parameters - even if it’s just to ignore them until you can update the CGI.
6. If a data item is not available (because, for example that particular sensor is unserviceable) it may not be sent - your script needs to deal with this.


Please see the WeatherCat web templates forum for further discussion of this feature.

Personal tools
Namespaces

Variants
Actions
Navigation
Tools