Weatherstation
The photos below show my home designed and built weather station. I wanted to build a weatherstation, but let me state up-front that it is no better or cheaper than commercial units. It has taken me over a year to design and build it. Ready-made commercial units can be purchased at reasonable prices, but it is much more fun to build it yourself and learn the principles of weather measurement first hand.
![]() |
![]() |
|---|
The objectives were:
- Unit must be capable of continuous weather monitoring
- Upload of acquired of data to a PC
- Capable of buffering data for a reasonable period before upload to PC is necessary (ie not dependant on a PC being switched on all the time)
- Reasonable accuracy
- Monitor a wide range of inputs
- All items under my control, so I can expand the number of items monitored in the future. With commercial units it is generally not possible to change sampling parameters, and it is harder to manipulate the uploaded data.
- Data stored on PC in standard csv file for loading into Excel and drawing graphs, etc.
The installation consists of the monitoring sensors and transmitter; receiver base station, and software to upload data to the PC.
Transmitter |
Receiver |
Uploaded data |
|---|---|---|
| Circuit Diagram PICAXE code |
Example csv file (Contact me if you want the VB.NET code) |
I am not providing real-time online data. There are plenty of good weatherstations on the web already doing that, with much better accuracy than my setup. I may update this page with some graphs after a period of data acquisition.
I will now discuss each of the sensors, general operation, limitations and gotchas for the information of anyone wishing to construct a similar weatherstation themselves. This is by no means the only way of constructing a weatherstation; this is simply the way I constructed my weatherstation.
General Operation
Transmitter:
repeat forever
for i = 1 to 10 (minutes)
for j = 1 to 6 (10 second intervals)
for k = 1 to 4 (2.5 second intervals)
Sleep for ~ 2.3 seconds
Read and reset Rainfall and Lightning counter latches
Read wind speed - update maximum and average wind speeds
next k
Transmit a sync pulse to the Receiver
next j
Read temperature, humidity, pressure, ion, solar, wind direction, battery voltage
Transmit all data to receiver
next i
Receiver:
Start
if Upload_switch then Upload data to PC
if Initialise_switch then reset buffer variables
repeat
forever
if data_received then
if sync_pulse increment sync_pulse_counter
else if data_record then receive data and store in EEROM
else
update_LCD_display
PICAXE Microprocessors
I am using the PICAXE micros programmable with Basic code, rather than assembly language on the PIC micros. The transmitter uses a PIC28X, and there is a PIC18X in the receiver base station. There are some limitations using PICAXE code, but programming is quick and easy. The code is inefficient, and almost all 2048 bytes are used in the receiver base station program. The biggest limitation I struck is when using the serin command to read data from the 433 MHz transmitter. The serin command must receive data before the program continues - so if there is no data the program hangs, and is not interruptible. This causes programming difficulties which I had to work around. On the positive side, with the PICAXE Basic IDE I was writing code that was working first time and required little debugging. I changed my mind several times and made large changes to operation and functionality in a short time.

Transmitter - from left the 433 MHz transmitter (screened), temperature and humidity sensors,
pressure sensor (middle), toroid of 300 kHz lightning receiver on right
Base Station
Every 10 minutes the base station receives 15 bytes of data from the transmitter (including 2 unused data bytes). The base station adds internal temperature and date/time stamp from the internal RTC, resulting in 22 bytes of data per sample. As I'm using a 24LC256 32 kB x 8 EEPROM with page writes I need to align samples to a page boundary to avoid unnecessary complication, so 32 bytes of EEPROM are used for each sample. this still allows storage of 1000 samples, and as there are 144 x 10 minute samples per day, the base station can run for nearly 1 week before it is necessary to upload the data to the PC. The transmitter send data at "approximately" 10 minute intervals (it will vary based on a number of factors). The base station adds a time stamp from the internal real time clock (RTC) which should be accurate to within a few seconds. In an upload test, it took 80 seconds to upload 232 samples to the PC (at 2400 baud, which is about as fast as the PICAXE will reliably transfer data).

