Design of a Microcontroller-Based Data Acquisition System for Ground Weather Observations : Evaluation of Radio Refractivity of Air

A meteorological data acquisition system is built using a PIC16F877A microcontroller and electric output-based sensors. This system is programmed in C language using the PCWH compiler. It is smart, accurate, cheap, small, light and easily movable. It is designed to automatically get instantaneous measurements of air temperature, atmospheric pressure, and relative humidity. Depending on their utilisation, these measurements are collected with repetition rate tuneable from one minute to one hour. They are displayed on LCD screen and transferred to a personal computer where they are stored and processed. As an application, such data are recorded in situ and used to estimate the radio refractivity of air near the ground in real time. This parameter is necessary to account for the propagation of radiofrequency waves through the lower atmosphere, during wireless transmissions.


Introduction
Nowadays, new electronic components and integrated circuits produced by various manufacturers and dedicated to the electronic instrumentation, are available in the market.These are, for example, removable memories such as flash disks capable to store a large amount of data and programmable logic devices like microcontroller, DSP (Digital Signal Processor) and FPGA (Field Programmable Gate Array), used to build data loggers and auto-matic measurement systems [1]- [5].Moreover, small sensors today commercialized, are able to measure meteorological phenomena and convert them into electric signals [6] [7].In the case of weather observations, many meteorological stations are equipped with data collection platforms made of such devices and especially designed to automatically record ground measurements such as the time variations of solar radiation, air temperature, atmospheric pressure, relative humidity, wind speed and precipitation ratio [8].In general, the data collection platforms are usually connected to the National and World Meteorological Centres via meteorological satellites.The atmospheric data collected by such platforms near the ground are essential for the characterization of the present climate change and its perturbations on the terrestrial environment.In spite of their high investment costs, this kind of automated system has the advantage of avoiding the tedious work of handy records, consisting in reporting the meteorological measurements on a register, as practiced in the past.Programmable logic devices were also applied to various areas like those concerning solar radiation, wind, spectrometry, wireless networks, hydrology or farming [9]- [14].For example, a smart system managed by microcontroller was used to monitor a greenhouse so that the plants grow inside under the best conditions [14].Another interesting application is the characterization of the atmosphere for radio communications.To fulfill such an application, the meteorological data acquisition system presented in this paper, is built using the PIC 16F877A microcontroller.Such a microcontroller has been chosen owing to its very good performance, programming facilities, availability and economical advantages.This system is designed to mainly record air temperature, atmospheric pressure, and relative humidity data near the ground.As explained hereafter, these data can be usefully exploited to probe the lower atmosphere and study the anomalous propagation of RF waves.

Design of the Meteorological Data Acquisition System
The block diagram of Figure 1 shows that the meteorological data acquisition system under study mainly consists of three electric sensors respectively measuring air temperature, atmospheric pressure, and relative humidity, their matching circuits, a PIC 16F8877A microcontroller, an LCD (Liquid-Crystal Display) used as alphanumerical display, and an RS232 serial interface.The microcontroller insures the management of the whole system, the processing of the meteorological measurements, the computation of air refractive index, the visualization of the obtained data on the LCD screen and their transfer, via the RS232 interface, towards a personal computer where they are stored.
The matching circuits are two input amplifiers which enhance the signals arising from the temperature and pressure sensors respectively and a voltage/frequency converter which pulses the signal provided by the humidity sensor.The PIC 16F877A is as efficient as the other programmable logic devices and much cheaper than FPGA, DSP or most of the other microcontrollers.

