Christchurch panorama
John's Weather-Watcher
christchurch, new  zealand

Building the Weather Station

Part 2 - Programming the Weather Station

Programming the weather station has been a major undertaking. It is divided into 3 different sections and involves 6 different programming languages, all of which, thankfully, I am well versed in.

  • Programming the Arduino: Language C.
  • Programming the receiver: Language Delphi (Object Pascal).
  • Programming the website: Languages HTML, Javascript, JQuery, PHP. (and CSS for formatting and layout)

Programming the Arduino.

The first task was to set up interrupts to read the rain bucket and the speed of the wind. Every few milliseconds the microcontroller stops what it's doing and reads those two ports, then goes back to where it left off.

rain gauge

The rain bucket is known as a "tipping bucket" rain gauge. If you look at the image you'll see the two tipping buckets which are on a pivot. Rain comes into the gauge through a hole at the top and drips into the bucket in its top position. As soon as it has received 0.2mm of rain its weight causes it to drop down, and as it does so a magnet mounted on the pivot point goes past a magnetic reed switch closing its contacts momentarily, thus sending a "pulse" to the Arduino. When the bucket hits the bottom the other bucket is positioned at the top ready for the next raindrops. The bucket we've read from empties its water through a drain hole underneath.

anemometer

The anemometer works in a similar way - there are two reed switches in the housing which trigger a pulse as the anemometer spins round. One complete revolution made in one second = 2.4kmh.

The code can get quite complicated because we're counting the number of revolutions over time. Here's a short snippet of code so you'll see what I mean

programming code

The rest of the program is concerned with reading the temperature and humidity inside and outside, and the barometric pressure. These are very straightforward - they're just raw readings.

When all the data is gathered (and this all happens once per second) it is ready to be transmitted to the PC, one item each time round the (one second) loop.

In the next section we'll look at programming the receiver - the PC

prev buttonnext buttonhome button