In operation the base station displays the most important weather information cycling through four displays:
- Display number of uploaded samples (0 -1000), sync pulse counter (minutes, 0 - 9), current date and time
- External and internal temperature (there is a temperature sensor in the base station)
- Humidity and pressure
- Wind speed, direction and rainfall
The cycling period is variable. This is because the base station continuously checks for data from the transmitter. Updating the display takes 120 - 150 ms. The code then checks for data from the transmitter, but because the serin command hangs the code until a data byte is received, a $99 byte must be received either through a sync pulse (once a minute) or randomly. The display will not refresh in less than 4 seconds, but if a $99 byte is not received randomly for a while it can be longer before the display moves on to the next one. This is a nuisance but I was unable to find a way round this with the PICAXE.
PC Upload Software
I used a simple program which I wrote in Visual Studio 2005. Note that earlier versions of Visual Studio did not have a serial port object - options were to use the VB6 com port object (which worked okay), or write your own (there was some example code on MSDN). In VS 2005 it is very easy to fetch data from the serial port. I use very simple one byte handshaking to initiate data transfer. Once all the data has been uploaded another handshake confirms data receipt, and data is deleted from the base station (actually the location pointers are reset). The PC software reformats the data and writes it out to a csv file for analysis in Excel. It is very easy to manipulate data and draw pretty graphs in Excel.

433 MHz Transmitter
I used a pair from Jaycar (Product numbers ZW3100, ZW3102), which run at 433.92 MHz. The transmitter runs at 3 V, 10 mA, and the receiver at 5V, 3 mA. Maximum data rate is 10 kbps, but I followed recommendations from another PICAXE datasheet (Greenhouse monitor) and ran the the transmitter at 1200 bps. You can't just send a data byte - a period of synchronisation is required. I actually send 12 bytes to transmit 3 bytes, with a prior period of transmitting several data records so that the PLL in the receiver has time to synch. Before I understood this I was not receiving the same data as I was sending! The method (recommended by the PICAXE application datasheet) seems to be reliable. So to send 3 bytes, b1, b2, b3, the transmission string is:
serout TXD, T1200,($AA, $AA, $AA, $AA, $00, $00, $99, $55, rec, b1, b2, b3)
At the base station I wait for a $99, check to see if the next byte is $55, and if so get the record type (0 = synchronisation pulse, 1 - 5 = data records) and load in the the 3 bytes of data. One data record like this takes 100 ms to transmit, and I then wait another 100 ms for the base station to do its stuff and store the data in EEPROM before sending the next data record. This seems reliable, and range is very good (better than WiFi range or Bluetooth within my house).
Sensors
Data
|
Sensor
|
Accuracy / Resolution / Acquisition time / Sampling
|
|---|---|---|
Temperature |
DS18B20 |
±0.5 Celcius over -10 to +85° Celcius, ±2 Celcius over -55 to +125° Celcius, |
Humidity |
Humidel HS1101 |
±2% over 10% - 90% humidity range at 25 Celcius, 0.34 pF/%RH Capacitive sensor 160 - 200 pF; 10 minute sample |
Pressure |
MPXAZ4115A |
15 - 115 kPa, output 3.8 V - 4.2 V over 950 - 1050 mBa, resolution 1 mBar; 10 minute sample, resolution 1 mBar (0.1 kPa) |
Rainfall |
La Crosse WSTX5 |
0.2 mm per tip, checked every 2.5 seconds |
Wind speed |
La Crosse WSTX20 |
5 - 100 km/hr, sampled every 2.5 seconds for maximum gust, averaged over 10 minutes for average wind speed, resolution 1 km/hr |
Wind direction |
La Crosse WSTX20 |
16 points, 22.5° resolution. Wind direction is that taken at 10 minute sampling interval |
Lightning flashes |
300 kHz receiver |
1 flash, checked for every 2.5 seconds |
Ion emf |
FET gate |
8-bit voltage level, sampled every 10 minutes |
Solar radiation |
Dual photodiodes |
Sunshine hours checked for every 10 minutes by difference in light level between two photodiodes |
Battery level |
Resistor divider |
8-bit voltage level |
Temperature
I used the Dallas Semiconductor 1-wire temperature sensor DS18B20. You can get these from Digikey for about US$5, or RS Components for about NZ$12. I wanted accuracy better than 1 degree Celcius. When using the PICAXE readtemp12 command, the temperature is returned with 12 bits, the last four bits being 1/2, 1/4, 1/8 and 1/16th of a degree. The sensor is not this accurate, but is specified for ±0.5 Celcius over -10 to +85° Celcius which is good enough for me. It is ±2 Celcius over -55 to +125° Celcius but the weather isn't that extreme even here in Wellington! The temperature error is less than 1/4 of a degree over 0 to 30 Celcius which is the range it will normally be operating over. Operating current is almost negligible, and it is easy to use but note that a 5 k pull-up resistor is required on the data line. If you forget this resistor it doesn't work! Conversion time is long, 750 ms at 12-bit resolution, but this is not a problem for me. Temperature measurement is quick, easy, and accurate.