Air Temperature
Air temperature has been measured using the LM335 sensor which is a small circuit of SGS-Thomson integrating sixteen silicon transistors and three output pins.Thanks to the sensitivity of its transistors to temperature, this sensor behaves like a semiconductor diode and can make measurements from −40˚C to +100˚C.As shown in Figure 2, an LM334 current source supplies the LM335 sensor with constant dc current previously tuned to 1 mA.Following the data sheet provided by the manufacturer, the response of LM335 for this current value is 10 mV/K, its output voltage equals 2.98 V at 25˚C and it varies proportionally to temperature.In temperate regions, air temperature range is usually measured near the ground between −15˚C and +55˚C.This means that the output voltage of LM335 will vary from 2.58 V to 3.28 V when such measurements are performed.According to the working conditions of PIC 16F877A, the signal received at each of its inputs, extends from 0 to 5 V.The matching circuit of Figure 2 mainly consists of three operational amplifiers OP07 chosen for their very good accuracy.This circuit amplifies the signal produced by the LM335 sensor, so that the voltage variations at the microcontroller input will wholly cover the temperature range under consideration.This requirement implies that −15˚C and +55˚C must be respectively assigned to 0 V and +5 V at the output.As shown in Figure 2, the signal, sens.
V , coming from the LM335, is amplified and compared with a reference voltage, ref. 2.58 V V = , corresponding to −15˚C, i.e., 258 K.This value is tuned using the potentiometer, 1 P .According to the resis- tance values of 1 R , 2 R , 3 R and 4 R , the gain of the matching amplifier is 2 1 and the output voltage therefore equals.( ) The calibration relationship used to measure air temperature in Kelvin is then written as temp.
258 100 The obtained values at ambient temperature are the same as those measured with a thermometer or a PT100 resistance sensor.As mentioned in Section 5, this signal, temp.
V , will be applied to the RA0 pin of the A port of the microcontroller.

Atmospheric Pressure
The sensor used for the measurement of atmospheric pressure, is the MPX200A manufactured by Motorola.This sensor is a small silicon piezoresistive-based aneroid barometer.It is mainly composed of two volumes separated by a gelatinized silicon diaphragm.The upper volume is directly opened on the ambient air through the hole of its stainless cover and then, submitted to the external variations of the atmospheric pressure, 1 p .The lower volume is a vacuum chamber containing the piezo-resistive strain gauge.The pressure, 2 p , within this chamber is nearly equal to zero and taken as reference.The voltage at the MPX200A output is therefore proportional to the pressure difference, 1 2 p p .Considering its data sheet, the best working conditions will be reached if MPX200A is biased with 3 1 3 V V V − = + dc at 25˚C.In this case, the output voltage difference deduced from the plots of the data sheet is expressed as ( ) In this relationship, ( ) p p − is given in kPa and the voltage ( ) , in mV at 25˚C.The matching amplifier of MPX200A is described in Figure 3.Its schematic is identical to that used for the LM335 sensor.However, its resistances are different, because: Ω .Its gain then equals: It has been chosen sufficiently high so that the pressure voltage, pres.V will vary from 0 to 5 V at the amplifier output.This voltage will be applied to the RA2 pin of the A port of the PIC 16F877A.Expressed in volts, it is given by ( ) The principal disadvantage of MPX200A is the sensitivity of its strain gauge to temperature variations.For a given pressure, the voltage across the pressure sensor is found to decrease exponentially with temperature.The slope of Equation (3) will therefore change if 25 C T ≠ °.Thanks to a corrective routine created in the program of PIC 16F877A, the position of voltage-pressure curve is automatically readjusted versus temperature and the errors caused by temperature variations are counterbalanced.We get that the pressure will correspondingly vary from 0 to 136 kPa in the interval of the pres.
V values running from 0 to 5 V.In particular, the atmospheric pressure measured by the circuit of Figure 3 under normal conditions, is found to be nearly 100 kPa, as that observed with the mercury barometer.

Relative Humidity
The sensor chosen for the measurement of humidity ratio is an 1 H capacitive hygrometer produced by Philips.It is made of two metalized polyamide films, the thickness of its dielectric material is about few microns and its nominal capacity is equal to 122 pF.It acts by trapping the molecules of water suspended in the air, which modify the dielectric constant of the polyamide layers.The resulting capacity, 1 H C , of this sensor therefore depends on the humidity concentration.In particular, it is proportional to the relative humidity, H , when the latter ranges from 10% to 75% and its expression in pF, it is given by 1 0.4 104.6 The capacity variations do not exceed ±15%.To account for these variations, a voltage/frequency conversion is applied to the signal produced by the H1 sensor, using the circuit of Figure 4.This circuit mainly consists of the NE555 component which is a timer working as astable circuit.The c T period of the pulses delivered at the NE555 output, is proportional to the capacity, [ ] The nominal period of these pulses calculated for .Since the sensor capacity depends on the relative humidity, the pulse frequency will also vary against this parameter.The pulses of ( ) c F H frequency generated by NE555, will be transmitted to the TICK pin of C port, which inputs the timer 1 of the PIC 16F877A operating as counter.

