Connecter la station meteo Ws2300 sous Linux
De MicElectroLinGenMet.
Sommaire |
Description
Voir la page Station meteo. Lacross Technology WS2300 pour une description des possibilité de cette station.
Mise à part le prix, le choix de la station météo Ws2300 s'est fait en fonction de la possibilité de la relier à un PC mais aussi à un PC fonctionnant sous Linux.
Le logiciel libre qui permet de piloyer cette station se nomme Open2300.
Installation d'Open2300
Aprés le téléchargement du programme à partir de cette page http://www.lavrsen.dk/twiki/bin/view/Open2300/DownloadFiles (version 1.10 actuellement)
$ tar xvf open2300-1.10.tar.gz $ cd open2300-1.10/ $ make $ make mysql2300 (Pour compiler le binaire mysql2300 utilisant la base de donnée MySql) # make install # cp open2300-dist.conf /etc/open2300.conf
Ne pas oublier d'utiliser le fichier mysql2300.sql pour créer les tables MySql.
Exemple pour créer les tables dans la base de donnée "meteo" existante.
mysql -u root -p meteo < mysql2300.sql
Configuration
Il suffit de configurer son propre fichier /etc/open2300.conf.
Seul le port série et les paramètres de connection MySql ont été modifié.
# open2300.conf # # Configuration files for open2300 weather station tools # # Default locations in which the programs will search for this file: # Programs search in this sequence: # 1. Path to config file including filename given as parameter (not supported by all tools) # 2. ./open2300.conf (current working directory) # 3. /usr/local/etc/open2300.conf (typical Linux location) # 4. /etc/open2300.conf (typical Linux location) # # All names are case sensitive!!! # Set to your serial port and time zone # For Windows use COM1, COM2, COM2 etc # For Linux use /dev/ttyS0, /dev/ttyS1 etc SERIAL_DEVICE /dev/ws2300 # /dev/ttyS0, /dev/ttyS1, COM1, COM2 etc TIMEZONE 1 # Hours Relative to UTC. East is positive, west is negative # Units of measure (set them to your preference) # The units of measure are ignored by wu2300 and cw2300 because both requires specific units WIND_SPEED m/s # select MPH (miles/hour), m/s, or km/h TEMPERATURE C # Select C or F RAIN mm # Select mm or IN PRESSURE hPa # Select hPa, mb or INHG #### Citizens Weather variables (used only by cw2300) # Format for latitude is # [2 digit degrees][2 digit minutes].[2 decimals minutes - NOT seconds][N for north or S for south] # Format for longitude is # [3 digit degrees][2 digit minutes].[2 decimals minutes - NOT seconds][E for east or W for west] # Use leading zeros to get the format ####.##N (lat) and #####.##E (long) CITIZEN_WEATHER_ID CW0000 # CW0000 should be replaced by HAM call or actual CW number CITIZEN_WEATHER_LATITUDE 5540.12N # DDMM.mmN or S - example 55 deg, 40.23 minutes north CITIZEN_WEATHER_LONGITUDE 01224.60E # DDDMM.mmE or W - example 12 deg, 24.60 minutes east APRS_SERVER aprswest.net 23 # These are the APRS servers and ports for APRS_SERVER indiana.aprs2.net 23 # Citizens Weather reporting. APRS_SERVER newengland.aprs2.net 23 # They they are tried in the entered order APRS_SERVER aprsca.net 23 # you may enter up to 5 alternate servers #### WEATHER UNDERGROUND variables (used only by wu2300) WEATHER_UNDERGROUND_ID WUID # ID received from Weather Underground WEATHER_UNDERGROUND_PASSWORD WUPASSWORD # Password for Weather Underground ### MYSQL Settings (only used by mysql2300) MYSQL_HOST localhost # Localhost or IP address/host name MYSQL_USERNAME root # Name of the MySQL user that has access to the database MYSQL_PASSWORD xxxxxxxx # Password for the MySQL user MYSQL_DATABASE meteo # Named of your database MYSQL_PORT 0 # TCP/IP Port number. Zero means default #PGSQL_CONNECT hostaddr='127.0.0.1'dbname='open2300'user='postgres'password='sql' # Connection string #PGSQL_TABLE weather # Table name #PGSQL_STATION open2300 # Unique station id
Utilisation d'Open2300
Commandes pratiques pour vérifier le fonctionnement
fetch2300
Write current data to standard out
dan@vesta:open2300-1.10$ fetch2300 Date 2007-Oct-30 Time 17:07:33 Ti 19.9 Timin 13.5 Timax 31.1 TTimin 11:08 DTimin 2007-10-23 TTimax 18:45 DTimax 2007-08-05 To 10.9 Tomin -3.6 Tomax 35.1 TTomin 08:48 DTomin 2007-10-23 TTomax 17:21 DTomax 2007-08-05 DP 7.0 DPmin -21.9 DPmax 21.1 TDPmin 00:18 DDPmin 2007-10-26 TDPmax 15:08 DDPmax 2007-08-26 RHi 50 RHimin 35 RHimax 76 TRHimin 16:26 DRHimin 2007-10-24 TRHimax 13:43 DRHimax 2007-10-03 RHo 77 RHomin 0 RHomax 90 TRHomin 00:18 DRHomin 2007-10-26 TRHomax 12:14 DRHomax 2007-10-05 WS 1.1 DIRtext N DIR0 0.0 DIR1 22.5 DIR2 0.0 DIR3 337.5 DIR4 0.0 DIR5 22.5 WC 10.9 WCmin -9.8 WCmax 35.1 TWCmin 07:03 DWCmin 2007-10-24 TWCmax 17:21 DWCmax 2007-08-05 WSmin 0.0 WSmax 50.9 TWSmin 16:58 DWSmin 2007-10-30 TWSmax 08:40 DWSmax 2007-04-30 R1h 0.00 R1hmax 26.41 TR1hmax 09:39 DR1hmax 2007-05-08 R24h 1.55 R24hmax 32.63 TR24hmax 03:59 DR24hmax 2007-08-23 Rtot 773.89 TRtot 10:01 DRtot 2007-01-01 RP 1027.500 RPmin 1000.000 RPmax 1039.500 TRPmin 15:26 DRPmin 2007-07-23 TRPmax 13:00 DRPmax 2007-10-20 Tendency Rising Forecast Sunny
log2300
dan@vesta:open2300-1.10$ log2300 log2300 - Read and interpret data from WS-2300 weather station and write it to a log file. Perfect for a cron driven task. Version 1.10 (C)2003-2004 Kenneth Lavrsen. This program is released under the GNU General Public License (GPL) Usage: Save current data to logfile: log2300 filename config_filename
dan@vesta:open2300-1.10$ log2300 /tmp/test.log dan@vesta:open2300-1.10$ cat /tmp/test.log 20071030171049 2007-Oct-30 17:10:49 19.9 10.8 6.9 50 77 1.5 22.5 NNE 10.8 0.00 1.55 773.89 1027.500 Rising Sunny
histlog2300
Write history data to a log file. The data is interpreted into readable values.
20071030015900 2007-Oct-30 01:59:00 21.6 5.3 3.3 46 87 0.0 180.0 S 5.3 570.84 1022.000 20071030025900 2007-Oct-30 02:59:00 20.4 4.4 2.6 47 88 0.9 247.5 WSW 4.4 570.84 1022.600 20071030035900 2007-Oct-30 03:59:00 19.5 3.9 1.9 47 87 0.0 247.5 WSW 3.9 570.84 1022.600 20071030045900 2007-Oct-30 04:59:00 19.4 3.9 1.9 47 87 1.5 270.0 W 2.7 570.84 1022.800 20071030055900 2007-Oct-30 05:59:00 19.3 4.2 2.4 47 88 1.0 270.0 W 4.2 570.84 1023.000 20071030065900 2007-Oct-30 06:59:00 19.3 4.7 2.9 47 88 0.8 270.0 W 4.7 570.84 1023.300 20071030075900 2007-Oct-30 07:59:00 19.6 5.3 3.5 50 88 4.3 270.0 W 2.0 570.84 1023.900 20071030085900 2007-Oct-30 08:59:00 19.7 5.8 4.1 50 89 0.0 337.5 NNW 5.8 570.84 1024.500 20071030095900 2007-Oct-30 09:59:00 19.7 7.1 5.4 50 89 0.6 22.5 NNE 7.1 570.84 1025.100 20071030105900 2007-Oct-30 10:59:00 19.9 9.8 8.1 51 89 3.7 0.0 N 7.9 570.84 1025.900 20071030115900 2007-Oct-30 11:59:00 20.2 10.6 8.9 51 89 0.8 22.5 NNE 10.6 570.84 1026.100 20071030125900 2007-Oct-30 12:59:00 20.5 12.5 10.6 51 88 0.7 315.0 NW 12.5 570.84 1025.900 20071030135900 2007-Oct-30 13:59:00 20.0 11.9 9.3 52 84 1.0 0.0 N 11.9 572.39 1026.300 20071030145900 2007-Oct-30 14:59:00 20.4 11.8 9.0 51 83 2.0 337.5 NNW 11.3 572.39 1026.400 20071030155900 2007-Oct-30 15:59:00 20.4 11.5 8.2 49 80 2.9 22.5 NNE 10.4 572.39 1026.900 20071030165900 2007-Oct-30 16:59:00 20.0 11.0 7.1 50 77 0.9 337.5 NNW 11.0 572.39 1027.400
mysql2300
Write current data to MySQL database
Extrait de données de la base MySql:
dan@vesta:open2300-1.10$ mysql -u root -p meteo Enter password: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1670 Server version: 5.0.45-Debian_1-log Debian etch distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> select timestamp,rec_date,rec_time,temp_in,temp_out,rain_total,rel_pressure from ws2300 -> order by timestamp -> desc -> limit 20 ; +----------------+------------+----------+---------+----------+------------+--------------+ | timestamp | rec_date | rec_time | temp_in | temp_out | rain_total | rel_pressure | +----------------+------------+----------+---------+----------+------------+--------------+ | 20071030172605 | 2007-10-30 | 17:26:05 | 19.8 | 10.4 | 773.9 | 1027.8 | | 20071030172505 | 2007-10-30 | 17:25:05 | 19.8 | 10.4 | 773.9 | 1027.8 | | 20071030172407 | 2007-10-30 | 17:24:07 | 19.8 | 10.5 | 773.9 | 1027.9 | | 20071030172306 | 2007-10-30 | 17:23:06 | 19.8 | 10.5 | 773.9 | 1027.8 | | 20071030172207 | 2007-10-30 | 17:22:07 | 19.8 | 10.6 | 773.9 | 1027.6 | | 20071030172107 | 2007-10-30 | 17:21:07 | 19.8 | 10.6 | 773.9 | 1027.7 | | 20071030172008 | 2007-10-30 | 17:20:08 | 19.9 | 10.6 | 773.9 | 1027.7 | | 20071030171905 | 2007-10-30 | 17:19:05 | 19.9 | 10.6 | 773.9 | 1027.7 | | 20071030171806 | 2007-10-30 | 17:18:06 | 19.8 | 10.7 | 773.9 | 1027.7 | | 20071030171706 | 2007-10-30 | 17:17:06 | 19.9 | 10.7 | 773.9 | 1027.7 | | 20071030171632 | 2007-10-30 | 17:16:32 | 19.9 | 10.7 | 773.9 | 1027.7 | | 20071030171504 | 2007-10-30 | 17:15:04 | 19.9 | 10.8 | 773.9 | 1027.7 | | 20071030171405 | 2007-10-30 | 17:14:05 | 19.9 | 10.8 | 773.9 | 1027.6 | | 20071030171303 | 2007-10-30 | 17:13:03 | 19.9 | 10.8 | 773.9 | 1027.6 | | 20071030171204 | 2007-10-30 | 17:12:04 | 19.9 | 10.8 | 773.9 | 1027.6 | | 20071030171108 | 2007-10-30 | 17:11:08 | 19.9 | 10.8 | 773.9 | 1027.5 | | 20071030171006 | 2007-10-30 | 17:10:06 | 19.9 | 10.9 | 773.9 | 1027.6 | | 20071030170906 | 2007-10-30 | 17:09:06 | 19.9 | 10.9 | 773.9 | 1027.6 | | 20071030170804 | 2007-10-30 | 17:08:04 | 19.9 | 10.9 | 773.9 | 1027.5 | | 20071030170709 | 2007-10-30 | 17:07:09 | 19.9 | 10.9 | 773.9 | 1027.5 | +----------------+------------+----------+---------+----------+------------+--------------+ 20 rows in set (0.00 sec) mysql>
wu2300
Send current data to Weather Underground
Ce programme lit les données sur la station et les envoie sur le site Weather Underground.
Il faudra au préalable se créer un compte (gratuit)
Ne pas oublier de rajouter l'ID/PASSWORD dans le fichier de config. d'Open2300.
Utilisant le programme mysql2300, il n'est pas pratique d'utiliser wu2300 en parallèle sans riquer de bloquer le port série de la station.
Les données étant dans la base MySql, voici un script bash permettant de faire la même chose que wu2300 mais celui-ci interroge la base au lieu de relire la station.
#!/bin/bash # By Domos date=$(date '+%s') data=$(mysql -s -u root -p$(cat ./mysql.txt) -D meteo << ! SELECT timestamp, rec_date, rec_time, ROUND((temp_out * 9 / 5 + 32), 2) AS temp_outf, ROUND((dewpoint * 9 / 5 + 32), 2) AS dewpointf, rel_hum_out, ROUND(windspeed * 2.23693629, 2) AS windspeedmph, wind_angle, ROUND(rain_1h / 25.4, 2) AS rain_1hin, ROUND(rain_24h / 25.4, 2) AS rain_24hin, ROUND(rel_pressure / 33.8638864, 3) AS rel_pressurein FROM ws2300 ORDER BY timestamp DESC LIMIT 1 ; ! ) if [ $? -ne 0 ] then echo "Erreur accés base MySql meteo !" exit 1 fi liste="timestampws rec_date rec_time temp_outf dewpointf rel_hum_out windspeedmph wind_angle rain_1hin rain_24hin rel_pressurein" echo $data | while read $liste do datews=`echo $timestampws | cut -c1-8` heuresws=`echo $timestampws | cut -c9-10` minutesws=`echo $timestampws | cut -c11-12` secondesws=`echo $timestampws | cut -c13-14` secondesdata=`date +%s -d $datews` timestamp=$(echo "$secondesdata + $heuresws*3600 + $minutesws*60 + $secondesws" | bc) diffsecondes=$(( $date - $timestamp )) #echo "Diff. sec. = $diffsecondes" if [ $diffsecondes -gt 60 ] then echo "Données Ws2300 plus à jour !" exit 1 fi BASEURL_wu="weatherstation.wunderground.com" PATH_wu="/weatherstation/updateweatherstation.php" ID_wu="id" PASSWORD_wu="passwd" SOFTWARETYPE_wu="open2300%20v1.10" date_wu=$(date -u "+dateutc=%Y-%m-%d+%H%%3A%M%%3A%S") url_wu="http://$BASEURL_wu$PATH_wu?ID=$ID_wu&PASSWORD=$PASSWORD_wu&$date_wu&tempf=$temp_outf&dewptf=$dewpointf&humidity=$rel_hum_out&windspeedmph=$windspeedmph&winddir=$wind_angle&rainin=$rain_1hin&dailyrainin=$rain_24hin&baromin=$rel_pressurein&softwaretype=open2300%20v1.10m&action=updateraw" #echo $url_wu reponse_wu=$(wget -q -O - "$url_wu") #echo $reponse_wu if [ "$reponse_wu" != "success" ] then echo "$reponse_wu" echo "Erreur mise à jour station WS2300 sur Weather UnderGround !" fi done
Voir les données de la station sur le site The Weather Underground
Mise en forme graphique des données relevées
Avec RRDTool
Avec JpGraph en Janvier 2009