Humidity
After the ease of measuring temperature I was surprised at how difficult it was to find cheap, easy-to-use sensors for other inputs. I used the Humidel HS1101, available from Digikey for about US$12. This is a capacitive sensor, varying from about 160 pF to 200 pF, temperature compensated and reasonably linear - quoted accuracy is ±2% over 10% - 90% humidity range at 25 Celcius. I used the recommended 555 oscillator circuit to create an oscillator varying from about 6 - 7.3 kHz, which I then fed into a 4046 PLL to create a voltage varying between 2.53 - 4.03 Volts. With 8-bit ADC resolution, RH = (205 - adc_number) * 1.32. ie 50% humidity is 180 pF, 3.25 Volts = 166, so RH = (205 - 166)*1.32 = 50. I calibrated the oscillator and PLL using fixed capacitors - I have no other easy means of measuring and/or generating humidity to test the sensor. I am happy if the overall accuracy is ±5%.


Atmospheric Pressure
There must be cheap, accurate pressure sensors covering the atmospheric pressure range of interest, ie 950 - 1050 mBar or 95 - 105 kPa. The cheap weatherstations have digital readouts display to 0.1 mBar. I'd love to know what sensor they use. After some searching I used the Digikey MPXAZ4115. This is designed for automotive use and is easy to use, but covers the range 15 - 115 kPa. This means that the voltage varies from 3.8 V - 4.2 Volts over the range of interest, or Vo = Vs * (0.009.P - 0.095) or about 45.9 mV/kPa or 4.5 mV per mBar. With 10 bit ADC (about 5 mV ultimate resolution) the resolution is about 1 mBar per digit. Ideally I wanted better than 1 mBar resolution but I don't have it. The sensor does have linear output and is temperature compensated over normal operating range. I use the formula Pressure = adc_number *.1.087 + 118 to get the pressure. Note that multiplication in the PICAXE by 1.087 is done by (1 + 8/100 + 7/1000) to avoid 16-bit overflow. I adjusted the constant value of 118 to calibrate my sensor with other weatherstations in my area. So far is seems to be accurate ±1 mBar over the range 990 - 1020 mBar. I will monitor and adjust if necessary. It is sensitive to supply voltage variations. It does gobble up 7 mA when operating, so I use a small pFET to switch it on only for a few hundred ms once every 10 minutes to read the output.


Rainfall
![]() |
I decided it was too hard to construct a simple tipping bucket rainfall meter, so I bought a ready-made plastic one from Met Instruments. The La Crosse WSTX5 isery easy to use - simply count the number of times the switch is activated (I bypassed the wireless transmitter that comes with the unit, using just the reed switch). Accuracy is 0.2 mm per tip. The switch is an off-on-off type. As the PICAXE goes to sleep between sampling, I decided to use the switch to clock a latch (using preset input, not the clock input). The latch is read and cleared every 2.5 seconds. This means that it is possible to miss a count if the rainfall exceeds 0.2 mm in 2.5 seconds, or 4.8 mm per minute (or 288 mm per hour). This is extremely heavy rain and it seems unlikely that this will be a limitation. |
|---|

