Weather Station Hardware > Davis Instruments Weather Stations

Tutorial: Davis Station with Weewx, Ubuntu, MySQL and SLOWeather Serial Cable

(1/3) > >>

Hello everyone!  I've been using the information here at to get my own setup going, and I have the pleasure of making my first post.  I've created what I hope to be a bare bones, step by step tutorial on getting a Davis Vantage Vue running with:

A non-logging serial cable
Ubuntu Linux

Hopefully this can help some other folks out along the way to getting their station on the internet on the cheap.

Here is what will be the most up to date tutorial link:

Here are the copied contents of the tutorial... sorry for the lack of formatting:

Getting your weather station online using a Davis Vantage Vue, a SLOweather serial cable (found here at wxforum), 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 operational 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:

Open the quick guide setup steps here. It's titled for Debian but works on Ubuntu:

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;
Start up weewx
sudo /home/weewx/bin/ /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.

Nice work!! 

Having just gone through this last week, I can say it really is just that easy! (Except I used a davis logger).

Great job!

Welcome to the forum Tony!

Nice tutorial and great work, thanks for posting this for others to follow!

Have fun here on the forum!


My experience, is - of course - atypical.  Sigh.

I had to replace this step ...

--- Quote ---mysql -u root -p
(Enter your root password for mysql. Can't help you here)
--- End quote ---

With ...

--- Code: ---cd /opt/lampp/bin && ./mysql -u root -p
--- End code ---

Then I entered the following ...

--- Quote ---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;
--- End quote ---

But MySQL refused to recognize "quit" or "quit;" or "QUIT".

I had to Ctrl-C to break out but that resulted in an "Aborted" message, which
I take to mean that the CREATE USER & GRANT lines were lost.

Why would MySQL refuse the "quit" command and how might I solve that, please?



[0] Message Index

[#] Next page

Go to full version