Linux: Weather Station
Linux Powered Weather Station
Linux Weather Station
The following is a guide on how to set up a Weather Station and a Raspberry Pi that can stream your weather data to a personal web site. In the following example, I have assumed that you have positioned your weather station in a safe area already and have connected your weather station to your home network. In this project, I have used the following components:
WS-1001 Weather Station
The WS-1001 is a popular Weather station which also sells under many different brand names (WS1001, HP1000, XC0422, Ambient, Watson and N23DQ to name a few). These weather stations are available from many online retailers and from many high street stores. The particular model I have used is a (N23DQ) which I purchased from my local Maplin Electronic store. The weather station comes with a variety of sensors that allow for the monitoring of Indoor and Outdoor temperatures, Humidity, Wind Speed, Rain, Air Pressure and UV Light. The Sensor array transmits the data to a base console which displays the current conditions.
Various options are available directly from the console that allow you to transmit your data to various weather online sites such as "Weather Underground". However, if you want to use your data on your own personal website, then you are limited by what you can be done straight out of the box.
The Raspberry Pi is a small single board computer that can be linked to a keyboard, monitor (TV) and various other devices. It comes with built in bluetooth, wifi, 4 x USB Ports, 1 x Ethernet Port, Quad Core CPU, MicroSD card slot, Full size HDMI output, audio output jack and 1 GB of RAM. For this particular setup, I used a Raspberry Pi 3 with a 16GB SD Card, Mouse, Keyboard, USB Power supply (2.5 amps) and HDMI lead to a portable TV/Monitor Screen. The SD card came pre-installed with NOOBS Debian Linux. The set-up is very easy to do as it basically involved plugging all the components in and powering on. Once powered online, you can connect to either a Wifi network or plug in an Ethernet cable. Full details will be given below on how to set a static IP address and allow "SSH" connectivity to the Raspberry Pi from other computers.
The software chosen to run on the Raspberry Pi is WeeWX which is a free, open source software program, that is written in Python and allows you to interact with your weather station. The software is capable of producing html reports and graphs. WeeWX can also be used to publish your reports and data to many other weather sites as well as your own personal web server. The transfer of this data is carried out using ftp/sftp and rsync.
The HP1000 driver is used in conjunction with the above software. The HP1000 driver allows the software running on your Raspberry Pi to communicate with your Weather Station Console. (Providing the Console and your Raspberry Pi are on the same network).
Cummulus RunTime Plugin
The Cummulus RunTime Plugin software is used as it allows for the creation of data in a format that can be used by popular weather templates. The software when running will create a file called "realtime.txt" which will contain all of the latest sensor information from your weather station.
Cummulus Weather Dashboard
This weather template software is used in conjunction with the file generated from the cummulus realtime plugin. The dashboard software is copied across to your web server and used for displaying all manner of statistical representations of your data.
Setting Up the Raspberry Pi
The Basic set-up of a Raspberry Pi has been covered in detail at the main Raspberry site:
Installing Debian "Stretch" on a Raspberry Pi
If you are new to using or working with a Raspberry Pi, I would recommend using the "NOOBS" (New Out Of Box Software) option. For this particular exercise, I have gone with the instructions for using the "NOOBS" setup. Once the OS has been installed, I carried out the following additional setup:
Activate SSH connectivity on your Raspberry Pi
When you come to working with your Raspberry Pi, you will find it very useful to activate the "SSH" option which will allow other computers on the same network to connect directly to the "Pi". To activate "SSH", follow the instructional guide below:
From the "Raspberry Pi" start button, select "Preferences" > "Raspberry Pi Configuration"
From this menu, simply select the Middle Tab "Interfaces" and click on the "Enabled" option and then click on "OK". Once you have done that, you may now "ssh" to your Raspberry Pi from other computers/devices on the same network. Before you go any further it is advisable to change your default raspberry pi password.
By default the user "pi has been created for you with a password of "raspberry". To change this, simply click on the "Terminal" icon on the top row of your desktop. (Normally the fourth icon across). Once clicked, this will open a command line terminal where you can issue the following command to set your new password: (command issued: sudo passwd pi
Once that has been done, you may now ssh from any other device/computer providing you know the IP address of your system. By default your Raspberry Pi will obtain an IP address by using what is known as "DHCP (Dynamic Host Configuration Protocol). Using this default protocol, your router will issue your Raspberry Pi with a temporary IP address. You can see this address by issuing the following command from the Terminal: "ip address show" or "ip a s "
What you need to do now is edit a configuration file and allocate a static IP address. A static IP address is an addresses that never changes, your Raspberry Pi will use this address even after a reboot.
To edit files in Linux, there are many different tools available such as "gedit", "vim/vi" and "Nano". In the following examples, I have used the "vi" editor, however, you may use which ever editor you are more comfortable or familiar with.
Static IP address on a raspberry Pi
The file where you place your static IP address into is called: "/etc/dhcpcd.conf". This file contains many settings. To set a static IP address and specify our nameservers, simply add the following relevant entry to the bottom of the file. If you are using an "Ethernet" cable, then use the option "interface eth0" and if you are using a wireless connection, use the option "interface wlan0":
Ethernet and Wireless Config Options
interface eth0 static ip_address=192.168.0.10/24 static routers=192.168.0.1 static domain_name_servers=192.168.0.1 184.108.40.206 220.127.116.11 interface wlan0 static ip_address=192.168.0.200/24 static routers=192.168.0.1 static domain_name_servers=192.168.0.1 18.104.22.168 22.214.171.124
On my setup, I have used a wireless connection, so the bottom of the "/etc/dhcpcd.conf" file looks like this:
Output from command "tail -n 7 /etc/dhcpcd.conf"
pi@raspberrypi:~ $ tail -n 7 /etc/dhcpcd.conf #My Static IP settings and DNS Servers interface wlan0 static ip_address=192.168.0.200/24 static routers=192.168.0.1 static domain_name_servers=126.96.36.199 188.8.131.52
In the above, the IP address I have assigned is: "192.168.0.200". I have also assigned my default gateway which is "192.168.0.1". If you are unsure of your default gateway, you can issue the command "route -n" to identify this.
The nameservers I am using for DNS lookup are provided by google as part of their Public DNS system. These IP addresses are "184.108.40.206" and "220.127.116.11". NOTE: Please amend the IP address information and gateway information to match that of your own network. Once you have made these changes, it is a good time to try a reboot and verify that you are now using a static IP address. To reboot your Pi, simply click on the Raspberry Pi logo and select "Shutdown" > "Reboot". Alternatively, you may issue the "reboot" command directly from the "Terminal"
There are a several system prerequisites that need to be verified or installed before we can install the additional software to the Raspberry Pi. Firstly you will need to ensure that "Python" the multipurpose programming language is installed. By default, this should already be installed as part of the Debian OS on your Raspberry Pi. However to check, you can issue the following command: "python -V"
pi@raspberrypi:~ $ python -V Python 2.7.13
As long you have "Python 2.7.x or above, you will be fine. However, I do not believe "Python 3.x" is compatible.
Next, install the basic ftp package if not already installed. This can be installed by issuing the command: "sudo apt-get install ftp". Please note "ftp" is not a secure method of transferring data between servers. Ideally, you should be using "sftp" as this allows for encryption. However, for simplicity, I have used the default "ftp" package. The option for setting up "sftp" can be configured from the main configuration file. Details on this will be provided later. If you need additional information for installing or removing software, see our Package Management guide:
Next you will need to install the "Python" network pacakge "python-netifaces". This package can be installed by issuing the command: "sudo apt-get install python-netifaces". This package will allow the "HP1000" driver to discover your weather station on your network.
pi@raspberry:~ $ sudo apt-get install ftp pi@raspberry:~ $ sudo apt-get isntall python-netifaces
Installing WeeWX Software
WeeWX is free, open source, software program, written in the Python programming language, which interacts with your weather station. In this project, we are installing weewx as it will be used to communicate with the weather station base unit and can be used to create html output for use on a web server. Options exist within the configuration that allow you to utilise ftp and rsync for transferring files to your web server or some of the popular weather sites like "Weather Underground".
Adding Software repositories
Before we can install the software, we need to define to the system where the downloads can be obtained from. This is done by adding the download location to a list of available repositories. The commands to accomplish this are as follows:
wget -qO - http://weewx.com/apt/weewx.list | sudo tee /etc/apt/sources.list.d/weewx.list
Output from the above commands can be seen below:
pi@raspberry:~ $ wget -qO - http://weewx.com/keys.html | sudo apt-key add - OK pi@raspberry:~ $ wget -qO - http://weewx.com/apt/weewx.list | sudo tee /etc/apt/sources.list.d/weewx.list deb [arch=all] http://weewx.com/apt/ squeeze main
Before we install the software, we need to run an update to refresh the repositories. This will ensure that any software that is downloaded will be at the latest version. The command to accomplish this is: "sudo apt-get update":
sudo apt-get update
The command used for installing the "weewx" package is: "sudo apt-get install weewx"
sudo apt-get install weewx
When you issue the above command you will be prompted to enter the following details: Location, Latitude and Longitude of your weather station, Altitude, Display Units, Hardware Type and Weather Station Model. Screen shots can be seen below along with the entries I have used. Please modify where appropriate for your location. The values you enter at the configuration screens can be amended if needed by manually editing the main configuration file: /etc/weewx/weewx.config
Location String - Description of your Location
Latitude and Longitude of your Weather Station
Altitude of your Weather Station
Display Units: US/Metric
Weather Station Hardware Type: Simulator Selected
Weather Station Model: WS-1001
Once you have finished entering the requested details, you should now be able to see that the "weewx" software is running. You can verify this by looking in your systems log files. To do this, issue the following command from the terminal: sudo tail -f /var/log/syslog
You should now see entries similar to the following:
Dec 28 18:11:28 raspberrypi weewx: engine: Initializing weewx version 3.8.0 Dec 28 18:11:28 raspberrypi weewx: engine: Using Python 2.7.13 (default, Jan 19 2017, 14:48:08) #012[GCC 6.3.0 20170124] Dec 28 18:11:28 raspberrypi weewx: engine: Platform Linux-4.9.59-v7+-armv7l-with-debian-9.1 Dec 28 18:11:28 raspberrypi weewx: engine: Locale is 'en_GB.UTF-8' Dec 28 18:11:28 raspberrypi weewx: engine: pid file is /var/run/weewx.pid Dec 28 18:11:28 raspberrypi weewx: engine: Using configuration file /etc/weewx/weewx.conf Dec 28 18:11:28 raspberrypi weewx: engine: Loading station type Simulator (weewx.drivers.simulator)
Download and Install Interceptor Driver
The "Interceptor" driver needs to be downloaded and installed. The Interceptor driver is used by weewx for parsing your network traffic. The command to download the Interceptor Driver is:
wget -O weewx-interceptor.zip https://github.com/matthewwall/weewx-interceptor/archive/master.zip
Output from the above command:
pi@raspberry:~ $ wget -O weewx-interceptor.zip https://github.com/matthewwall/weewx-interceptor/archive/master.zip --2017-12-28 12:14:11-- https://github.com/matthewwall/weewx-interceptor/archive/master.zip Resolving github.com (github.com)... 18.104.22.168, 22.214.171.124 Connecting to github.com (github.com)|126.96.36.199|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://codeload.github.com/matthewwall/weewx-interceptor/zip/master [following] --2017-12-28 12:14:12-- https://codeload.github.com/matthewwall/weewx-interceptor/zip/master Resolving codeload.github.com (codeload.github.com)... 188.8.131.52, 184.108.40.206 Connecting to codeload.github.com (codeload.github.com)|220.127.116.11|:443... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [application/zip] Saving to: ‘weewx-interceptor.zip’ weewx-interceptor.z [ <=> ] 51.79K 211KB/s in 0.2s 2017-12-28 12:14:13 (211 KB/s) - ‘weewx-interceptor.zip’ saved 
The above file now should have been downloaded and can be located within your home area as follows:
pi@raspberrypi:~ $ pwd /home/pi pi@raspberrypi:~ $ ls -l weewx-interceptor.zip -rw-r--r-- 1 pi pi 53031 Dec 28 18:19 weewx-interceptor.zip
Now you will need to install the "Interceptor" driver with the following command:
sudo wee_extension --install weewx-interceptor.zip
pi@raspberrypi:~ $ sudo wee_extension --install weewx-interceptor.zip Request to install 'weewx-interceptor.zip' Extracting from zip archive weewx-interceptor.zip Saving installer file to /usr/share/weewx/user/installer/interceptor Finished installing extension 'weewx-interceptor.zip'
Now configure the driver use by issuing the following command:
sudo wee_config --reconfigure --driver=user.interceptor --no-prompt
pi@raspberrypi:~ $ sudo wee_config --reconfigure --driver=user.interceptor --no-prompt Using configuration file /etc/weewx/weewx.conf Saved backup to /etc/weewx/weewx.conf.20171228183044 Saved configuration to /etc/weewx/weewx.conf
Install Cumulus Realtime Plugin - crt
The Cumulus Realtime Plugin - crt is an extension to weewx that emits data to a file in the format used by Cumulus realtime.txt. This file will be generated containing the sensor output from your weather station. The file can then be transferred to a web server and used in conjunction with a weather template to create a dashboard containing near "real time" weather stats from your weather station.
The plugin can be downloaded from the location: Cumulus Realtime Plugin. At the time of creating this document, the version of this software was at "weewx-crt-0.18.tgz". If this version has been updated, you will need to amend the commands to match the lateset version. The command to download directly from the above location is as follows:
pi@raspberrypi:~ $ wget http://lancet.mit.edu/mwall/projects/weather/releases/weewx-crt-0.18.tgz --2017-12-28 18:34:21-- http://lancet.mit.edu/mwall/projects/weather/releases/weewx-crt-0.18.tgz Resolving lancet.mit.edu (lancet.mit.edu)... 18.104.22.168 Connecting to lancet.mit.edu (lancet.mit.edu)|22.214.171.124|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 10595 (10K) [application/x-gzip] Saving to: ‘weewx-crt-0.18.tgz’ weewx-crt-0.18.tgz 100%[===================>] 10.35K 46.3KB/s in 0.2s 2017-12-28 18:34:21 (46.3 KB/s) - ‘weewx-crt-0.18.tgz’ saved [10595/10595] pi@raspberrypi:~ $ ls -l weewx-interceptor.zip -rw-r--r-- 1 pi pi 53031 Dec 28 18:19 weewx-interceptor.zip
Once you have successfully download the above file, you can now issue the following command to install the plugin:
sudo wee_extension --install weewx-crt-0.18.tgz
pi@raspberrypi:~ $ sudo wee_extension --install weewx-crt-0.18.tgz Request to install 'weewx-crt-0.18.tgz' Extracting from tar archive weewx-crt-0.18.tgz Saving installer file to /usr/share/weewx/user/installer/crt Saved configuration dictionary. Backup copy at /etc/weewx/weewx.conf.20171228183723 Finished installing extension 'weewx-crt-0.18.tgz'
Next, you need to add the following lines to the bottom of the main "weewx" configuration file. (Amend/add accordingly). The main configuration file is located at:
You may use the editor of your choice for amending this file. In this example, I am using the "vi" editor. The command I used to edit the file is as follows: sudo vi /etc/weewx/weewx.conf
[CumulusRealTime] filename = /var/tmp/realtime.txt unit_system = METRIC # options are US, METRIC, METRICWX
The above specifies the location of where the "realtime.txt" file is to be placed on your server.
Install HP1000 Driver
The next step is to install the "HP1000" driver. This is the driver that is going to make the connection to your weather station from your Raspberry Pi. The driver can be downloaded from the following site: HP1000 Driver. The following commands can be issued to download and install the HP1000 driver to your Raspberry Pi:
cd wget https://github.com/AussieSusan/HP1000/archive/master.zip unzip master.zip cd HP1000-master/ tar xvf hp1000.tar.gz sudo python /usr/bin/wee_extension --install /home/pi/HP1000-master/HP1000
The output from the above commands can be seen below:
pi@raspberry:~ $ wget https://github.com/AussieSusan/HP1000/archive/master.zip --2017-12-31 14:24:14-- https://github.com/AussieSusan/HP1000/archive/master.zip Resolving github.com (github.com)... 126.96.36.199, 188.8.131.52 Connecting to github.com (github.com)|184.108.40.206|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://codeload.github.com/AussieSusan/HP1000/zip/master [following] --2017-12-31 14:24:14-- https://codeload.github.com/AussieSusan/HP1000/zip/master Resolving codeload.github.com (codeload.github.com)... 220.127.116.11, 18.104.22.168 Connecting to codeload.github.com (codeload.github.com)|22.214.171.124|:443... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [application/zip] Saving to: ‘master.zip’ master.zip [ <=> ] 17.95K --.-KB/s in 0.1s 2017-12-31 14:24:15 (142 KB/s) - ‘master.zip’ saved  pi@raspberry:~ $ unzip master.zip Archive: master.zip 81a5a43eef744bbb2f33ccafd9284ac54d05e353 creating: HP1000-master/ inflating: HP1000-master/hp1000.tar.gz inflating: HP1000-master/readme.md pi@raspberry:~ $ cd HP1000-master/ pi@raspberry:~/HP1000-master $ tar xvf hp1000.tar.gz HP1000/ HP1000/bin/ HP1000/._install.py HP1000/install.py HP1000/._readme.md HP1000/readme.md HP1000/bin/user/ HP1000/bin/user/._HP1000.py HP1000/bin/user/HP1000.py pi@raspberry:~/HP1000-master $ sudo python /usr/bin/wee_extension --install /home/pi/HP1000-master/HP1000 Request to install '/home/pi/HP1000-master/HP1000' Saving installer file to /usr/share/weewx/user/installer/HP1000 Finished installing extension '/home/pi/HP1000-master/HP1000'
The next step is to reconfigure "weewx" to use the HP1000 driver. To accomplish this, issue the command as follows:
Command Issued: sudo python /usr/bin/wee_config --reconfigure
pi@raspberrypi:~ $ sudo python /usr/bin/wee_config --reconfigure Using configuration file /etc/weewx/weewx.conf Enter a brief description of the station, such as its location. For example: Santa's Workshop, North Pole description [Sedgley - West Midlands]: Specify altitude, with units 'foot' or 'meter'. For example: 35, foot 12, meter altitude [235, meter]: Specify latitude in decimal degrees, negative for south. latitude [52.536]: Specify longitude in decimal degrees, negative for west. longitude [-2.119]: Indicate the preferred units for display: 'metric' or 'us' units [metricwx]: metric Installed drivers include: 0) HP1000 (user.HP1000) 1) Interceptor (user.interceptor) 2) AcuRite (weewx.drivers.acurite) 3) CC3000 (weewx.drivers.cc3000) 4) FineOffsetUSB (weewx.drivers.fousb) 5) Simulator (weewx.drivers.simulator) 6) TE923 (weewx.drivers.te923) 7) Ultimeter (weewx.drivers.ultimeter) 8) Vantage (weewx.drivers.vantage) 9) WMR100 (weewx.drivers.wmr100) 10) WMR200 (weewx.drivers.wmr200) 11) WMR300 (weewx.drivers.wmr300) 12) WMR9x8 (weewx.drivers.wmr9x8) 13) WS1 (weewx.drivers.ws1) 14) WS23xx (weewx.drivers.ws23xx) 15) WS28xx (weewx.drivers.ws28xx) choose a driver : 0 Saved backup to /etc/weewx/weewx.conf.20171229200832 Saved configuration to /etc/weewx/weewx.conf
weewx.conf - Confiuration File
Now edit the main configuration file that is located at "/etc/weewx/weewx.conf" using the editor of your choice. Amend the following sections to read as follows:
Under the [Interceptor] heading change the following lines:
From: device_type = acurite-bridge
To: device_type = observer
Example extract from my weewx.conf file:
[Interceptor] # This section is for the network traffic interceptor driver. # The driver to use: driver = user.interceptor # Specify the hardware device to capture. Options include: # acurite-bridge - acurite internet bridge # observer - fine offset WH2600/HP1000/HP1003, aka 'observer' # lw30x - oregon scientific LW301/LW302 # lacrosse-bridge - lacrosse GW1000U/C84612 internet bridge #### device_type = acurite-bridge device_type = observer
At the top of the file under the line that says "debug=" add the following lines:
# The following line manages network failures loop_on_init = True
The above will ensure that if a loss of network connectivity occurs that your system will recover once the network connection has been established again.
Starting/Stopping and Restarting weewx
Once you have made the above amendments, you will need to restart "weewx". The following command will allow you to restart your system:
sudo /etc/init.d/weewx restart
Useful weewx commands
The following commands can be used for starting, stopping, restarting, reloading and checking the status of "weewx":
sudo /etc/init.d/weewx stop
This command will stop "weewx"
sudo /etc/init.d/weewx start
This command will start "weewx"
sudo /etc/init.d/weewx restart
This command will start "weewx" if its not running. If the weewx is already running, then the process will be terminated and restarted.
sudo /etc/init.d/weewx status
This command will display running information about the current status of weewx.
sudo /etc/init.d/weewx reload
This command will reoload the current weewx.conf file.
This command will display installed extensions along with their version number and a description.
Checking Connectivity to your Weather Station
Once you have restarted "weewx", you can check your system logs to make sure that your "Raspberry Pi" is communicating with your weather station. To check this, you must look within the file:
You should now see entries similar to the ones shown below:
Dec 31 11:12:13 raspberrypi weewx: HP1000: Connected to address ('192.168.0.17', 60774) Dec 31 11:12:14 raspberrypi weewx: HP1000: Established contact at 31/12/17 11:12:14
Your entries will reflect the IP address of your weather station on your network. Note, this is the IP address of your weather station and not the Raspberry Pi.
Cumulus Realtime Plugin
Now that connectivity has been established from your Raspberry Pi to your weather station. You should now see a file being generated in the following location:
This file contains the collected weather data from your weather station sensors. The contents of the file will be in a format similar to:
pi@raspberrypi:~ $ cat /var/tmp/realtime.txt 01/01/18 13:09:16 3.8 91 2.5 1.1 3.2 136 0.0 2.7 989.4 SE 1 km/h C mb mm 26.2 0.4 2.7 2.7 7.2 22.6 48 3.8 0.2 4.5 05:25 2.6 01:30 6.2 04:25 24.1 04:35 990.3 02:10 988.4 08:45 3.8.0 0 7.9 3.8 3.8 1 0.0 112 142 0.0 0 1 0 SE 401 m 1.6 4.8 NULL 0
A full explanation of each field can be found at the following wiki website: Realtime.txt.
To provide updated information about your recorded weather, you must upload this file to your website. In this example, I am uploading the file every two minutes. (You may change this value to match your own needs). To achieve this upload, I have created a simple script which gets executed by a "cron" job every two minutes. As well as the standard html reports that will be created from "weewx", I will be using a custom weather template that is freely available for use on web servers. Details of this will be provided later.
In this example I have created a directory on my webserver called "sedgley_live_data. This is the location where I am going to send the "realtime.txt" file to.
If you use the example script, you will need to amend the entries for HOST, USER, PASSWD and REMOTE_PATH. My ftp script is called: "send_realtime.sh
Simple ftp Script:
#!/bin/sh HOST='ftp.johnreed.co.uk' USER='xxxxxxxxxxxxxxxx' PASSWD='xxxxxxxxxxxxxxxxxx' FILE='/var/tmp' REMOTE_PATH='/html/johnreed.co.uk/sedgley_live_data' ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD cd $REMOTE_PATH lcd $FILE put realtime.txt quit END_SCRIPT exit 0
Once you have created your script and amended it to match your environment, you will need to set "execute" permissions on this file.
To do this we will use the command "chmod".
The command issued will be: chmod u+x send_realtime.sh
pi@raspberry:~ $ ls -l send_realtime.sh -rw-r--r-- 1 pi pi 292 Jan 7 13:47 send_realtime.sh pi@raspberry:~ $ chmod u+x send_realtime.sh pi@raspberry:~ $ ls -l send_realtime.sh -rwxr--r-- 1 pi pi 292 Jan 7 13:47 send_realtime.sh
As you can see from the above a "x has now been added to the permssions for the user "pi. More details for permission settings can be found at Linux File Permissions explained.
Cron job to transfer realtime.txt
Once you have the above script in place with the relevant user credentials and paths defined. You will need to create a cron job that can run continually transfer the realtime.txt file to your target server. An explanation of how to create cron jobs can be found here Crontab entries
Below is how I created the crontab entry for the above script.
Issue the command: crontab -e
Now add the following line to the bottom of the file:
*/2 * * * * sudo -u pi /home/pi/send_realtime.sh 2>&1
The above entry will run the ftp script that you created in the previous step every 2 minutes. You can change this value of 2 minutes to a value that matches your requirements. Note, the path of the file must match the exact location of where you created your script.
weewx html reports
One of the great features of "weewx" is its built in ability to generate reports in a html format. If you do not wish to use the default reporting option and want only to use the "realtime.txt" option, you can comment out the ftp settings below so that the latest updates from your station are not transferred to your webserver.
The html reports are generated within the default directory location of : /var/www/html/weewx You can view these reports directly on your Raspberry Pi by entering the following into your Raspberry Pi's browser:
If you wish to automate the transferring of these reports to your webserver, then you will need to fill out the section below from the "weewx.conf" configuration file:
Below is an example of the test configuration that I used for initial testing.
In the example below, I am sending the reports to the directory "sedgley_live_data" on my test web server. You will need to amend your entries to match your environment/directory structure.
[[FTP]] # FTP'ing the results to a webserver is treated as just another report, # albeit one with an unusual report generator! skin = Ftp # Set to True for an FTP over TLS (FTPS) connection. Not all servers # support this. secure_ftp = False # To upload files from something other than what HTML_ROOT is set # to above, specify a different HTML_ROOT here. #HTML_ROOT = /var/www/html/weewx # Most FTP servers use port 21 port = 21 # Set to 1 to use passive mode, zero for active mode passive = 1 # If you wish to use FTP, uncomment and fill out the next four lines. user = xxxxxxxxxxxxxxxx password = xxxxxxxxxxxxxxxxxxxx server = ftp.johnreed.co.uk path = /html/johnreed.co.uk/sedgley_live_data
Example html Report
The default reports will display all data that has been collected from your station. Various graphs will also display a time line so that you can see any current trends.
Using a Weather Template
If you have chosen not to go with the default html reporting option. You can always choose to use a dedicated weather template. A popular template for displaying weather station data can be obtained from the site Weather Station Dashboard. The template is called "CUMULUS CU-X7". A zip file containing all of the files can be downloaded from the above link.
Please NOTE: your web server must have php 5 or above activated to use this template. You maybe able to activate this yourself from your Webserver dashboard or you may need to ask your hosting company to activate this for you.
Once you have downloaded the zip file, you will need to extract the contents to a directory on your local computer. Once you have extracted the downloaded files, you must then copy the contents of this directory to your web server. On my test server, I copied the extracted files to the root location. Once that was done, I typed in the url of my web server on a internet connected browser and followed the instructions. Initially you should be presented with a setup area that runs a script called "easyweathersetup.php"
The first time this script is run you will be asked to create a password for your dashboard. Once you have done this, you may now start to configure your template settings. Various options and configurations can be added or modified. If you have a Weather station account with "Weather Underground", you can retrieve your api key from the following location: Weather Underground API key. You can use the api key to provide forecast data for your weather station. Various options exist for supplying the current outlook and several days ahead outlook.
CUMULUS CU-X7 - Dashboard
Once you have completed your setup, you should now see a dashboard similar to the one below: My Weather Station