MeteoStation is a software tool for reading data from Thies Clima meteorological stations and storing that data.
This software is designed to work with Thies Clima's Clima Sensor US, part number `4.920x.x0.00x`.
View Demo
Table of Contents
- Python >= 3.9.0
Set Up the Virtual Environment and Install the meteostation package and its dependencies.
python3 -m venv .venv
source .venv/bin/activatepython -m venv .venv
.venv\Scripts\activateAfter activating the virtual environment, install the meteostation package:
pip install -e .Note: This library depends on
mysqlclientpython library. If any error ocurred during the installation of said library in Linux, please refer to its installation instructions
Run meteostation's setup subcommand to generate the needed configuration and ancillary files to run command in the library.
python -m meteostation setupAfter that, the file config.yml will be created in the working directory.
Many parameters and options can be configured through this configuration file.
Once installed, you can run the meteostation subcommands after invoking the module.
For example, to run the read_print subcommand:
python3 -m meteostation read_printTo see all the available options please run:
python3 -m meteostation -hAnd to see the help for each specific command run add the -h flag after the subcommand.
For example, to get the help for the send_command subcommand:
python3 -m meteostation send_command -h- mySQL or a compatible DB manager like mariaDB
After creating the user username with the valid permissions for the meteostation database, run:
mysql -u username <db/meteostation.sql -p
mysql -u username <db/add_synops.sql -pIf not yet done, run the setup subcommand to create the configuration file:
python -m meteostation setupNow, you must modify the following config.yml values:
instrument.port: Serial port name at which the instrument is connected to.storage.csv_dir: Directory where the downloaded entries from the instrument will be stored as CSV files.database:username: Username to connect to the database.password: Username's password to connect to the databasehost: URL where the MySQL-like database is hosted at.station: Name of the station to identify it. Must be different from the other stations.
Run the subcommand read_store to check that the system can successfully read data from the station:
python -m meteostation read_storeIn order to run the read and store task for a fixed frequency, run the runner.py script.
This launches a process that runs the task every 60 seconds using python time.sleep function
to wait each period.
This is usually more precise than Window's task scheduler, in case better precision is required.
To run the script automatically at regular intervals, use crontab.
- Open the crontab editor:
crontab -e
- Add a new job to run the script every 5 minutes (adjust as needed):
*/5 * * * * /path/to/your/repository/.venv/bin/python3 -m meteostation read_store
Replace /path/to/your/repository with the actual directory where your project is located.
On Windows, you can use Task Scheduler to automate the execution.
- Open Task Scheduler (Press
Win + R, typetaskschd.msc, and hit Enter). - Click Create Task in the right panel.
- Modify values under the General tab:
- Name:
MeteoStation Data Download - Security options:
- Select "Run whether user is logged on or not".
- Check "Do not store password. The task will only have access to local computer resources."
- Name:
- Create a trigger under the Triggers tab:
- Click New... and configure:
- Begin the task: On a schedule
- Settings: One time
- Start: Set the seconds to
:00to align with minute boundaries. - Advanced settings:
- Check "Repeat task every:" and set the frequency (e.g., 1 minute).
- Set "for a duration of:" to Indefinitely.
- Click New... and configure:
- Create an action under the Actions tab:
- Click New... and configure:
- Action: Start a program
- Program/script:
C:\path\to\your\repository\.venv\Scripts\pythonw.exe - Add arguments:
-m meteostation read_store - Start in:
C:\path\to\your\repository\
- Click New... and configure:
- Modify settings under the Conditions tab:
- Power:
- Uncheck "Start the task only if the computer is on AC power."
- Check "Wake the computer to run this task."
- Power:
- Click OK to save the task. If prompted, enter your credentials to finalize the setup.
First, run the subcommand send_last_data to check that the connection with the database works correctly:
python -m meteostation send_last_data 1After that, automate the process using Crontab or Windows Task Manager.
You can set it up to send last 30 minutes of data every 15 minutes. The command for sending the latest 30 minutes of data would be:
python -m meteostation send_last_data 0.5This tool allows users to generate visual representations of the weather data stored in the database.
To enable plotting, you must define the output paths in your configuration file under the plot section. The following paths are available:
temp_humidity_path: Generates a graph showing temperature, humidity, dew point, and wind chill.winds_path: Generates a graph displaying wind speed, gusts, and direction.precipitation_path: Plots half-hourly and daily precipitation along with atmospheric pressure.csv_path: Path to a CSV file containing the data used in the most recent plot.json_path: Path to a JSON file containing the latest entry's data.
-
plots_db_last:python -m meteostation plots_db_last [last_hours]
Generates plots using only data entries newer than
last_hoursago. -
plots_db_interval:python -m meteostation plots_db_interval [first_date] [last_date]
Generates plots based on data retrieved from a specified time interval.
The software currently supports data sharing with five networks:
Windy, Wunderground, PWSweather, Weathercloud, and Meteoclimatic.
python -m meteostation share_windy [last_minutes]Fetches weather data from the database covering the past last_minutes up to the current time, and sends it to Windy using the API key and station ID defined in the configuration.
- Data is sent using Windy's
POSTmethod. - Windy only accepts near-real-time data, specifically within 60 minutes of the current time.
- The recommended update frequency is every 5 minutes.
python -m meteostation share_wunderground [last_minutes]Fetches weather data from the database from last_minutes ago until now, and sends it to Wunderground using the API key and station ID specified in the config.
- The recommended update frequency is every 10 minutes.
python -m meteostation share_pwsweather [last_minutes]Retrieves weather data from the past last_minutes and sends it to PWSweather using the API credentials defined in the configuration.
- Data can be sent retroactively as long as timestamps are accurate.
- Recommended interval: 5–10 minutes.
python -m meteostation share_weathercloudThis command must be run on the same machine where data is being collected from the weather station.
- It reads the most recent local record.
- If that entry is less than 90 seconds old, it is sent to Weathercloud using your configured credentials.
- Free-tier Weathercloud accounts can only send data once every 10 minutes. Sending more frequently may result in a temporary block.
- Only one data point is sent per execution. Batch sending is not supported.
python -m meteostation share_local_meteoclimaticThis command must be run on the same machine where data is being collected from the weather station.
- Reads the most recent local record.
- If the entry is less than 90 seconds old, it is sent to Meteoclimatic using the configured credentials.
- Meteoclimatic ignores the
dateutcfield in the Wunderground-style payload. It assigns the timestamp of reception as the official measurement time. - Data is sent using the Wunderground protocol, which is accepted by Meteoclimatic's
EWUadapter. - Important: Meteoclimatic requires updates at least every 60 seconds when using this method. This script does not control the timing, one must schedule it appropriately using
cron,systemd, or equivalent.
This project is licensed under the GNU General Public License v3.0 or later (GPLv3+).
See the LICENSE file for details.
- Javier Gatón Herguedas - gaton@goa.uva.es.
- José Luis Martín Marcos - jose@goa.uva.es.