logo

Questa è una guida per eseguire Weewx su OpenWRT con una stazione meteo Oregon Scientific WMR200.

 

PREREQUISITI

 
  • • OpenWRT Chaos Calmer 15.05

  • • Circa 10 Mb di spazio libero (una volta compilati, installati e rimossi i pacchetti sorgente, occuperanno circa 7 Mb)

  • • Pacchetti dal repository tramite webui o ssh opkg:

    • - python-light
    • - libusb-1.0
    • - openssh-sftp-server (opzionale, fornisce l'accesso SFTP, utile per la modifica dei file)

  • • Pacchetti Python dal repository:

    • - python-distutils
    • - python-codecs
    • - python-openssl
    • - python-logging
    • - python-email
    • - python-decimal
    • - python-ctypes
    • - python-sqlite3

  • • Pacchetti Python dalla sorgente (cioè non nel repository) "python setup.py install" (non provengono dal sito dev, per non usare https in wget):

    • - configobj: http://pypi.upc.edu/mirror/configobj/configobj-5.0.6.tar.gz
    • - six: http://pkgs.fedoraproject.org/repo/pkgs/python-six/six-1.10.0.tar.gz/34eed507548117b2ab523ab14b2f8b55/six-1.10.0.tar.gz
    • - pyusb: http://internode.dl.sourceforge.net/project/pyusb/PyUSB%201.0/1.0.0/pyusb-1.0.0.tar.gz

  • • Codice sorgente di Weewx, sezione Installare con setup.py nella Guida all'installazione (una volta installato puoi risparmiare circa 1 MB eliminando le cartelle di esempi, documentazione e skin)

 

CONFIGURAZIONE WEEWX

 

In weewx.conf ho disabilitato i report per salvare l'installazione di altri pacchetti:

report_services = weewx.engine.StdPrint

Aggiungi la sezione driver:

[WMR200]
    # This section is for the Oregon Scientific WMR200
    
    # The station model, e.g., WMR200, WMR200A, Radio Shack W200
    model = WMR200
    
    # The driver to use:
    driver = weewx.drivers.wmr200
    
    archive_interval = 300

Quindi forza l'intervallo di archiviazione per l'impostazione della tua stazione, nelle sezioni [WMR200] e [StdArchive]:

[StdArchive]
    
    # If the station hardware supports data logging then the archive interval
    # will be downloaded from the station. Otherwise, specify it (in seconds).
    archive_interval = 300

Quindi per correggere l'errore con il driver di back-end mancante è necessario aiutare il file del driver /home/weewx/bin/weewx/drivers/wmr200.py a trovare il driver USB installato:

import usb

import usb.backend.libusb1
backend = usb.backend.libusb1.get_backend(find_library=lambda x: "/usr/lib/libusb-1.0.so")

Il problema sopra descritto e la correzione non si applicano solo al file wmr200.py ma sembra rilevante per tutti i driver basati su USB. Sicuramente vale anche per il driver fousb.py che supporta un'enorme varietà di stazioni meteorologiche prodotte da Fine Offset.

Ora dovrebbe funzionare. Puoi monitorare il registro di sistema per i messaggi Weewx in ssh -> "logread -f"

 

SCRIPT INIT

 

Ho aggiunto questo script init di avvio: /etc/init.d/weewxd

#!/bin/sh /etc/rc.common
# Simple weewkd initd for openwrt
# Note paths used if different.
# www.httech.com.au

START=99
STOP=99

start() {        
        logger "starting weewx"
        # commands to launch application
        /home/weewx/bin/weewxd --daemon /home/weewx/weewx.conf
}       

stop() {          
        logger "stopping weewx"
        # commands to kill application 
        kill -9 `cat /var/run/weewx.pid`        
}

restart() {          
        logger "restarting weewx"
        # commands to kill application 
        kill -HUP `cat /var/run/weewx.pid`
        /home/weewx/bin/weewxd --daemon /home/weewx/weewx.conf
}
 

CREDITI

 
Hayden Thring
Autore: BernieHD