Evaluation of Water Vapour Pressure and Refractive Index of Air
Let w e be the pressure of saturated water vapour, namely the pressure of water vapour contained in the atmos- phere when the air is saturated relatively to liquid water or ice at the same air pressure, p , and temperature, T .The relative humidity expressed in %, is defined as [15] [16].
Thanks to Equation (7), the partial pressure of water vapour, e , in the atmosphere is evaluated using the H -measurements performed with a hygrometer.The saturated water vapour of wet air, w e , is previously deduced from the numerical tables giving the saturated water vapour, 0 w e , under pure phase conditions at different tem- peratures, i.e., the gas concentration in a medium made of only water vapour [15] [16].
Considering the ratio ), w f is nearly equal to unity with deviations less than 0.5% whereas at higher pressure, this parameter increases quickly.Since 100 kPa is the or- The correlation coefficient of this adjustment was found to equal 0.9998.The air refractive index, n , and therefore the radio refractivity, N , can be indirectly determined from the measurements of air temperature, T , atmospheric pressure, p , and partial pressure of water vapour, e , using the following equation [17] [18].
This where p and e are respectively given in hPa and T , in K, expresses the mixture of dry air and water vapour considered as perfect gazes.The obtained N -values are usually estimated in the RF range with error of about 0.5%.Moreover, such a relationship is recommended by the Radio Communication Sector of International Telecommunication Union (ITU-R) for the applications of radio frequencies up to 100 GHz.

Building and Programming the Microcontroller Card
PIC 16F877A is a microcontroller manufactured by Microchip following the CMOS technology.Supplied with only 5 V dc, it consumes very little electrical energy.The number of its pins equals 40, including 33 inputs/outputs.It works at 20 MHz provided that 20 MHz quartz is connected at the pins of its internal oscillator.The internal structure of PIC 16F877A integrates all the components of a computer.It is mainly composed of its ALU (Arithmetic and Logic Unit) , internal clock, three timers, five input/output ports, Analogue-to-Digital converter having eight 10-bit channels, RAM (Random Access Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), Flash memory and interface circuits such as USART (Universal Synchronous Asynchronous Receiver Transmitter), MSSP (Master Synchronous Serial Port) and PSP (Parallel Slave Port).As explained in Section 4, the A port is used for the analogue-to-digital conversion of the temperature and pressure signals, the C port, for the reception of the humidity signal through the timer 1, after voltage/frequency conversion, and the communication with a personal computer (PC) via the USART serial port, the D port, to control the LCD lying at the output and the B port, to control the reset and LEDs.To talk with the PC, four sorts of interface are available, namely the RS232 or USB serial interfaces and the GPIB or Centronix parallel ones.Considering the slowness of the meteorological measurement cycles (about only few minutes), RS232 has been chosen because this interface is simpler to use and sufficiently rapid for the transmission of the meteorological data under consideration.The PIC 16F877A has been configured using the PCWH compiler developed by CCS (Computer Composer Studio), PRO-PIC programmer and IC-PROG software.Being dedicated to the PIC family of microcontrollers, PCWH is written in C language [3] [19].It is as efficient as assembly language, but much easier and faster to implement.The microcontroller was programmed following several steps which principally are: • To carry out all the tasks of the meteorological data acquisition system, an appropriate program is set up in the PC and written in C language using PCWH compiler [19].• This program is compiled so as to generate a hexadecimal file (HEX).
• The PIC 16F877A is placed into the PRO-PIC programmer • The program previously converted into HEX, is transferred to IC-PROG software.
• The PRO-PIC programmer holding PIC 16F877A is connected to the PC through the GPIB port and then, put into service.• Finally, the HEX program is transferred from the PC to the microcontroller.
During a few hundred microseconds, the data are collected by the microcontroller, displayed on the LCD screen and transmitted to the RS232 interface of the PC via MAX232 circuit and DB9 connectors.The transfer of these data was performed in sharing time.For that, they were sampled into sequences of 8-bits accompanied with their start and stop bits.These sequences are successively assigned to temperature, pressure, humidity and refractive index of air.Their reception, reconstitution, storage and processing are managed in the computer using Delphi applications (insertion of TComPort and TComLed components of Delphi).The resulting meteorological data are recorded every one minute (or more) with very good accuracy and automatically reported on a table of five columns (time, temperature, pressure, humidity, air refractivity).

