WxMonitor: An Open Source Weather/Home Monitoring System
Overview - In my rural community, it is not possible to get
immediate local weather data. The nearest weather monitoring
stations are 30 miles away and only update at about 30
minute intervals. Commercial weather monitoring systems are too
expensive and not flexible (ie. hackable). To solve
this problem, I decided to design and build a weather monitoring
system with a goal of keeping the system flexible enough
so that it could be easily adapted and used as part of a home
monitoring/control system. I currently have a functioning
prototype that is composed of client and server components.
The server is composed of a PIC Micro-Controller and
sensors serially connected to a Debian Linux box. The server
contacts the PIC to request a new sample from one of the sensors at some
periodic interval. The PIC
takes a voltage sample from the specified sensor and returns it to the server. The server then does the
necessary calculations and filtering to update the value of the parameter.
The client prototype is running on
a SparcStation5 NetBSD machine. The client contacts the server via TCP/IP to request the
latest values of the monitored parameters at a configurable interval. The client logs the values in a
file and generates plots of the parameters via Gnuplot. The client then updates
a static html webpage.
The prototypes are a bit kludgy and probably not worth keeping around. My
plan is to rewrite the client and server using the Ruby OO scripting
language. The web page is still up in the air. Any of Perl, Python, PHP or
Ruby would be great for the web page.
Project Goal - The goal of the project is of course to get
others involved, and to provide a high quality, low cost, flexible, open source solution to the
problem.
Design Intent - My intent is to keep the design as
generic and flexible as possible, so that it can be easily adapted for
other uses. Some other uses that I currently have in mind:
- Home Monitoring/Control - A smaller Micro-Controller
such as the PIC16F84 and a DS18b20 temperature sensor (see below)
could be used to monitor the temperatures in individual rooms of a
home.
- CPU Loads - Using rsh/ssh to
execute a vmstat command to get the cpu load of a machine on a
network. Taking this a few steps further, a person could monitor
various state parameters of several machines on a
network, and have a client update a webpage enabling someone to
keep an eye on trends in your system throughout the day.
Software Overview
This is a very high level view of what I envision for the software components
of this system. Most of this is based on what I currently have prototyped
(hacked) and needs to be refactored.
- Server - The server will be written in Ruby. It will be
multi-threaded to allow for independent sampling frequencies. The server
will probably use Kalman filtering to eliminate noise from the sensors.
Client communication will be handled through TCP/IP, but this will probably
be configurable so that a person could use UDP/IP instead if they wanted.
Client/Server interactions will be logged. The server should be able to
dynamically re-read its config file by sending the process a signal.
Dynamic reconfiguration would be beneficial because it would allow a person to
experiment with the sampling rates and filter parameters. At this point I
have a somewhat solid design for the
main components of the server.
- Client - If I design and write the client it will also be
written in Ruby. If someone else does this, they are free to use whatever
they prefer. The
client will basically serve as a wrapper around GNU Octave or GNUPlot. It
will contact the server (TCP or UDP) with requests for updates at some
configurable interval and log the responses either in a file or database. Once the client
gets an update on the parameters that it is monitoring, it will perform
some action, which typically will be to generate plots for a webpage.
- Web Page - The webpage will at least display the current
plots of the monitored parameters. It would be nice if a person could
request the recorded parameters/plots/statistics of some day in the
past from a database.
Hardware Overview
This is a listing of the components that I used for the prototype. It has
been working well for quite a while. The server software will be generic enough so that the exact type of
micro-controller and sensors used will not matter. From
the viewpoint of the server, any micro-controller could be used. The PIC
16F877 seems to be a nice fit because it has on board A/D converters
and an on board USART. The construction
of the hardware and housing is simple and only requires bacic
tools. Here is the electrical schematic.
- PIC 16F877-20/P - This is an inexpensive and
robust micro-controller. See the datasheet
for exact specs. It costs approximately $10 USD. It is programmed using
assembler (See wx.asm).
- MPX4250AP - This is a linear atmospheric pressure
sensor. It costs approximately $20 USD. This sensor does not have the
required resolution for atmospheric pressure. I ordered the wrong sensor by
accident. The MPX4115 ($20 USD) should be used instead.
- HIH-3610 - This is a linear humidity sensor. It
costs about $20USD.
- DS18b20 - This is a digital temperature
sensor. It costs approximately $8 USD.
- MAX232 - This is a TTL to RS232 serial line
driver/converter. Very cheap but requires 5 tantalum capacitors. If you use
the MAX233 it has the capacitors built in.
- 7805 - This is a 5 Volt regulator that is used to provide
voltage for the Micro-Controller, sensors and a stable reference voltage for the A/D
converters.
- Additionals - Additional supplies are: circuit board, 20MHz
clock, phone wire, serial port connector, power supply and wire.
Help Wanted - This is a listing of some of the
areas that I could use help with. If anyone is interested, in these areas, or
if you want to get involved in some way, or if you have questions/feedback,
please feel free to
contact me.
- Cheaper Electronics - It would be nice to be able to bring the
price of the weather station down as much as possible. Any help with doing this
would be great.
- Client - If anyone would like to help develop the client
let me know. If you just want to play around with the server, you can open up
a TCP/IP connection to www.bkbryant.net port 8000 and do a read to get a string
with the servers latest values.
- Web Development - Web stuff is not my strong
point. It would be nice if the web front end was connected to a database
and could retrieve previous days measurements, display max/min of
parameters, etc.
- Wind Speed - I plan to add a sensor to measure wind speed. I
believe that it could be measured based on differential pressure. I think that
this would be easier than dealing with moving parts.
- Wind Direction - This can be measured by mounting a 360
degree potentiometer with a windvane attached to it. I have not been able to
find a decent 360 degree potentiometer.
- Lightning Detection - One easy way to do this is by using a cheap
AM receiver chip tuned to a dead portion of the AM band.