WeeWX: How to Import Weather Data from Meteohub

This tutorial describes how to export weather data from a Meteohub device (e.g. Raspberry PI) and import the raw weather data into the weather data logger application WeeWX.

If you have been running your personal weather station using different means of retrival and archiving previously and would like to switch to WeeWX than you probably want to be able to import your data archive into WeeWK at some point. In this tutorial I explain step-by-step how to export your weather data from a Meteohub system, how to properly modify the exported CSV files, and finally how to import the data back into WeeWX.

1. Export weather data from Meteohub

As a first step, log-in to your Meteohub system using a browser. You can get the system’s local IP address by looking it up on your routers network overview.

Next, click on WSWIN Data Export and set up all sensors that you want to export. After you have made your selection make sure to hit “save”, otherwise no data (i.e. empty values) will be exported and you will have to re-select sensors all over again!

Export weather data from Meteohub using the WSWIN Data Export function

Next, select the month for which you want to export the weather data and hit “Generate”. This will then start the generation of the file export.

To find out if the data export has finished, go to “Log Files” and select the meteohub log file. If export is done you should see a message like in the screenshot below:

Find out whether the export is done

Now you will need to log-in to your weather server using an SSH client. For this, I prefer to use MobaXTerm which allows me to easily download files using a regular file tree. However, you can also use any other SSH client like Putty.

In MobaXTerm, add a new SSH session using the credentials shown below. Note that you should replace the local IP address with the IP address that your Meteohub system uses.

Login to your Meteohub server using SSH

Note that the default Meteohub SSH username is “root” and the password should be “meteohub”

Browse to the export folder located under /data/export/ and download the exported file (EXP07_20.csv in my case) to your computer.

2. Modify exported weather data into a suitable format for import

In order for WeeWX to be able to import the old monthly weather data, we need to change a few aspects of the exported CSV file. WeeWX expects only one header line which indicates the variables of the different columns. Here is an example of the original first couple of lines:

Datum,Zeit,Temp. Indoor,Temp. Outdoor,Hum. Indoor,Hum. Outdoor,Pressure,Rain,Wind,Wind Direction,Solar,Wind Gust
,,°C,°C,%,%,hPa,l/qm,km/h,°,W/qm,km/h
#Calibrate=1.000 #Regen0=0mm #Location=429/429m #Baro_correction=0hPa #Station=meteohub
,,1,2,17,18,33,34,35,36,42,45,133
01.07.2020,00:00,36.6,16.8,30.0,81.2,963.8,0.00,0.0,331,0.0,0.0,1014.3
01.07.2020,00:01,36.6,16.8,30.0,82.0,963.8,0.00,0.0,331,0.0,0.0,1014.3
01.07.2020,00:02,36.6,16.8,30.0,82.0,963.8,0.00,0.0,331,0.0,0.0,1014.3

You are free to specify any names for the description of the columns, as long as you know what is what. Furthermore, WeeWX expects the date and time in the same column. However, as can be seen from above, Meteohub exported them in two separate columns. To fix this, use a text editor like the fantastic Notepad++ to search for the string “2020,” and replace all occurrences with “2020 ” or whatever year you are about to import. Since this is not the default date/time format, you will need to specify the date format used in the import configuration file (raw_datetime_format setting). Here is an example of the first couple of lines of my modified, and ready for import, CSV file:

DatumZeit,TIn,TOut,HumIn,HumOut,Pressure,Rain,Wind,WDir,Solar,WGust,SLP
01.07.2020 00:00,36.6,16.8,30.0,81.2,963.8,0.00,0.0,331,0.0,0.0,1014.3
01.07.2020 00:01,36.6,16.8,30.0,82.0,963.8,0.00,0.0,331,0.0,0.0,1014.3
01.07.2020 00:02,36.6,16.8,30.0,82.0,963.8,0.00,0.0,331,0.0,0.0,1014.3

3. Setup the WeeWX import configuration file

WeeWX can only import your files if it gets a few information regarding the structure and content of the imported file. You can copy example import files to your home directory:

cp /etc/weewx/import/csv-example.conf /home/roman/csv-import-meteohub.conf

WARNING: The default example file contains an error where the delimiter is not escaped! This will lead to an error when attempting to import.

Update the file path and make sure to add quotes around the comma like this:

[CSV]
    # Parameters used when importing from a CSV file

    # Path and name of our CSV source file. Format is:
    #   file = full path and filename
    file = /home/roman/import/EXP07_20.csv

    # The character used to separate fields. Format is:
    #   delimiter = <single character>
    # Default is , (comma).
    delimiter = ','

