INTRODUCTION  · PROGRAMS  · NEWS · HARDWARE · DOCUMENTS · DOWNLOAD · MISCELLANEOUS · LINKS  

Monitoring the weather with RISC OS

If, like me, you think it's fun to keep tabs on the weather, you might be pleased to discover the budget weather station kit sold by a firm in the USA. Dallas Semiconductor [1], of Texas, are well known as manufacturers of integrated circuits. One of their devices may be found in some Acorn models. Lift the lid on a Risc-PC for example, and towards the front from the processor slots you can locate a socketed 3-pin device that looks like a transistor. This is a DS2401 silicon serial number, that holds a unique 64-bit code, laser-engraved at the factory. This was chosen by Acorn to give a unique machine ID.

What's clever about this line of chips is the 1-wire bus that connects them to the rest of the system. This is a bi-directional serial data line, that allows communication between the host and many Dallas chips without the need for a clock line. ‘1-wire’ is a bit of a fib of course, as for any current to flow there has to be an ‘earth’ connexion as well. But even a power line is optional, as an internal capacitance gets charged up off the serial line, providing the required drive voltage.

Dallas now have a broad line of 1-wire devices [2], including switches, counters and analogue-to-digital converters. They even do a Java-based computer in a tiny stainless-steel canister (called an ‘iButton’), like a calculator battery, that holds secret keys and has its own encryption engine for tasks such as e-mail encoding or as an alternative to stamps in the US postal system.

1-wire WX station

Figure 1. The 1-wire weather station

The weather station kit is a bit of a departure from their normal range, mainly intended as a promotional item I think, rather than as a serious contender to the professional systems that cost a great deal more. You can buy it on-line at the iButton web site [3] for $79. They will add a charge for delivery (mine came by Federal Express) and HM Customs & Excise will want to charge you too (usually via the couriers).

As kits go this one doesn’t take much putting together. The main body of the weather station is a plastic moulding, split down the middle. The anemometer, with its three cups, projects from the top, and the wind vane from beneath – see Fig. 1. In the middle is a circular printed circuit board (PCB), on which are all the 1-wire chips – see Fig. 2. The 1-wire bus is connected through US-style (RJ11) telephone sockets, which are a smaller version of 10baseT ethernet sockets (RJ45). This is a little unfortunate for us (outside America) as the tools to make up cables are more expensive than those for our domestic telephone connectors; around £15 from Farnell [4] is the cheapest I've found.

WX station PCB

Figure 2. Weather station PCB and wind vane shaft.

How it works

The main components on the weather station PCB are:

To measure the temperature the computer instructs the DS1820 to start its temperature conversion cycle. Around one second later it will have the result. To measure wind speed the anemometer cups rotate a shaft, with two magnets mounted just above the PCB. These pass over a reed switch – a small glass capsule containing a pair of contacts that close when near to a magnet. Each time either magnet passes, the switch pulses the DS2423 counter – twice per rotation. By reading the count every few seconds the rate of shaft rotation, and consequently the wind speed, is determined.

The wind vane is a little more troublesome – but clever! In this case the shaft from the vane has a single magnet, that rides just below eight reed switches. Each reed switch connects a DS2401 silicon serial number (as used by Acorn) to the bus. The program scans the bus to see which chips are present, showing which of the reed switches are closed. If the magnet is about midway between two switches both will close, so in all sixteen compass points can be read.

The instructions for assembling the weather station are on the iButton site. You will need to drill holes through the 1-inch aluminium tube for a suitable U-bolt, to mount it to a mast. If the PCB is not already coated, you should apply a waterproof PCB varnish or lacquer. Silicone rubber sealant must be applied to the join in the weather station body, and around the tube entry, to keep out the rain.

A bus interface to connect to your computer’s RS232 port is supplied with the weather station. This has a 9-pin D connector, and plugs straight into later RISC OS models. Pre-A5000 machines will require a short lead between the interface and the computer, with pins 2, 4 and 8 joined at the computer end.

Installation

To get a representative measure of wind speed and direction the weather station needs to be mounted well away from obstructions. Ideally it should be on a mast away from buildings, but a mast on the house should be a reasonable compromise, so long as you get it as high as possible, and above the roof line.