Experimental Prototype
The meteorological data acquisition system is compacted in a 6 × 15 × 23 cm 3 box which incorporates all its sensors and electronic devices.The photo of Figure 5 is the fragmented view of the whole system.It shows that the latter is composed of three electronic cards and LCD board.These cards respectively contain the matching circuits of temperature, pressure and humidity sensors, the PIC 16F877A and the electrical power supply.Eagle and Sprint Layout were the software used to design the cards and optimize the implantation of their electronic components on a single sided PCB (Printed Circuit Board).The power supply is classical.It is made of ac transformer, bridge of diodes, current regulators, Zener diodes and appropriate capacitive and self filters.It produces all the required dc voltages from the 220 V 50 Hz mains, namely ±12 V for OP07 operational amplifiers, +5 V for PIC 16F877A microcontroller, +12 V for LM334 + LM335, +3 V for MPX200A and +12 V for NE555.The bias voltage of the sensors is adjustable with trimmers.Notice that if the data acquisition system must work in a remote site, it can also be supplied with only batteries.This system consumes less than 2.5 W. Connected with a portable PC, it has been tested in Algiers under various weather conditions.

In Situ Tests
Outdoor measurements were performed in Algiers under various meteorological conditions, showing the exactness of the relations of sensor calibration given in Section 4. Table 1 reports the experimental results obtained at the ground, for this location on days of fine and bad weather.These results summarize four situations respectively characterized by hot and dry atmosphere, hot air charged with humidity, standard atmospheric conditions and rainfall perturbations.Table 1.Experimental values of air temperature, T, atmospheric pressure, p, relative humidity, H, and radio refractivity, N 0 , obtained at the ground, in Algiers on days of fine and bad weather: e w is the saturated water vapor pressure and e, the water vapor pressure in the atmosphere.The obtained refractivity values range from 293 to 382.To account for the time variations of the refractive index of lower atmosphere, the plot of Figure 6 has been recorded every five minutes on midday for a period of fine weather, with hot and dry air near the ground.It shows that the refractivity of air decreases slightly in time.These variations are explained by weak increases of air temperature at maximum sun elevation angle, whereas atmospheric pressure and relative humidity remain constant during the period of record.Indeed, the obtained measurements are 301.9K 302.6 K T < < , 1070 hPa p = and 10 % H = .From this plot, it is deduced that the ground measurements of refractive index of air vary from 1.000286 to 1.000295.Thanks to its small size and weight, the meteorological data acquisition system of Figure 5 can easily be carried from one place to another and measure the spatial variations of refractivity of air.
In particular, the measurements of refractive index of air with altitude, z , will be helpful for the implementa- tion of models of atmospheric boundary layer and the characterization of terrestrial radio communications [17] [20].Such models usually generate the vertical profiles of modified refractivity, ( ) M z , and use them to compute the RF rays propagating near the Earth.Let us recall that the modified refractivity of air is defined as In this equation,

