WeeWX: Installation on Debian-based systems




This is a guide to installing WeeWx from a DEB package on Debian-based systems, including Ubuntu, Mint, and Raspbian.
Configure apt
Tell apt where to find the WeeWx releases. This only has to be done once – the first time you install WeeWx.
wget -qO – http://weewx.com/keys.html | sudo apt-key add – wget -qO – http://weewx.com/apt/weewx.list | sudo tee /etc/apt/sources.list.d/weewx.list
Install
Use apt-get to install WeeWx. The installer will prompt for a location, latitude/longitude, altitude, station type, and parameters specific to your station hardware.
sudo apt-get update
sudo apt-get install weewx
When you are done, WeeWx will be running in the background as a daemon.
Status
To make sure things are running properly look in the system log for messages from WeeWx
sudo tail -f /var/log/syslog
Verify
After about 5 minutes, open the station web page in a web browser. You should see your station information and data.
file:///var/www/html/weewx/index.html
Adjusting Archive Interval (example every 5-mins)
If your hardware supports hardware archiving, then how long you wait will depend on the archive interval set in your hardware.
wee_device --set-interval=5
Allowed intervals are: 1, 5, 10, 15, 30, 60, or 120 minutes
Clear Logger memory
wee_device --clear-memory
Setting USB PORT to a logical
To ensure USB port assignment consistency across reboots, it is essential to have a fixed USB port name and the best way of doing this is to use a Logical rather than physical port addres.
1. First list-out the connected USB devices:
dmesg | grep ttyUSB
2. Now list out the details device information:
udevadm info –name=/dev/ttyUSB0 –attribute-walk
3. Find the device to assign the Logical name to:
In this case the idVendor = 0403 and idProduct = 6015
4. Now create the Logical link from the USB ports to the devices. To do this create a file which will specify the rule for each USB device based on the unique properties just found. In the Terminal, enter following command to create a file with the rules :
sudo nano /etc/udev/rules.d/10-usb-serial.rules
Enter:
SUBSYSTEM==”tty”, ATTRS{idProduct}==”6015″, ATTRS{idVendor}==”0403″, SYMLINK+=”ttyUSBDAVIS”
The chosen Logical name is ‘USBDAVIS‘
5. Enter following command in the Terminal to let the rules take effect :
sudo udevadm trigger
6. You can check the new names you just created by entering the following command in the Terminal :
ls -l /dev/ttyUSB*
$ls -l /dev/ttyUSB*
crw-rw—- 1 root dialout 188, 1 Apr 17 11:28 /dev/ttyUSB1
crw-rw—- 1 root dialout 188, 2 Apr 17 11:40 /dev/ttyUSB2
lrwxrwxrwx 1 root root 7 Apr 17 11:28 /dev/ttyUSBDAVIS -> ttyUSB2
Customize
To enable uploads such as Weather Underground or to customise reports, modify the configuration file /etc/weewx/weewx.conf. See the User Guide and Customization Guide for details.
Edit the configuration file:
sudo nano /etc/weewx/weewx.conf
Edit the details for :
Weather Underground: site-name / password
WOW: Site-number / PIN
Change:
[[[Units]]]
# The following section sets what unit to use for each unit group.
# NB: The unit is always in the singular. I.e., ‘mile_per_hour’,
# NOT ‘miles_per_hour’
[[[[Groups]]]]
group_altitude = meter # Options are ‘foot’ or ‘meter’
group_degree_day = degree_C_day # Options are ‘degree_F_day’ or ‘degree_C_day’
group_distance = mile # Options are ‘mile’ or ‘km’
group_pressure = hPa # Options are ‘inHg’, ‘mmHg’, ‘mbar’, ‘hPa’, or ‘kPa’
group_rain = mm # Options are ‘inch’, ‘cm’, or ‘mm’
group_rainrate = mm_per_hour # Options are ‘inch_per_hour’, ‘cm_per_hour’, or mm_per_hour’
group_speed = mile_per_hour # Options are ‘mile_per_hour’, ‘km_per_hour’, ‘knot’, or ‘meter_per_second’
group_speed2 = mile_per_hour2 # Options are ‘mile_per_hour2’, ‘km_per_hour2’, ‘knot2’, or ‘meter_per_second2’
group_temperature = degree_C # Options are ‘degree_F’ or ‘degree_C’
Save file.
Now edit the Seasons Skin.conf file:
sudo nano /etc/weewx/skins/Seasons/skin.conf
Change graph colours to:
daynight_day_color = “#fcfcae”
daynight_night_color = “#d9d9fa”
daynight_edge_color = “#fff8f8”
Adjust image sizes:
image_width = 480
image_height = 290
Now edit current.inc:
sudo nano /etc/weewx/skins/Seasons/current.inc
To include the rain radar image:
# This radar image would be available as $Extras.radar_img
radar_img = http://m.meteox.co.uk/images.aspx?jaar=-3&voor=&soort=loop1uur&
To include the Beaufort scale report:
<tr>
<td class=”label”>$obs.label.wind</td>
<td class=”data”>$current.windSpeed $current.windDir.ordinal_compass ($current.windDir)</td>
</tr>
<tr>
<td class=”label”>Beaufort</td>
<td class=”data”>$current.windSpeed.beaufort</td>
</tr>
WeeWx must be restarted for configuration file changes to take effect.
Setting Up WU and WOW Uploads
Before you attempt to upload you will need 2 numbers. The first is your Site ID. This is an arbitrary number that is used to distinguish your site from another. This number appears (in brackets) next to or underneath the name of your site on the site information page, for example (956916003) for pre-June 2016 sites or (6a571450-df53-e611-9401-0003ff5987fd)
The second item you require is the Authentication Key. This is a 6 digit number that is used to ensure data is coming from you and not another user. If you do not know (or have not created) the Authentication Key, go to the Edit pages of any site you own and the value is an option under the Site Details section. Create and enter a 6-digit numeric PIN of your choice (it is not supplied by the kit manufacturer). The Authentication Key may also be referred to as the ‘AWS Pin’.
You must take note of both these numbers before continuing, otherwise you will not be able to upload weather data to WOW. More information regarding this can be found on the support page here:
https://wow.metoffice.gov.uk/support/dataformats
Start/Stop
To start/stop WeeWx:
sudo /etc/init.d/weewx start
sudo /etc/init.d/weewx stop
Re-load Config.txt without restarting WeeWx
sudo /etc/init.d/weewx reload
Refresh WU API Key or others
1. Go to Weather Underground or other service provider, get new / refreshed key
2. sudo nano /etc/weewx/weewx.conf
3. Scroll to the end and enter new API key for the service, save and exit
e.g. for WOW use c619f4f3-4615-eb11-8441-0003ff597f33
4. sudo /etc/init.d/weewx reload – to restart Weewx
Uninstall
To uninstall WeeWx but retain configuration files and data:
sudo apt-get remove weewx
To uninstall weeWX, removing configuration files but retaining data:
sudo apt-get purge weewx
To remove data:
sudo rm -r /var/lib/weewx
sudo rm -r /var/www/html/weewx
Layout
The installation will result in the following layout:
executable: | /usr/bin/weewxd |
configuration file: | /etc/weewx/weewx.conf |
skins and templates: | /etc/weewx/skins |
sqlite databases: | /var/lib/weewx/ |
generated web pages and images: | /var/www/html/weewx/ |
documentation: | /usr/share/doc/weewx/ |
examples: | /usr/share/doc/weewx/examples/ |
utilities: | /usr/bin/wee_* |
Making backups
To backup a WeeWx installation, you will need to make a copy of
- configuration information;
- skins and templates;
- any custom code or extensions you have installed;
- the WeeWx database.
It is not necessary to backup the generated images, HTML files, or NOAA reports since WeeWx will easily create these again.
Individual instructions follow.
Configuration
Save the weewx.conf file.
setup.py: | /home/weewx/weewx.conf |
DEB/RPM: | /etc/weewx/weewx.conf |
Skins and templates
Save the contents of the skins directory if you have modified the default skin or if you have added any new skins or template files.
setup.py: | /home/weewx/skins |
DEB/RPM: | /etc/weewx/skins |
Run a report at anytime:
sudo wee_reports /etc/weewx/weewx.conf
Custom code or extensions
Save the contents of the user directory if you have modified the database schema or added any extensions. If the extensions save data to a database you should backup those databases as well.
setup.py: | /home/weewx/bin/user |
DEB/RPM: | /usr/share/weewx/user |
Database
Finally, you will need to backup the database.
For a SQLite configuration, make a copy of the weewx.sdb file.
setup.py: | /home/weewx/archive/weewx.sdb |
DEB/RPM: | /var/lib/weewx/weewx.sdb |
Do not make the copy of the SQLite database while in the middle of a transaction! Schedule the backup for immediately after an archive record is written, and then make sure the backup completes before the next archive record arrives. Alternatively, stop weeWX, perform the backup, then restart weeWX.
For a MySQL configuration, save a dump of the archive database.
Restoring from backup
To restore from backup, do a fresh install of weeWX, replace the default files with those from a backup, then start weeWX.
Extra Required packages (For Almanac calculations):
# debian, ubuntu, mint, raspbian
# required packages:
sudo apt-get install python-configobj
sudo apt-get install python-cheetah
sudo apt-get install python-imaging
# required if hardware is serial or USB:
sudo apt-get install python-serial
sudo apt-get install python-usb
# required if using MySQL:
sudo apt-get install mysql-client
sudo apt-get install python-mysqldb
# required if using FTP on Raspbian systems:
sudo apt-get install ftp
# optional for extended almanac information:
sudo apt-get install python-dev
sudo apt-get install python-pip
sudo pip install pyephem
Dynamic DNS Updating
DYNU.COM setup – needed to update server IP address to dynu.com for DNS
You can make a script in Raspberry Pi and setup a cron job to run every 5 minutes to keep your hostnames updated to the most current IP address.
1. You can make a directory to put the files in.
cd ~
mkdir dynudns
cd dynudns
vi dynu.sh
2. Move to dynu.sh and make the script. Copy and paste the following into the file and save it.
3. Make dynu.sh executable.
chmod 700 dynu.sh
4. Use a cron job to make the script run every 5 minutes.
crontab -e
copy and paste the below to the bottom of the crontab:
Dynu Custom IP Update URL
How to Update one domain name
- Non SSL: http://api.dynu.com/nic/update?hostname=example.dynu.com&password=PASSWORD
- SSL Format: https://api.dynu.com/nic/update?hostname=example.dynu.com&password=PASSWORD
Update all domains in your account
- Non SSL: http://api.dynu.com/nic/update?username=USERNAME&password=PASSWORD
- SSL Format: https://api.dynu.com/nic/update?username=USERNAME&password=PASSWORD
Update an alias
- Non SSL: http://api.dynu.com/nic/update?hostname=example.dynu.com&alias=Alias&password=PASSWORD
- SSL Format: https://api.dynu.com/nic/update?hostname=example.dynu.com&alias=Alias&password=PASSWORD