Good quality cable should be used, especially for longer runs. Ethernet-style category 5 ‘twisted-pair’ cable is ideal, but telephone cable will often suffice. Be sure to secure the cable to your mast / walls with suitable ties and cleats, or it will make a lot of noise and even come off in a strong wind. If you have to go through a wall or window frame make a downwards loop in the cable, so that the approach to the hole is from below, to keep drips away. Use some silicone sealant around the hole.

Software

The main program supplied by Dallas, at the iButton site, is for MS Windows (95 or later). There is also a Java version and simple example programs in C for Linux, Mac, &c. My contribution is it take this C code, change the serial port code to talk to the block drivers, and bolt on a graphical interface, resembling the Windows application. The resulting program, !Oww (one-wire weather), can be found on the downloads page.

Before you run the program be sure to have the latest version of the block driver program, !SerialDev. Early versions may lead to a crash. Basic version-12 drivers are included in the application directory in case !SerialDev is absent.

!Oww

Figure 3. !Oww main window

Oww has three windows. The main display window is shown in Fig. 3. This is where the values read from the weather station are presented. The wind direction has a graphical display as a compass rose. Above this is the wind speed. Temperature is shown numerically and by a small ‘virtual’ bulb. For a more dramatic display you may set the weather station graphic to animate!

But you won’t get any results here until you've done some setting up. There are two further windows (available from theOww menu): ‘Setup’ and ‘Devices’. These are shown in Figs. 4 and 5. I will leave the fine detail of the setup window to the !Help file, but the important item to consider now is the serial port setup, in the ‘Block driver’ section.

Setup

Figure 4. Setup window

With the standard built-in serial port, Oww can use the ‘InternalPC’ driver. Older machines machines (pre-A5000) are not likely to work, because of the lower voltages provided on the serial port. The numeric entry only comes into play if your serial device has multiple ports.

Already Oww will have complained about a missing ‘devices’ file. This is because all 1-wire device numbers are unique, and I can't anticipate the IDs of the chips in your weather station. So you will have to access the ‘Devices’ dialogue. Now click ‘Search’ in the ‘devices’ window. If all is well the program will determine the IDs of your weather station chips, and the main window will correctly display temperature and wind speed – see Fig. 5. If not, check that the serial port configuration is correct, and that everything is properly connected.

Devices

Figure 5. !Oww devices setup

At this stage Oww will not know the IDs of all the wind vane switches. Begin ‘teaching’ with the wind vane pointing north – conventionally pointing away from the 1-inch tube, but it depends on how you finally mount the instrument. Press ‘Search’. The wind vane section of the devices window should read ‘Vane – Found – 1’, indicating that one switch ID has been determined. If the number is ‘2’ you should move the vane slightly and start again, as starting with the magnet over two switches might get them in the wrong order. Now rotate the vane slowly in a clockwise direction (setting the update time to ‘1’– see the ‘Setup’ window). The number should increment, and the vane displayed in the main window will also rotate. When you reach ‘8’ the procedure is complete, and you can click the ‘Save’ button. But do another full rotation to check that everything is in order. If after installation the wind vane direction is misaligned you can adjust the ‘Offset’ entry by ±8 compass points. You will have noticed that the procedure requires access to the weather station, so you must do this before permanent installation! It would probably be a good idea to make a safe back up of the ‘devices’ file inside the !Oww application directory, or at least lock it.

Once all is correctly set up the display window should produce sensible readings, such as in Fig. 3. After being mesmerized for a bit by the wind vane display twirling about, you could check the results in a log file.

Keeping a log

Oww can record your weather measurements to comma-separated-value (CSV) log files, which you can later use in spreadsheets, for example. Fig. 6 shows the wind speed (raspberry) and ambient temperature (dark blue) on a day in early December. You can log data to a single file or to a fresh file each day. In this mode !Oww will create a directory for the current month, into which it will write a file for the current day, changing to a new one at midnight.

WX plot

Figure 6. Some weather – wind speed and temperature

Passing it on

If you want to read live data into another program you may simply access the Oww$Logged system variable. This always holds the most recently recorded weather values, in the same format as a log line. Here is an example:

04/12/99 , 16:03:33 , 1.1,°C , 8.34, MPH, East , 90.0 , 4 , 8.1, mm

Applications may also pick up values broadcast in ThermIIC-style broadcast messages. So my TherMon application [5] can be used to plot the weather in real time. See Fig. 7 for an example screen grab. This also means that simple cgi programs can be used if your computer is running a web server, providing real-time weather data on a web page.

