99

General concept

General concept
If you look on this website you see several proposals for measuring and logging meteo data. Measuring temperature, moisture and airpressure is not to difficult nowadays using modern and cheap i2c compatable small electronic boards. But if I build one, I also like to know wind direction and speed. And hours of sunshine, but that will be a next seperate proposal (a LDR with a very cheap optical lens and colorfilter). So I designed, build and tested a prototype for wind direction and speed. I used a MBED uP for prototyping. Read on (at 'Interfacing') for suggestions of how to use the MBED as a master meteo logger or as a intelligent slave instrument.

Traditional way to measure wind direction and speed
The traditional (mechnical) way to measure wind direction and speed is to use a weathervane and weathermill. The position of the vane can be detected using a potmeter or a rotary decoder (maybe if you can make a special .wav file and burn it on a CD so that it has sectors on the CD with grey code, you can use the CD as a decoder) on its vertical axis. The speed can be measured by counting pulses or use a dynamo to measure current on a rotating axis. Especially for electronic engineers, building such a instrument requires mechanical skills and tools, which we often lack. Furthermore we have to take into account that the instrument is exposed to the weather (and that includes rain, hail, snow but also sand, dust or leaves or spiderswebs or bugs). So, is there a electronic alternative? I think there is; a instrument based on thermo-flow meters.

Thermo-flow
As a control engineer I was introduced ones with a thermoflow meter; to measure the amount of (polluted) air in a large pipeline somebody suggested using that kind of instrument. A small heater produces warmth which is measured a few millimeters after the heatsource with a accurate temperature sensor. So, if I use 3 temperaturesensors at a 120 degrees angle around the heatsource, I get a omnidirectional sensor (see Detailfoto-meetinstrument-1.jpg).