Also make sure to correctly specify if you have an UV or solar sensor in the configuration file and finally update the Field Map section which links the columns in the imported CSV file to the respective variables in WeeWX. You must also specify the units supplied in the CSV file for WeeWX to properly archive the data.

 [[FieldMap]]
        dateTime    = DatumZeit, unix_epoch
        barometer   = SLP, hPa
        pressure    = Pressure, hPa
        inTemp      = TIn, degree_C
        outTemp     = TOut, degree_C
        inHumidity  = HumIn, percent
        outHumidity = HumOut, percent
        windSpeed   = Wind, km_per_hour
        windDir     = WDir, degree_compass
        windGust    = WGust, km_per_hour
        rain        = Rain, mm
        radiation   = Solar, watt_per_meter_squared

You can download my working configuration file here.

4. Import data into WeeWX

Before you proceed importing your files, make sure to stop WeeWX:

sudo /etc/init.d/weewx stop

Then run a dry run of the import action:

sudo wee_import --import-config=/home/roman/csv-import-meteohub.conf --dry-run
Using WeeWX configuration file /etc/weewx/weewx.conf
Starting wee_import...
A CSV import from source file '/home/roman/import/EXP07_20.csv' has been requested.
Using database binding 'wx_binding', which is bound to database 'weewx.sdb'
Destination table 'archive' unit system is '0x01' (US).
Missing derived observations will be calculated.
All WeeWX UV fields will be set to None.
This is a dry run, imported data will not be saved to archive.
Starting dry run import ...
19865 records identified for import.
Unique records processed: 19865; Last timestamp: 2020-07-14 19:04:00 UTC (1594753440)
Finished dry run import
19865 records were processed and 19865 unique records would have been imported

If no errors are reported and everything looks OK, import the data:

sudo wee_import --import-config=/home/roman/csv-import-meteohub.conf --verbose
Using WeeWX configuration file /etc/weewx/weewx.conf
Starting wee_import...
A CSV import from source file '/home/roman/import/EXP07_20.csv' has been requested.
The following options will be used:
     config=/etc/weewx/weewx.conf, import-config=/home/roman/csv-import-meteohub.conf
     source=/home/roman/import/EXP07_20.csv, from=None, to=None
     dry-run=None, calc_missing=True, ignore_invalid_data=True
     tranche=250, interval=derive, date/time_string_format=%d.%m.%Y %H:%M
     delimiter=',', rain=discrete, wind_direction=[0.0, 360.0]
     UV=False, radiation=True
Using database binding 'wx_binding', which is bound to database 'weewx.sdb'
Destination table 'archive' unit system is '0x01' (US).
Missing derived observations will be calculated.
All WeeWX UV fields will be set to None.
Starting import ...
Obtaining raw import data for period 1 ...
The following imported field-to-WeeWX field map will be used:
     source field 'DatumZeit' in units 'unix_epoch' --> WeeWX field 'dateTime'
     source field 'SLP' in units 'hPa' --> WeeWX field 'barometer'
     source field 'Pressure' in units 'hPa' --> WeeWX field 'pressure'
     source field 'TIn' in units 'degree_C' --> WeeWX field 'inTemp'
     source field 'TOut' in units 'degree_C' --> WeeWX field 'outTemp'
     source field 'HumIn' in units 'percent' --> WeeWX field 'inHumidity'
     source field 'HumOut' in units 'percent' --> WeeWX field 'outHumidity'
     source field 'Wind' in units 'km_per_hour' --> WeeWX field 'windSpeed'
     source field 'WDir' in units 'degree_compass' --> WeeWX field 'windDir'
     source field 'WGust' in units 'km_per_hour' --> WeeWX field 'windGust'
     source field 'Rain' in units 'mm' --> WeeWX field 'rain'
     source field 'Solar' in units 'watt_per_meter_squared' --> WeeWX field 'radiation'
Raw import data read successfully for period 1.
Mapping raw import data for period 1 ...
Mapped 19865 records.
Raw import data mapped successfully for period 1.
Saving mapped data to archive for period 1 ...
19865 records identified for import.
Proceeding will save all imported records in the WeeWX archive.
Are you sure you want to proceed (y/n)? y
Unique records processed: 19865; Last timestamp: 2020-07-14 19:04:00 UTC (1594753440)
Mapped data saved to archive successfully for period 1.
Calculating missing derived observations ...
Processing record: 19865; Last record: 2020-07-15 00:00:00 UTC (1594771200)
Recalculating daily summaries...
Records processed: 21000; Last date: 2020-07-14 14:00:00 UTC (1594735200)
Finished recalculating daily summaries
Finished calculating missing derived observations
Finished import
19865 records were processed and 19865 unique records imported in 9.88 seconds.
Those records with a timestamp already in the archive will not have been
imported. Confirm successful import in the WeeWX log file.

And that is it!

After repeating this procedure for each month in your weather station’s archive you should be good to go with WeeWX.

Leave a Comment