TherMon

Figure 7. TherMon screen grab

Rain gauge

You may have spotted some icons in the windows referring to a rain gauge. This is an optional extra from Dallas, for $49. As you can see from Fig. 8 it is another two-part plastic moulding. The top of the unit acts as a funnel to collect precipitation (yes, snow or hail works too, once it melts!).

rain gauge rain gauge

Figure 8. The rain gauge kit

Inside sits a tipping bucket – see close-up, Fig. 9. This pivots at the bottom, so that one side tips down, and the other side tips up to collect water from under the funnel. When this fills it becomes unbalanced, and eventually tips over. This side then empties, and the other side starts filling, so that the process repeats as long as it keeps raining. The bucket carries a small magnet, which sweeps past an interface PCB on each tip. The PCB contains another reed switch, connected to a counter. Reading this counter determines the number of tips – each corresponds to 0.01" of rainfall.

Tipping bucket

Figure 9. Tipping bucket and 1-wire counter

Assembly of the kit is even simpler than for the main weather station. For one thing we don’t have to keep water out! The PCB is encapsulated in black rubber. The tipping assembly is pushed together and bolted into position. You'll need some more cable and an RJ11 plug to connect link the bus to the second socket in the weather station. At the rain gauge this must be connected to the two wires protruding from the PCB. The recommended means for this is called a ‘Skotchlok’. These snap down onto the wires and squidge waterproof grease around the join. If you solder to the wires instead, be sure to provide your own waterproofing. To attach the gauge to a pole requires two ‘Jubilee’ clips.

To get an accurate 0.01" per tip you must adjust two screws that set the travel of the bucket. This takes a while, as you must let 1 US pint (i.e. 473.2 ml, or 16 US fluid ounces – a little over 16 imperial fluid ounces, and a lot less than a ‘real’ pint) dribble through in an hour. This corresponds to 1" of rainfall, and so should produce 100 tips. If the water runs through too quickly some will get lost during each tip, and the gauge will under-read. This is a known short-coming of tipping-bucket gauges.

Even if your system does not run for 24 hours a day the rain gauge should still accumulate the correct total precipitation. When the bus is powered-down the counter runs off a small battery on the PCB.

‘Devices’ revisited

As for the main instrument Oww needs to determine the serial number of the 1-wire counter in the rain gauge. So open the ‘Devices’ window and start the search process. Now the rain entry should also read ‘Found’. However, you must make sure Oww has not confused rain and wind – twirl the anemometer and tip the bucket. Click the swap button to swap them, if necessary.

With everything set up and the instrument installed, all you need is some rain. My colleagues thought me quite peculiar (more than usual) fervently hoping for rain. Once it comes you should find the reading on the main window incrementing in 0.01" (or 0.25-mm) steps. After some days of heavy rain the reading might be so big that you prefer to start again from zero. On the setup window there is a button to reset the reading.

Final words

That covers wind, temperature and rain measurements, telling you most you might want to know about the current weather. Dallas are now talking about a pressure add-on, which would provide some more predictive information. All we’d need then is a ‘virtual’ Michael Fish!

Lightning

If your area suffers from a lot of lightning you should take extra precautions when mounting electronic equipment high up. The weather station has some built-in protection (an electro-static discharge protection diode) but this might not be enough to guard against a really close strike. Useful advise, about lightning conductors and other schemes, was posted on the weather station discussion group [6], and this is now available from the main site [7].

At a glance

Webliography

[1] Dallas web site http://www.dalsemi.com/
[2] iButton web site http://www.ibutton.com/
[3] Weather station http://www.ibutton.com/weather/
[4] Farnell http://www.farnell.com/
[5] TherMon ../thermiic/thermon.html
[6] Weather list http://www.ibutton.com/weather/#forum
[7] Lightning protection  http://www.ibutton.com/weather/fdbk3.html
See also these articles in ‘Sensors’ magazine:
[8] Weather station http://www.sensorsmag.com/articles/0698/wir0698/main.shtml
[9]  Rain gauge http://www.sensorsmag.com/articles/1299/56_1299/main.shtml

  
SourceForge.net Logo    SUMMARY  · PROJECTS  · SIMON  · MELHUISH.INFO