( )
m z is the modified refractive index of air which includes the effect of terrestrial curvature.It therefore depends on the Earth radius, 0 6370 km R = , the altitude, z , measured from the sea level and the refractive index of air, ( ) n z , obtained at z altitude, namely ( ) ( ) The M -variations with altitude are better appraised by computing their index gradient expressed as Notice that the assessment of radio refractivity of air near the ground is generally fundamental for wireless transmissions because it contributes to know the refractive index profiles and the trajectories of electromagnetic waves within the troposphere [17].Indeed, in spite of the weakness of the refractive index variations, the latter are more sensitive with altitude and then, significantly influence the propagation of RF waves.Briefly, the lower troposphere is generally submitted to either sub-refraction or super-refraction [17] [18].Sub-refraction occurs when the gradient of refractive index of air obtained from its vertical profile, is greater than zero.In this case, the path followed by the RF waves, is curved towards the sky.Super-refraction is characterized by vertical gradient of atmospheric refractive index which always takes negative values.The resulting refractivity variations with altitude yield that the RF rays are bent down to the ground and cover long distances.In particular, if these variations are sufficiently strong, atmospheric ducts will set up over the terrestrial surface and transmit RF waves beyond the horizon, over very large distances.The anomalous propagation so described is generally observed in tropical and equatorial regions, over the seas and plains, when atmosphere is quiet and submitted to important temperature and humidity variations [17].In the Mediterranean region, this phenomenon especially happens along the Algerian cost, during fine weather periods of summer.To detect atmospheric ducts near the Earth surface, the outdoor measurements of radio refractivity of air can be simply performed with altitude by connecting our data acquisition system with a portable PC and moving the whole set from the ground to the floors of a construction.For example, during hot and wet day of summer, the air refractivity measured with this system, was found to be 0 344 N ≈ at the ground and .From this value of index gradient, we infer that an evaporation duct was probably present in the region of Algiers during this experimentation.

Conclusion
During the various tests performed in Algiers, the meteorological data acquisition system presented above has well worked without any failure.Thanks to the electric sensors and microcontroller chosen to build such a system, ground measurements of atmospheric pressure, air temperature, and relative humidity have been automatically collected with a reasonably good precision (~1%).These data are displayed on LCD screen and transferred every five minutes (or more) to a personal computer where they are archived and processed.They have also been used to evaluate the refractive index of air near the ground, in view of applications to RF terrestrial transmissions such as those operating at VHF, UHF and microwaves.Notice that such data are pertinent indicators to define the type of weather prevailing in the region where the meteorological data acquisition system is installed.In addition, this system is easily transportable and consumes little electrical energy.Supplied with autonomous energy source such as a small stand-alone photovoltaic system and equipped with a wireless data transmission system, it could therefore be used for meteorological observations in remote locations.All the electronic devices and sensors composing this system are advantageously available at low cost in the market, the necessary documentation and software have been quickly downloaded from internet and the programming tools used such as PCWH are easily implemented.However, some difficulties appeared when designing the electronic circuits.These are, for example, unwanted oscillations, then eliminated by self/capacity filtering and programming errors, detected and corrected in due time.The principal drawback was due to the calibration of the pressure sensor.Since the latter is sensitive to temperature variations, its pressure-voltage relation must be continuously readjusted in conformity with temperature variations.To improve the working conditions of this sensor, the gain of its matching amplifier has been increased and a corrective routine was introduced in the program of PIC 16F877A.These modifications make the measurements more accurate around the normal atmospheric pressure.
To check the reliability of the data acquisition system and the calibration of its sensors, it will be obviously necessary to pursue the experimentation in situ during long periods.For instance, the obtained ground measurements of air refractivity could be employed to identify the type of propagation medium and input the models describing the propagation of RF waves in the low atmosphere.However, the vertical profile of air refractive index must be known to yield more realistic radio communication previsions.Thus, among the possible approaches, instrumentations based on either multi-sensors or airborne concept could be good options for the measurement of air refractivity with altitude.

Figure 1 .
Figure 1.Block diagram of the meteorological data acquisition system.

Figure 2 .
Figure 2. Temperature sensor and its matching amplifier.

1 HC
. It is written as: is equal to 17 µs and the nominal frequency is 58830 Hz c F =

Figure 3 .
Figure 3. Pressure sensor and its matching amplifier.

Figure 4 .
Figure 4. Humidity sensor and its matching circuit.der of magnitude of atmospheric pressure prevailing in the lower atmospheric layer, we get 1 w f ≈ and

Figure 6 .
Figure 6.Time variations of refractivity of air measured at the ground, in Algiers on day of fine weather: • measurement, − smooth curve.