Taking Measurements

Measurements are taken from the weather sensors by hardware that you don't see. Measurements often require supplying power and control signals to the sensor, measuring its response, and converting it into a useful reading.

All sensors are wired to a "datalogger", which is located nearby. The datalogger runs a small program which automatically operates and collects data from each of the sensors. It can store several days of readings in its on-board memory.

A computer, located at the bottom of the mountain, is used to communicate with the datalogger over a serial link. The computer collects and stores weather information, and makes the information available in the form of web pages.

At the Sensors


Function: A datalogger captures analog information from sensors, converts it to a digital form, and stores it in an internal memory. The information can then be sent to a personal computer via a serial data port.

The datalogger contains a small microprocessor which runs a locally written program. It has the capability, under program control, to periodically wake-up, stimulate and control various sensors, convert analog-to-digital measurements, perform calculations and format the collected measurements into a data record.

Manufacturer / Model: Campbell Scientific / CR10X datalogger



The source code of the datalogger program looks like:

Power: Twelve (12) Volts DC, provided by multiple diode-isolated sources: In our case, a line-powered AC power supply and some rechargeable batteries for back-up. The datalogger should operate until the power rail drops below 9.6 Volts.

Attempts to rely on photovoltaic cells were unsuccessful due to the limited amount of solar energy available due to clouds and rime. Solar input is limited by the shortened daylight hours of winter, cloud cover, and the cells being obscured by a lingering rime build-up during the relatively brief periods of sunlight which follow storms.

A second challenge of photovoltaics and rechargeable batteries is the delay to recharge depleted batteries back up to an operational voltage. A smart power management scheme would allow immediate operation from sunlight-only, while the batteries are slowly recharging.

- Sensors - listed with specific sensor
- Serial data - Proprietary ribbon cable to RS-232 interface

9-pin to RS-232 DCE Interface

Function: This unit converts the datalogger's serial port to a standard RS-232 serial interface.

Manufacturer / Model: Campbell Scientific Inc., (Logan, Utah) / SC932(C)

- Serial data - Proprietary ribbon cable to datalogger
- Serial data - Direct connection to the modem

- Provided via the datalogger interface cable

Short haul modem

Function: The short haul modem makes it possible to operate a serial data link over a much longer distance than would be possible using a standard RS-232 serial connection.

This modem interfaces to an RS-232 serial port. It uses balanced line drivers and receivers and two twisted-pair wire connections to communicate with an identical unit at the other end of the line. At the far end, the other modem converts the signaling back to the RS-232 standard.

Manufacturer / Model: RAD Data Communications / SRM-5A & SRM-5A (pdf)

Distributor / Model: Campbell Scientific, Inc. (Logan, Utah) / SRM-5A

Serial data connections:
- To RS-232 interface - direct connection
- To the downhill line:

      Terminal  2-pair line to panel   25-pair line (to bottom)
        XMT +     Yellow Black Red Green          .
        XMT -     Yellow Black Red Green          .
        RCV +     Yellow Black Red Green          .
        RCV -     Yellow Black Red Green          .

- Derived from RS-232 interface connection

Additional Notes:
- A 25-pair telephone grade cable was used to provide in-the-ground copper wire connections between the datalogger and computer. This installation included surge suppressors at both ends of the line to minimize the potential for damage due to lightning.

At the Computer

Short haul modem

Function: Same as the modem at the datalogger.

Manufacturer / Model: Same as the modem at the datalogger.

Serial data connections:
- To the uphill line -> datalogger end

      Terminal  2-pair line to panel   25-pair line (from top)
        XMT +     Green                   .
        XMT -     Red                     .
        RCV +     Yellow                  .
        RCV -     Black                   .
- To computer - Directly onto the computer's 25-pin COM[1,2] RS-232 serial port connector

- Derived from serial data line from computer


Function: To collect, re-format, store and make use of the weather sensor data which is measured.

Operating system: Windows XP



Power: Via an Uninterruptible Power Supply (UPS)


Many programs are run on this computer to support the weather station. The following are the programs used to process the raw data to the point where the observations are recorded in daily summary files.

This program was provided by the manufacturer of the datalogger. It runs continuously. Every minute it connects to the datalogger via a serial link and downloads its most recent observations to a local file named "c:\PC208W\cr10x1.dat". This file's contents look like:

This program was written locally, using the ANSI "C" programming language. It runs continuously. Every minute it wakes-up, reads a "configuration file" ("c:\wx\sw\cron_config.txt") and causes other programs to be executed according to the schedule contained in the configuration file.

"cron" is similar to the Unix cron program, except that its scheduling resolution is to the second instead of the minute. While "sleeping" it adds very little load to the CPU.

The configuration file's contents look like:

This program was written locally, using the ANSI "C" programming language. It is executed every four minutes by "cron".

This program reads the raw data file created by PC208W, re-formats the information, and appends it to daily data files. The file for August 2, 2001 would be named "c:\wx\data\2001\08\02.txt". With an entry for every minute starting at midnight, it would look like:

Lessons Learned

As you have seen, there is a collection of hardware and a series of events which must work together in order to get readings from the sensors stored into the computer. Making this all work together is not necessarily simple.

Writing your own programs
When you write your own program (as opposed to buying one) you become responsible for its performance. This can (and should) be intimidating, since other people will expect good things from your program.

A great advantage of writing your own program is that you know how it works, what it can do, and you can fix and improve it as much as you like. If you didn't know how to program well before you started, you will by the time you have a good working program.

Data Collisions
If a program is trying to write to a file at the same time another program is trying to read the same file, the second program may get confused. It is better that you find ways to keep this from happening.

It's preferrable if all activities are coordinated by a single program. Each activity is done in order and without conflicts. Alternatively, see if both programs can be coordinated via a common timing reference. If you cannot control both programs, at least try to control one program so that it keeps out of the way of the other.

Data & Program Back-up
Just like weather sensors which may wear-out, the disc drive in your computer may wear-out. Imagine what would happen if all of your programs and weather data were stored on just that one drive.

Consider copying your program source code, configuration files, and historical weather data to another place for safe storage. Creating a CD or floppy discs with all of these files would be convenient insurance if you ever have to restore your system. This would also facilitate sharing your information with others.

Change Happens
Just when you think everything is working perfectly, something will change. This is when your troubleshooting skills get a work-out. Here are some types of problems we have encountered. You are invited to imagine the original symptoms and what it took to find and fix the problems:

With practice you learn what to check to quickly identify these problems. Each of these events is a potential learning experience, and a challenge to see if you can find ways to prevent them from affecting you in the future.