Gosh, thanks so much for putting this together, Tony! It's always gratifying to see user content.
May I offer a few suggestions?
1. To avoid doing everything as root and/or using 777 permissions everywhere, I create the /home/weewx directory and then make myself the owner:
sudo mkdir /home/weewx
sudo chown -R tkeffer:tkeffer /home/weewx
(substituting, of course, your user name for 'tkeffer').
At this point, almost everything can now be done without root privileges. The exception is that you may have to give yourself permission to access the /dev entry for the console. The easiest, permanent, way to do that is to add yourself to the group that owns the /dev entry, usually 'dialout':
sudo adduser tkeffer dialout
(again, substituting your user name for 'tkeffer').
2. In your section 'Install the serial cable' you left out the step of plugging the cable into the console!
3. Question: if you are going to put the generated files into /var/www/myserver/myweather, why would you need the directory /home/weewx/public_html at all? In any case, there is no need to create the latter manually --- it is automatically done by weewx.
4. If you follow my instructions #1 above, you will not need root privileges in the "start up weewx" section.
5. Finally, how about an actual link to the cable you used? There is a lot of confusion here, because some 3rd parties are beginning to offer cables, but they do not have a memory chip, while there are some online instructions that do have a chip.
Thanks for taking this on, Tony!
-tk
On Thu, Nov 29, 2012 at 7:18 PM, Tony Perkins
<tonyp...@gmail.com> wrote:
I've created a tutorial on getting a Davis Vantage Vue running with:
WeeWX
A non-logging serial cable
Ubuntu Linux
MySQL
Hopefully this can help some other folks out along the way!
Up to date tutorial link:
http://www.blueskybust.com/homewx.html
Original contents copied to this post... sorry for the poor formatting.
Getting your weather station online using a Davis Vantage Vue, a SLOweather serial cable, and WeeWX on Ubuntu Linux.
Updated 11/2012
I wanted to get a Davis Vantage Vue on the Internet. Since I already
have an Ubuntu Linux PC running 24 hours a day, this is where I chose to
send the data from the station. The Davis product to interface with a
PC, called WeatherLink, only contains software for Macs or Windows.
Essentially, you spend $100+ for a serial cable and software you throw
away.
Fortunately, community grown solutions exist to do this for much
cheaper. Through Google I found a homebew serial cable to interface
between the Davis console and the Ubuntu PC. This cable can be found by
googling for SLOweather and Davis serial cable. I got my for around
$30. There are two kinds for purchase, a serial cable, and a USB
interface. I have read that the serial interface is rock solid compared
to the USB interface, and since my PC has a serial port, I went with
that.
Steps to set up
Prerequisite steps:
- Your Davis Vantage weather station is operations and the console is displaying the weather data
- You have an Ubuntu Linux PC
- You have MySQL installed and running on Ubuntu
Disclaimer: I found that some things needed to be run as sudo to work
on Ubuntu, or that certains files couldn't be edited because I wasn't
logged in as 'weewx'. My quick fixes are to change the permissions of
those files to 777, and to run a lot of stuff as sudo. It works to get
things going. I know it's not the secure way to do things.
Install the serial cable:
- Turn off the console and remove the batteries so the power is
completely off to it. I don't know if this is required, but I did it.
- Hook the other end up to the Ubuntu PC with a serial port.
- Turn the console back on. Press 'Done' on it to get out of setup mode.
Test the connection to Ubuntu
Install the program minicom on Ubuntu:
sudo apt-get install minicom
Find your serial port identified in the device list with this command:
dmesg | grep ttyS
For me, this returned the information of:
[ 0.510838] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[ 0.532564] 00:08: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
The serial port device to use based on this is ttyS0.
Setup minicom for the test
sudo minicom -s
Go to the menu option Serial port setup.
Change setting of "Serial Device" to be what was in the previous step, with /dev/ prepended.
Example: /dev/ttyS0
Change setting of "Bps/Par/Bits" to:
Speed: 19200
Parity: None
Stopbits: 8-N-1
When done, save the config on the first menu with Save setup as dfl.
Test with minicom
Start minicom with:
sudo minicom
When it starts, type TEST in all capitals. You wont be seeing what you
are typing. If the word TEST is replied back, then it works.
Next, type LOOP in all caps. You should see gibberish characters come
across. This is the weather data being sent. Exit the command with
Ctrl-C.
You have now verified that the console is sending data to the Ubuntu PC.
Install WeeWx
WeeWx can decode the data and generate useful graphs and HTML pages with
it. It also stores the data in a MySQL database, and can post the data
to internet sites.
I downloaded the latest version using wget, which was weewx-2.0.2.tar.gz:
wget http://sourceforge.net/projects/weewx/files/weewx-2.0.2.tar.gz/download
Open the quick guide setup steps here. It's titled for Debian but works on Ubuntu:
http://www.weewx.com/docs/debian.htm
Follow the Prerequisite install steps as is.
Follow the Installing section as is.
For the "Configure" section: Edit the configuration file (I use vi, use what you like):
sudo chmod 777 /home/weewx/weewx.conf
vi /home/weewx/weewx.conf
Here are the changes I made to work with the SLOWeather serial cable and mysql:
Enable debugging. You may need it, so it doesn't hurt. You can turn it back to 0 after everything is working.
debug = 1
In the [Station] section:
location = (enter any text you want to describe your location)
latitude = (your stations latitude)
longitude = (your stations longitude)
altitude = (your stations altitude, foot) ( Example: altitude=654,foot )
station_type = Vantage (I think this was the default, but it's important to verify)
In the [Vantage] section:
port = (Use the /dev/ttyS0 entry you found when testing with mini com)
Ex: port = /dev/ttyS0
In the [StdReport] section:
HTML_ROOT = public_html
(Since I run a web server on the same Ubuntu box, I changed this from
public_html to a path like /var/www/myserver/myweather. You can just
keep it at public_html for initial testing and change it later if it
needs to go to another directory.)
In the [StdArchive] section:
Change the entries so it uses mysql:
archive_database = archive_mysql
stats_database = stats_mysql
record_generation = software
I needed to change record_generation to software in order for it to work
with the SLOweather serial cable. I think it's because the cable
doesn't store records itself.
Nothing else needs to change in the config file. I used the default
username and password listed in the [[archive_mysql]] and
[[stats_mysql]] sections of weewx / weewx.
Create the public_html directory
This didn't exist on my installation, so create it:
sudo mkdir /home/weewx/public_html
sudo chmod 777 /home/weewx/public_html
Create the MySQL database user of weewx
Start the mysql client:
mysql -u root -p
(Enter your root password for mysql. Can't help you here)
CREATE USER 'weewx'@'localhost' IDENTIFIED BY 'weewx.;
GRANT select, update, create, insert, delete on weewx.* to weewx@localhost;
GRANT select, update, create, insert, delete on stats.* to weewx@localhost;
quit
Start up weewx
sudo /home/weewx/bin/weewxd.py /home/weewx/weewx.conf
If things are working, you'll see data being printed to your window.
If nothing shows after 15 seconds or so, exit using Ctrl-C and then check the weewx debug output in the syslog:
grep weewx /var/log/syslog | more
If it's working ok too, do Ctrl-C to stop weewx.
Verify that mysql is logging data
Run this command again, but as the weewx user instead of root:
mysql -u weewx -p
(Enter password of weewx, which you probably created above as 'weewx')
use stats;
select * from outTemp;
You should see a record or two in the tables here, like this:
+------------+------+------------+------+------------+------------------+-------+
| dateTime | min | mintime | max | maxtime | sum | count |
+------------+------+------------+------+------------+------------------+-------+
| 1353736800 | 27.2 | 1353819100 | 28.8 | 1353822986 | 986.258918640156 | 35 |
| 1353823200 | 27.5 | 1353862112 | 30.6 | 1353830478 | 4726.0591897815 | 164 |
+------------+------+------------+------+------------+------------------+-------+
2 rows in set (0.00 sec)
If you don't see aything, then something isn't set up right with the mysql logging. Type quit and check the weewx syslog with:
grep weewx /var/log/syslog | more
If you saw a record, chances are the archive database is working too. From still in mysql:
use weewx;
select * from archive;
You should see one or more records listed. If you don.t, it may just be
that weewx wasn.t running for 5 minutes before we stopped the initial
test. If weewx is running later for 15+ minutes and you still see
nothing in here, check the weewx debug syslog:
grep weewx /var/log/syslog | more
type quit to exit mysql
You should also be seeing files generated in the public_html directory.
Open a few of the .html files with your web browser to check.
Add weewx as a service that starts up automatically
Now that it.s all working, let.s set it up so weewx starts on system
startup, and that it uses the familiar init.d start and stop functions.
sudo cp /home/weewx/start_scripts/Debian/weewx /etc/init.d/
sudo chmod +x /etc/init.d/weewx
sudo update-rc.d weewx defaults 98
Now you can start and stop weewx with:
sudo /etc/init.d/weewx start
sudo /etc/init.d/weewx stop
sudo /etc/init.d/weewx restart
Remember to turn off debugging with debug=0 in the weewx.conf file if you want, and then restart weewx.
That's it. Questions, comments, or improvements, send me an email at the permanent link at the top.
--
--
Tom Keffer
kef...@threefools.org+1 541-386-8891 (h)
+1 541-490-9507 (c)
Skype: tkeffer