Hardware
The heat is produced by a 2N2219A transistor (Conrad# 163139), placed in the middle of a wooden disc with a diameter of 57 millimeter. I choose 57 millimeters because it fitted in a cap of a foamcream aerosol can. Close around the transistor are 3 NTC's (Hygrosens CON-TS-NTC-204, Conrad# 502369). See Detailfoto-meetinstrument-2.jpg. After the transistor and NTC's were mounted on the disc, it is two times sprayed with black paint to protect it from pollution and corrosion. The main feature of the sensorhead is its 'roof' above the disc with the transistor en NTC resistors. This roof, consisting of a wooden disc covered with alu-folie reflects the uprising heat and keeps its within the slit where the transistor en NTC's are situated. This is the main mechanical feature (Detailfoto-meetinstrument-3.jpg)!

The 2N2219A transistor has a metal casing and a TO39 mount.. Feeding it with 3.3 Volt is a nuisance for electrical amplifying, but it produces a lot of heat! Using a 4.7K resistor from the base of the transistor to a digital output (high) let the transistor roughly consume 0.5 Watt, resulting in a 30 degrees Celsius rise to (any) ambient temperature. According to wind direction and speed the the 'heatcloud' changes shape which is measured by the NTC resistors. The NTC's are in series with a 180K ohm resistor and connected to 3 analog inputs of the MBED. No further amplifiying is done or necessary. See schematic.jpg. Practise results show that about 20% of the heat is sensed by the NTC's.

Software
See the softwarelisting in mbed-org-compiler-listing.pdf (in the .zip file).

Wind direction
After heating up, 12 measurements are taken at 5 second intervals of the NTC's. This is done via analog inputs. MBED converts 0 .. 3.3 V to 0.00 .. 1.00. The analog value increases with the increase in temperature. Then the values are subtracted from the maximum of the three analog values. These resulting values are vectors whose strengths point in the direction of the wind. All vectors are reduced to the x- and y-values of the circle (positive y-axis is pointing north). The needed trigoniometric values are sinus (30 degrees) and cosinus (30 degrees) and are fixed: 0.500 and 0.866. The reduction is done by multiplying with these values. The 12 x- and y-values are added up giving one v_x_s value and one v_y_s value. According to if the values are positive or negative, a quadrant (north to east, east to south, south to west, west to north) is selected. The 90 degree quardrant is subdivided with the arctangent function. See exampleNE.jpg for a grafical display. The resulting value is between 0 and 16, pointing a 22.5 degree sector on the circle. Sector 0 is north-north-east and counting up clockwise until 16, which is north-north-west. This value serves as a index to a textstring with discriptions of the winddirection (further reduced to 8 possibilities).

Wind speed
The first approach was to use the resulting vector calculated for the winddirection, but not using its angle but its strength (SQRT (v_x_s * v_x_s + v_y_s * v_y_s). For windspeeds 1 to 4 Beaufort (see beaufort.jpg for an explanation of the Beaufort scale) that worked allright, but than something strange happened for windspeeds of Beaufort 5 and higher. The original assumption was that the strength of the resulting vector increases with the windspeed. But from Beaufort 5 and higher the strength decreased again. A stronger wind blows so much heat out of the sensorhead that the difference between the NTC's diminishes. This is no problem for detecting the winddirection but for every strength there are two possible solutions of Beaufort values.

So an other approach was used; take all three NTC's measurements as one to measure the amount of heat in the sensorhead. Take 2 measurement series; one with a 'cold' sensor and one with a 'hot' sensor. The more heat is measured in the 'hot' period (compared to the 'cold' period) the more heat remains in the sensorhead, or is not blown away by the wind and so the weaker is the windspeed. Testing showed that this method works fine if the conversion of the measured value to Beaufort scale is done by a reciprocal function.

Test and calibration
The instrument is tested and calibrated in august 2012 at the frisian island Ameland. During the weeks windspeeds of Beaufort 1 to 7 were blowing on different days and from different directions.

Calibration of NTC's
The chosen NTC's can be exchanged without calibration according to Hygrosens. But because of slight differences in the position of the NTC's around the transistor and other mechanical toleration it is (probably) necessary to calibrate them with each other. The program provides three values (#define Corr_v1, Corr_v2, Corr_v3). To find the small values take the comment slashes (//) from lines 44 and 65. The program will print the measured analog values als voltages. If the sensorhead is put in a windless environment (indoors – don't run and puff around during the measurement) the values should be equal to a 0,01 Volt of each other. Start with the correction values at 0.000 and adjust according from the outcome.

Setting of B_numerator and B_offset
The difference (variable vv) between the 'cold' measurement (variable vk) and the 'hot' measurement (variable vh) is input for the conversion formula for the Beaufort strength (B_numerator / vv + B_offset). The value of B_numerator can be obtained by (again) do some measurements indoors – in a windless environment. Use program lines 44 and 65 to print the vk and vh variables and write down the last vk and vh values in a measurement cycle (5 minutes) and subtract them. Take some measurementcycli and choose an average. That will be B_numerator. Smart calculators recognise that the Beaufort scale then never becomes lower than 1, but hey, Beaufort 0 is a windspeed between 0 and 0.2 meters per second. You may set B_offset a little higher or lower according to your own assumption of what is the correct windspeed. Beware that by printing the Beaufort value as “%1.0f” the value is truncated. Setting the B_offset to +0.5 for example sets the value of Beaufort 2.6 to 3 instead of 2.

Next steps

PCB board
To make the instrument better reproducable it is a good idea to change the wooden disc with the 2N2219A and NTC's for a printed circuit board. A second small board soldered vertical under the PCB disc could hold a uP and some extra electronics. It may also be a good idea to make the diameter of the round PCB a little larger than the wooden prototype disc (57 millimeters). To bring wind turbulance to a minimum a rule of thumb is to make distance from the edge of the disc to the NTC as 5 times as large as the distance between the NTC and the the transistor. A piece of rainpipe with a diagonal of 80 millimeters would be ideal. For a proposal see montage.jpg. It may be interesting to test the instrument upside down. The heat is then locked from rising by the PCB (or melting it?).

Lowering energy consumption
The MBED I used for prototyping and to develop the program is of type NXPLPC1768. The disavantage is that is consumes a lot of power (60 to 120 mA). This is not good for a free standing instrument, probably running on battery power. So we have to replace it with a NXP LPC11U24 (1 to 60 mA). And it is also cheaper. Look on mbed.org for specs of the uP's. In the program we only exchange the wait () instructions by timed sleepinstructions. 99% of the measuring cycle is just waiting, so why waste energy then.

If you like to use an other type of uP, feel free to convert the program. What you need are 3 analog inputs, 1 digital output and a way to output the result. Your uP should be able to do the multiplication with 0.500 and 0.866 (or get around it by multiplying with something like 5000 and 8666 and subsequently dividing by 1000) and, more important, can perform the arctangent function!

To lengthen the time before the batteries are empty, it is a good idea to charge them using a small solar panel for outdoors use connected on the instrument housing (we want to put the instrument and housing free from obstacles and that makes it probably difficult to access to change batteries). Taking a 9V solar panel we can charge 4 AA batteries (5.2 Volt) with 5.6 Volt using a 5.6 Volt 500 mW zenerdiode with a 47 ohm resistor in series. This will charge the batteries with 72 mA. There will be no need for further charge and test electronics, because when the batteries get full there voltage will reach 5.6 Volt and the charging stops automatically.

Windtunnel
As said before the testing was done on the frisian island Ameland under different windconditions. The predicted windspeed was looked up from online weatherprediction websites. But actual, accurate windspeeds can change within minutes or even seconds. The reciprocal function seems to best fit to calculate the Beaufort strength. But before mass producing this kind of instrument it is a good idea to test it in a conditioned environment, especially in a windtunnel. But that is a bit costly for a prototype.

Interfacing
As stated before the place to mount this kind of instrument is to free airflow. In my case that will mean to climb on the roof of my house and fix it there somewhere. And that means also that to build a display on it, is useless. I think connecting a RFM12 radio transmitter / receiver to the MBED (see elektor jan. 2009) and send a direction and speed message at 868 Mhz every 5 or 30 minutes. An other small uP in my house with a RFM12 receives the message and displays it in a nice way. Because i2c communication is limited to 1 meter, that will also be no option. If you do want to use a cable, RS232 might be a option (15 meters, sorry - not enough for castle owners).

Other meteo data
Because the two i2c interfaces on the MBED are still unused it is quite easy to add a Hope RF HH10D (airhumidity) and a HP035 (airtemp. and pressure) sensor to the instrument (see elektor 575, september 2011). A sensor measuring hours of sunlight and rainmeter will complete the meteo instrument. I have allready started to design a simple hours of sunshine instrument.

Logging
If you are interested in logging, using a MBED might also be a good idea. The MBED has a inbuilt disc of 2 Mb (!) and functions to create, open, write, read and delete files on that disc. Connecting the MBED via its USB connection to a PC gives you access to this disc as if it were a USB stick. In a test I wrote a program reading HH10D and HP035 data and witing it to the disc in a .csv file format. OpenOffice could import this file with no problem at all.

Your help with the next steps is welcome.