Wind Speed and Direction
![]() |
Again, after some investigation I decided that my construction skills would not result in a reliable instrument. I purchased a La Crosse WSTX20, (eg Scientific Sales in NZ) which I pulled apart to extract the speed pulse, and 4 LEDs for wind direction. Internally the La Crosse unit works on 2 Volts, so simple level shifters are necessary to raise to the 5 Volts of the transmitter unit. After some experimentation I found that the pulse width for wind speed is almost exaclty 1/wind speed, ie a 200 ms pulse is 5 km/hr. How did I work this out? I went for a drive in the car with the unit mounted outside the window, and used the micro to read the pulse width and report the width as I drove at various speeds round the roads of Wellington! The pulse width is read using the pulsein PICAXE command, and is in units of 10 µs. 100 km/hr wind results in a pulse width of 10 ms, which is a count of 1,000. 5 km/hr is a count of 20,000. In order to calculate a reciprocal I use 50,000/pulse_width * 2, ignoring pulse widths under 500 (ie 200 km/hr) or over 200,000 (under 5 km/hr, spurious results occur for very slow wind speeds). So 12 km/hr wind has a pulse width of 83 ms, which is a count of 8,333. 50,000/8,333 * 2 = 12. No wind causes a timeout at 0.65 seconds for the pulsein command. I am interested in peak wind speed, so I read the wind speed every 2.5 seconds. I store the peak, and average the 240 samples over 10 minutes for the average wind speed. I have no other easy method of confirming accuracy of the wind speed device. I am not sure of the accuracy or reliability in winds over 100 km/hr, which certainly can and do occur regularly in my location in Wellington. |
|---|
The WSTX20 has 4 LEDs with a photodiode, which it uses to obtain a 4-bit gray code for wind direction. That is 16 points of the compass, or 22.5° accuracy. This is fine for me, in fact 8 directions would have been acceptable. To read the direction it is necessary to successively enable each LED, and check the output of the photodiode. In the code I wait 50 ms after switching the LED on, so the reading takes 200 ms. The Gray coding ensures that any movement of the vane causes only a 1-bit error - with standard binary coding any movement error would be highly significant. The LEDs do gobble up the current, up to 20 mA (the current varies to keep the LED output constant inside the WSTX20 mounting, as the LEDs are at different distances from the photodiode). However, the current consumption is not significant as the sampling is over in a few hundred ms.
I am reading wind direction once every 10 minutes. Proper determination of wind speed and direction requires vector addition of the instantaneous wind speed and direction averaged over the sampling period. I am not going to do this sort of maths in the PICAXE, nor am I going to store and transmit all this information to the base station and the PC to do the calculation in Excel. I have implemented a compromise.
In the circuit diagram you will notice I use a MUX to switch on each diode, which I share with multiplexing other analog inputs.

