After surviving a windstorm that produced 40-60 mph winds on the boat I decided that I wanted a weather station to capture that data! The closest anemometer was very far away and definitely was not subjected to the same winds that I had in my marina. The following post is the steps I took to get my system up and running. It will probably be a work in progress because I like to tinker and fix things until they are broken.

For my overall design I had to make a decision right off the bat on whether I wanted to build the system hardware from the ground up or to use a complete commercial unit and focus on getting the code to work. After a lot of research I decided to go with the commercial unit. This is mainly to do with my current living situation and not having an easy way to get power and sensor readings from a remote sensor unit. In the future I would like to build the sensor array myself and get everything running off of solar, but that will be a ways off.

Working Weather Station

Real Time Update and Graphing

Step 1: Gather parts

Ambient Weather WS-2080

This weather station is not being sold for the $86 that I got it for and may not be the best option anymore. The Ambient Weather WS-2095 is supposed to be same / similar and may be better. It does have the sensors integrated together and not wired separately so that will be an issue if you decide to connect them directly to a custom pcb or a Raspberry Pi instead of using the base station.

Raspberry Pi 2

For the Raspberry Pi I decided to go with the Raspberry Pi 2 Model B. It has plenty of power and has the required number of USB ports to interface with WiFi dongle and the weather base station. The Rpi 3 is definitely an option now since it has built in WiFi capabilities. The link above is a kit, you can individually source the components, prices may vary.

8+ GB Micro SD Card (Class 10)

I used the card that came in the kit, but I will probably upgrade this soon. I made it work as described below, but it would have saved me some time and frustration if I had bought a larger SD Card right away.

Step 1.5 : Download Software

Depending on size of SD Card and success setting everything up you may want re-flash and just put Rasbian on the card right away.

Rasbian Jessie Lite
SDFormatter
Win32DiskImager

Step 2: Some Assembly Required

Once everything arrived it was really easy to get it together. The weather station went together simply by bolting and screwing the sensors to the mounting bracket. I ended up putting the assembled sensor array on my fence temporarily while I got everything working together. For the Pi, it fit right into the case and all the ports lined up. I inserted the 8 GB SD Card from the kit that was already loaded with NOOBS and booted it up. In the middle of updating and downloading the required software to interface with the weather station I ran out of room on the SD Card! This really surprised me considering I had barely started and I didn't have a database full of data. I decided to get and install Rasbian Jessie Lite. After downloading I figured how to clear and then flash the SD Card using SDFormatter and Win32DiskImager. I had to use the SDFormatter because Windows 7 was not seeing the SD Card as 8 GB. It only said that there was 400 MB remaining on the card. Once it was reformatted I used Win32DiskImager to reflash the card with my new Rasbian Lite image. These tools were pretty self explanatory and had an easy GUI to navigate.

Step 3: Update and Install

So now I have the SD Card freshly flashed with Rasbian Lite and installed in the Pi. I connect to it and log in using the default Username: pi Password: raspberry. The following should get the Pi up to date and ready to install the remaining software.

apt-get update  
apt-get upgrade  
apt-get dist-upgrade

This is directly from the Weewx site and are required dependencies:

apt-get install python-configobj  
apt-get install python-cheetah  
apt-get install python-imaging

These are also required if hardware is serial or USB:

apt-get install python-usb

If you are going to be using MySQL also install the following: Remember the root MySQL Password when you set it.

apt-get install mysql-client mysql-server  
apt-get install python-mysqldb

Also required if you are on Raspbian and planning on using FTP:

apt-get install ftp

These are optional for extended almanac information:

apt-get install python-dev  
apt-get install python-pip  
pip install pyephem

We need to add a Weewx user. You can take all the defaults when prompted:

adduser weewx

Create the MySQL Database that we are going to use:

mysql -u root -p  
CREATE DATABASE weewx;  
use weewx;  
CREATE USER 'weewx'@'localhost' IDENTIFIED BY 'putyourpasswordhere';  
GRANT select, update, create, delete, insert, drop ON weewx.\* TO weewx@localhost;  
FLUSH PRIVILEGES;  
quit;

Now go to Weewx and find out what the newest version is. Once you find the url to the newest version:

cd /home/weewx  
wget http://weewx.com/downloads/weewx-3.5.0.tar.gz

Unzip and install:

tar xvfz weewx-X.Y.Z.tar.gz  
cd weewx-3.5.0  
./setup.py build  
./setup.py install

During the actual install it will ask for some information about the station. Google maps is helpful to find your lat and long.
Before we start the program we need to edit the weewx.conf file.

nano weewx.conf

It is important to change line 10 so that it reads "database = archive_mysql" Find this section and modify it as needed to match your MySQL install:

##############################################################################

#   This section binds a data store to a database.

[DataBindings]

[[wx_binding]]
    # The database must match one of the sections in [Databases].
    # This is likely to be the only option you would want to change.
    database = archive_mysql
    # The name of the table within the database
    table_name = archive
    # The manager handles aggregation of data for historical summaries
    manager = weewx.wxmanager.WXDaySummaryManager
    # The schema defines the structure of the database.
    # It is *only* used when the database is created.
    schema = schemas.wview.schema

##############################################################################


##############################################################################

# This section defines various databases.

[Databases]

# A SQLite database is simply a single file  
[\[archive\_sqlite\]\]  
database\_name = weewx.sdb  
database\_type = SQLite

# MySQL  
[\[archive\_mysql\]\]  
database\_name = weewx  
database\_type = MySQL



##############################################################################

#This section defines defaults for the different types of databases.

[DatabaseTypes]

# Defaults for SQLite databases  
[[SQLite]]  
driver = weedb.sqlite  
# Directory in which the database files are located  SQLITE\_ROOT = %(WEEWX\_ROOT)s/archive

# Defaults for MySQL databases  
[[MySQL]]  
driver = weedb.mysql  
# The host where the database is located  
host = localhost  
# The user name for logging in to the host  
user = weewx  
# The password for the user name  
password = weewx  
##############################################################################

We are going to want this to run everytime the Pi turns on so lets daemonize this:

cd /home/weewx  
cp util/init.d/weewx.debian /etc/init.d/weewx  
chmod +x /etc/init.d/weewx  
update-rc.d weewx defaults 98

Prior to running it for the first time, I modified the weewx.conf and changed "debug = 0" to "debug = 1" so that I would have more verbose output and better error messages. Before we run it for the first time, it is a good idea to open up another terminal to the Pi and watch the log file as it starts. So in a new terminal on the Pi run:

sudo tail -f /var/log/syslog

In the first terminal run:

service weewx start

If all goes well it should be running with no errors. In roughly 5 minutes it will create a report and put it in /home/weewx/public_html

You view or move these reports from there. If you just want local access to them you can install a webserver on the Pi.

apt-get update  
apt-get install nginx  
cd /var/www/html
ln -s /home/weewx/public_html weather

In a web browser navigate to http://yourraspberrypiIPaddress/weather

Working default example

A much nicer and dynamic display: Dynamic display uses Mesowx . I will be doing a follow on post to explain the process I used to get that going.  

The following resources were extremely helpful in getting this project working and creating this guide.
WEEWX