Lightning flashes
After the standard weather measurements, I wanted to include something different. We don't get much lightning in Wellington, so to capture the occasional flash I use a simple broad-tuned 300 kHz receiver that I found on the web. This drives a monostable, and I further shape the pulse with a second 555 set up as a 1-second one-shot. This means that multiple quick flashes or interference from neighbours cars will not generate multiple pulses. One pulse will be latched, and this is checked and cleared every 2.5 seconds. Two lightning flashes in less than 2.5 seconds will be missed - this would be an unusual situation. The current consumption of the receiver is about 0.2 mA. I don't have any way to measure the sensitivity of the unit, so I can't say over what range I will capture lightning flashes - 1 km, 10 km, 50 km? I will update results when we actually have a lightning storm (we only get one or two a year in my location).
Ion emf
This simple FET circuit has a voltage that will vary according to surrounding electric field. It will respond to both positive and negative charges. I am not quite sure what this measures, but if a UFO flies over my house I expect it to respond appropriately (it is well known that UFO's have high surrounding emf fields, but they'll have to hover over my house for about 10 minutes to ensure I get a sample)). I also expect it to register disturbances during thunder storms and will monitor this to see if it is a useful weather measurement parameter.
Solar Radiation
I wanted to measure sunshine hours, and proper solar irradiance sensors are very expensive. I also wanted to measure UV radiation, but have yet to find a cheap and simple way to do it - I gather I could use a photodiode with UV filter, but have no idea how to calibrate it. To measure sunshine hours I have two photodiodes - one facing north (the sun) and the other facing south. I simply measure the output from the two photodiodes, and when there is sufficient difference between the two outputs I determine that the sun is shining. When cloud cover somes in the output of the two photodiodes is approximately the same. I am still experimenting with this but in practice it seems to work reasonably well until late afternoon when the sun goes far to the west. Ideally, it should track the sun (how can I do this simply?).
I am only checking the output once every 10 minutes, it is not a continuous measurement like the wind. I may modify this in future if it seems to be a reliable measurement technique throughout the year.
Battery Voltage and Power Supply
This simply measures the voltage of the NiMH battery pack in the transmitter unit. In operation the current drain is around 5 mA, 24 hours a day. During daylight hours the small solar panel charges the batteries. I am using 5 x 1.3 V AAA NiMH batteries, with a low drop out regulator to keep the voltage above 5 volts (the PICAXE will operature down to 4 Volts, but the pressure sensor is highly voltage sensitive so voltage drops below 5 V will compromise accuracy). The L4931 LDO regulator has a quiescent current of only 0.5 mA - I got caught out first with a 1 Amp regulator which had a constant current drain of 10 mA! No good for battery operated equipment.

The transmitter is powered by a 12 Volt, 125 mA (about 1.5 Watt) solar panel. A constant current regulator limits charging current to the batteries to about 100 mA. There is a constant discharge of about 5 mA on the batteries - or about 120 mAhr per day. As the AAA batteries are rated at 900 mAhr, it should be able to run for 5 - 7 days in really bad weather! The pressure sensor and wind direction LEDs have the highest current drain, and they are only turned on when required. The 433 MHz transmitter also uses 10 mA when operating, and is also switched on and off with a pFET to conserve power.
Physical Construction
This was the hardest part. The weatherstation is purposely positioned in the most open and exposed location. I have used aluminium and plastic. Screws are galvanised steel - not ideal against aluminium, but alternatives get very expensive (however, this is better than stainless steel against aluminium). The transmitter electronics is enclosed in a plastic box with vents - this is a security siren cover - and is positioned under the eaves of the house. I do have a concern that the high winds in the area may be more than the current construction can handle - time will tell.
Results after 1 year operation
It didn't blow down despite high winds! A couple of notes and issues found over the past year:
- The Ion detector doesn't measure anything worthwhile
- The sunlight detector worked well, but wasn't accurate from late afternoon onwards. Four light sensors at right angles to each other would have corrected this, and for a simple circuit would have provided good accuracy. I would also sample the sunlight more often then once every 10 minutes.
- The rain detector circuit has a flaw, in that if the rain bucket doesn't tip right over but stops halfway (eg with assistance from spiders webs) my circuit registers a "1" = rain continuously. The circuit should be modified so that the flip-flop is clocked rather than held high.
- The wind direction isn't very accurate, even with the sensor mounted above the house roof. The wind swirls around and the direction changes frequently. It doesn't provide a particularly useful reading.
- The lightning detect is a little too sensitive, and I positioned it too close to the main power cable entering my house. I know it records lightning strikes within 30 - 40 km of my home, so I'm quite satisfied with the sensitivity. The detector needs to be positioned farther from the power cable!
© In the Light, 18 March, 2011 , Disclaimer, Son of Suckerfish drop-downs from HTML dog




