1232 IEEE TRANSACTIONS ON INSTRUMENTATION AND MEASUREMENT, VOL. 48, NO.
6, DECEMBER 1999
A Microcontroller-Based Data Acquisition System
for Solar Radiation and Environmental Monitoring
Raphael Mukaro and Xavier Francis Carelse
Abstract— The hardware design and operation of a battery- horizontal surface. Monitoring as described herein deals with
powered microcontroller-based data acquisition system (herein collection, recording and transmission of the measured data
referred to as the DAS) for unattended remote measurements are to the computer for archival storage and off-site analysis of
presented. The system was designed around the ST62E20 8-bit
microcontroller and applied for solar radiation monitoring. The the data acquisition system performance. This data is sampled
measurement system uses the SolData silicon-cell pyranometer as and recorded as a function of lapsed time of the experiment.
the solar radiation sensor. The data from the sensor is collected by This improved the quality of data since small errors are
means of on-chip A/D converter and stored in a serial EEPROM involved in digital data handling compared to conventional
until uploaded to a portable computer. Keeping the DAS in a manual methods. This system is well suited for monitoring
low-power mode, which is only interrupted when measurements
are to be taken or when a computer is connected to retrieve meteorological or environmental parameters at remote stations,
the stored data, minimizes power consumption. An on-chip timer particularly in developing countries where electrical power
provides an interrupt to awaken the system from its low-power and telephone lines for telemetric data transfer are not readily
wait mode at 10-min intervals to sample and store the data. available [5]. One operator with one portable computer is all
At the end of each data collection period, the acquired data what is required to collect acquired data from many such
will be transmitted to the computer through the RS232 serial
port for subsequent analysis. Only unprocessed data is stored in systems scattered around an area of interest.
EEPROM. Quality control and data analysis is done off-line in
the laboratory to minimize system cost, complexity and system II. HARDWARE DESIGN
downtime. Field tests and comparisons of this measurement sys-
tem against the standard Eppley precision spectral pyranometer The data acquisition system developed is a compact (70
(PSP) have shown a slightly nonlinear correlation and that the 50 30 mm), low cost, 8-bit system with 8 analog input
accuracy of this measurement system as applied to solar radiation channels designed for automatic long-term data collection.
monitoring is fairly good, typically 613 W/m2 : Fig. 1 shows the block diagram of the basic elements of
Index Terms—Communication, data acquisition, digital, inter- the design. The system was designed to be versatile and all
face, interrupt, microcontroller, programmable, serial. operations are under software control. This will allow for
future expansion or modifications without the need for major
hardware changes. The system is connected to a computer
I. INTRODUCTION
through the RS232 serial link to allow user communications
W HILE quantitative information on global solar radiation
and other environmental parameters is needed in many
studies such as meteorology and the design of solar systems, it
and to download recorded data to the computer for subsequent
analysis. The main component of the data acquisition system
is the ST62E20 microcontroller that is driven by an 8 MHz
is difficult to obtain these data in remote areas where relevant crystal oscillator. The microcontroller is an HCMOS integrated
data are required. This is mainly because such studies cover circuit computer designed for embedded control applications
wide areas and also generate large amounts of data, such that which is here used to control measurement and data storage
the efficient acquisition, management and analysis of the data sequences. It has 4 kb of program space (EPROM), 64 bytes
become tedious, time consuming and above all expensive. In of scratch pad RAM and a true LIFO hardware eliminating
most cases researchers enter these large volumes of monitored the need for a stack pointer. It was chosen for this purpose
data manually into computer files for subsequent analysis because of its low-power consumption, low-cost and an in-
[1]. Given the labor intensiveness of this procedure and the built 8-bit A/D converter with up to 8 single-ended analog
potential for transcription errors, it is important to computerize inputs. The ADC has a conversion time of 70 s when an 8
the acquisition of data, data-file creation and analysis of the MHz oscillator is used. With a 5 V supply the converter has
data [5]. a resolution of 20 mV. Fig. 2 shows the hardware details of
Hence a low-cost battery operated microcontroller-based microcontroller-based data acquisition system.
data acquisition system that runs unattended was developed Two HCF4066BE quad switches (by SGS Thomson Micro-
and applied to continuously monitor solar radiation on a electronics) are used in conjunction with the A/D converter to
Manuscript received November 17, 1996; revised September 16, 1999. sample signals from the silicon-cell sensor and the 2.5 V ref-
This work was supported by the United Nations University through the erence derived from the LM336 voltage reference. These two
Microprocessor Laboratory, ICTP, Italy. switches provide this design with 8 single-ended analog input
The authors are with the Physics Department, University of Zimbabwe,
Harare, Zimbabwe. channels, four of which are dedicated for the reference voltage
Publisher Item Identifier S 0018-9456(99)09595-9. necessary for calibration purposes. The proper operation of
0018–9456/99$10.00 1999 IEEE
MUKARO AND CARELSE: MICROCONTROLLER-BASED DATA ACQUISITION SYSTEM 1233
Fig. 1. Block diagram of the data acquisition system.
Fig. 2. Circuit diagram of the data acquisition system.
1234 IEEE TRANSACTIONS ON INSTRUMENTATION AND MEASUREMENT, VOL. 48, NO. 6, DECEMBER 1999
each analog input line is verified by connecting the reference line, SDA, and the serial clock line, SCK, to communicate
voltage, through one of the switches to the A/D converter. with the microcontroller. The 24C65 data line, SDA, and the
A digital conversion is made and the results transmitted HCF4066BE switch control lines are both open drain terminals
to the computer and compared against an expected digital so 10 k pull-up resistors have been used. The 3-bit address
output. To ensure optimum system use and minimum power (chip select) of the memory chip is hard-wired at the pins A0,
consumption, nearly all control lines of the microcontroller A1 and A2 which are connected to ground to set the address
are used effectively. Seven lines from port B are used: four at 000 (binary). However up to eight such EEPROMS, giving
(PB1, PB2, PB3 and PB4) for analog inputs and two (PB5 a total of 64 kilobytes may be connected in parallel when the
and PB6) for data exchange with the memory chip. The other address pins are appropriately hardwired to obtain addresses
port B line, PB0, together with port A line, PA3 are used ranging from 000 to 111 (binary).
for RS232 communication with the computer for receiving Serial interfacing between the data acquisition system
command messages and for uploading acquired data to the and the computer is implemented using the MAX232 line
computer respectively. Two other lines of port A, PA0 and driver/receiver which is used to convert TTL (0–5 V) voltages
PA1, are used as control lines for the quad switches. Analog required by the data acquisition system to the 12 V and 12
input line PB1 is used for measuring both solar radiation and V needed by the computer for RS232 communication. Only
battery status if appropriate signals are applied to the control three RS232 lines are used for serial communication in this
lines. A logic low on the control line turns off the selected application. PB0, PA3 and ground from the microcontroller are
switch shutting off all its analog inputs. A logic high placed connected to the controlling computer’s RS232 Transmit Data
on line PA1 selects quad switch SW1 so that four analog input (Tx), Receive Data (Rx) and logic Ground lines respectively.
lines connected to this switch can be sequentially sampled. The 5 V supply for the interface circuit is derived from the
Similarly a logic high placed on PA0 selects SW0 so that the data acquisition system. The MAX232 serial interface chip is
reference voltage can be sampled. In this application, when incorporated in the detachable module, which acts as a data
PA1 is high and PA0 is low, solar radiation will be measured transfer interface between the data acquisition system and the
by sampling the signal on PB1. Similarly (which gives computer. It is only powered when a computer is connected
information on battery status) will be sampled through the to the data acquisition system to retrieve the collected data.
same analog input line PB1, if PA0 is now high while PA1 Capacitors C3, C4, and C7 are provide power supply filtering
is low. The other three analog input lines are not used here, to the ST6220, the 24C65 memory chip and the MAX232
but could be used for other environmental parameters such as respectively. The reset pin on the microcontroller is active
ambient temperature and humidity. An LED shows the status low and is held to a positive voltage by a 2.5 k pull-up
resistor. A touch of the push button brings down the potential
of the system. The LED is illuminated when measurements are
of the reset pin to ground thereby causing a system reset.
being taken and while data is being transferred between the
Capacitor C8 is used to eliminate debouncing of the push
data acquisition system and the computer. Line PA2 capable of
button which causes the microcontroller to reset many times.
sinking 20 mA current is used for directly driving this indicator
Diode D1 is used for protecting the system against damage
LED. The status LED is lit when a logic 0 is placed on this
due to accidental battery polarity reversal.
line and is turned off by a logic 1.
The SolData pyranometer is the most expensive component
of the system, costing about U.S $300. The rest of the III. SOFTWARE DESIGN AND DATA
data acquisition system components cost less than U.S. $60. ACQUISITION SYSTEM OPERATION
The sensor produces a voltage between 0 and 100 mV. An
LM358 low power dual operational amplifier (SGS-Thomson The control program, written in ST62 family assembly
language, oversees the operation of the entire system under
Microelectronics) with a gain of 34 was used for signal
interrupt control. This measurement system utilizes two of the
amplification. It was chosen because both its offset current
microcontroller interrupts. The timer interrupt is used for data
and offset voltage are very low (2 nA and 2 mV respectively).
collection and storage while the PC interrupt is used to trigger
The only other major component connected to the microcon-
the process of data transfer between the computer and the
troller is the Microchip 24C65, an HCMOS 8-pin and 64-kbit
system. These interrupts are nonpreemptive, however the PC
serial EEPROM. This memory is used to sequentially store
interrupt has the higher priority. The main program of this
acquired data. It has the following attractive features:
system does nothing except to wait for these two interrupts.
1) has a data retention of over 40 years without the need So this system is interrupt driven. The major roles of the data
for a power source; acquisition task include regular storage of monitored data to
2) has filtered inputs for noise suppression; the EEPROM, keeping a record of lapse time relative to the
3) has got power on/off data protection circuitry; first measurement and transferring measured and acquired data
4) has an electrostatic discharge protection of over 4 kV to the memory and later to the computer respectively. The
so it can withstand power surges caused by lightning system makes full use of the computer not only for subsequent
which is a common hazard in this region during the data analysis and presentation of results after retrieving the
rainy season. stored data, but also for initial setting of the start date and
The 24C65, which is described by the manufacturer as a Smart time of the system before it is left to run independently.
Serial EEPROM, uses only two lines, namely the serial data In this investigation, the system monitors horizontal global
MUKARO AND CARELSE: MICROCONTROLLER-BASED DATA ACQUISITION SYSTEM 1235
Fig. 3. State diagram for the data acquisition system.
solar radiation at 10 min intervals. The software and complete keyboard to communicate with the data acquisition system.
operation of the system can be understood from Fig. 3. which The data acquisition system does not have a real-time clock
shows the state machine diagram for the measurement system. so the operator via the computer keyboard supplies the start
The system has four modes of operation: time for measurement before the system is left to run. This
1) acquisition or measurement; data is stored in the first five bytes of the EEPROM. When the
2) storage; system start time has been entered, data and reference voltage
3) wait mode; corresponding to this start time is immediately sampled and
4) listen mode. stored. Thus data acquisition and storage is triggered from
The microcontroller was programmed to be in a low- the computer keyboard after the operator has specified start
power mode, except at specific times when data acquisition or time and date. After taking this initial set of readings, the
communication with the computer is in progress. The operation data acquisition system goes back into the Wait state to
of this data acquisition system is similar to the one described wait for another data acquisition and storage cycle. A Turbo
by Lou et al. [2]. C serial communication software running on the computer
When power is first applied or a reset is signaled, the first at this point instructs the user to disconnect the controlling
state entered is the Initialize state. This state ensures computer. Every 24 ms thereafter, the timer interrupt wakes
that all internal variables have a defined initial value and that up the microcontroller to check if 10 min have elapsed. If 10
the input/output lines are properly configured. The system min have elapsed, which happens after 25 000 such interrupts,
then goes into the Wait state. In this mode the oscillator the microcontroller goes into the Measure state where the
remains active to keep track of time but the system does system increments lapse time and lights an LED to indicate
nothing except to wait for the interrupts. Instruction execution that samples are being taken. In this Measure state, reference
is stopped, internal power consumption is decreased, however, voltage is sampled and 20 A/D converter readings from the
and internal RAM contents are preserved. The program then sensor are taken and averaged. If the data from sensor is less
starts the timer and reads channel PB0 to check if a computer than ten (equivalent to an irradiance of 65 W/m the system
is connected to the data acquisition system. If the computer is assumes it is night time and does not record this data. This
not connected the timer awakens the system from the Wait was done to save memory. Only lapsed time is recorded, and
mode. A set of readings is then taken and stored after which the data acquisition system returns to the Wait mode. The
the data acquisition system goes back into the Wait state system repeatedly sleeps, awakens and keeps track of time
to wait for another data acquisition and storage cycle. If the until the data are valid. If the sampled value is above ten,
computer is connected, the system makes a transition into the system goes into the Store state where the data are
the Listen mode in which the operator uses the computer written in the external EEPROM chip. Upon completion of
1236 IEEE TRANSACTIONS ON INSTRUMENTATION AND MEASUREMENT, VOL. 48, NO. 6, DECEMBER 1999
Fig. 4. Typical calibration graph for the DAS.
data storage the system switches off the LED to indicate that sent by the PC and performs the appropriate operation. After
the acquisition and storage processes are complete. It then the successful completion of operation, the system returns an
returns to the main program where it will go back into the acknowledge signal back to the computer.
Wait mode again to wait for the next PC inquiry or data Acquired data could be retrieved by one of the following
acquisition. Following every 10 min time, the reference and methods.
sensor signals are sampled and written to memory with each 1) One storage module (24C65 chip) remains with the
parameter using one byte. With this sampling frequency, 18 data acquisition system, stores data and is then replaced
bytes of memory are used per hour during the day and only by a “fresh” storage module during a site visit. The
one byte for lapse time during the night. So the system can run filled module is returned to the office and the data is
for about a month before the 8 Kbytes of memory are filled downloaded to a computer.
up. The data acquisition and storage processes go on until 2) The data logger is interrogated on-site by a battery
the computer again interrupts the system. This time when the operated IBM compatible lap-top computer through the
PC interrupt is noted, the measurement system goes into the RS232 serial port and acquired data transferred to it
Listen mode in which a series of commands are entered followed by a fast clearing of the whole storage module
from the computer keyboard to either for another storage routine.
1) download data to PC;
2) erase EEPROM for another recording cycle; IV. RESULTS
3) check the operation of each of the four analog input
The data acquisition system was first calibrated against a
lines;
first-class, factory calibrated reference, the Eppley PSP ther-
4) reset the system.
mopile pyranometer. The data acquisition system was mounted
Serial communication between the computer and the data outdoors on a horizontal surface alongside the Eppley PSP
acquisition system operates in the half duplex asynchronous Pyranometer. Global horizontal irradiance readings from the
mode at 600 baud. The MS-DOS MODE COM1: 600, N, 8,1 two instruments were taken simultaneously at 1-min intervals
command placed in the autoexec.bat file configures the serial for intensity levels between 65 and 1200 W/m Synchroniza-
port with required communication parameters of 600 baud rate, tion was achieved by taking the Eppley reading when the LED
no parity, data width of 8 bits and one stop bit, at boot-up. A on the data acquisition system was lit up, showing that data
software program in Turbo C programming language was acquisition readings were being recorded. The Eppley output
developed to facilitate communication between this system and was then regressed against the corresponding data acquisition
the computer through the RS232 serial port [5]. Through this output and showed a slight nonlinearity.
program the computer is able to send start date and time to Measurements were made throughout the year, so data
the data acquisition system or retrieve the acquired data for covering an almost complete range of atmospheric conditions
subsequent analysis. The data acquisition system through the in Harare were used to derive the calibration coefficients. The
PC interrupt routine reads and decodes the command bytes average empirical first and second order quadratic calibration
MUKARO AND CARELSE: MICROCONTROLLER-BASED DATA ACQUISITION SYSTEM 1237
Fig. 5. Comparison of radiation as measured by the Eppely PSP pyranometer and the DAS.
coefficients of 6.40 and 0.0034 respectively were obtained [6]. and the supply produces a regulated 5.0 V, the digitized
So the empirical function for this system as applied to solar reference from a reference of 2.5 V, was found to be
radiation monitoring is 127 1. The 1 count uncertainty derives from the fact that
the AD converter has a conversion error of one least significant
(1) bit. Thus the corrected digital output at any instant, is
given by
where is the calculated global irradiance and is the digital
data value recorded by the acquisition system. (2)
A typical calibration graph is shown in Fig. 4. In order
to examine the correctness of the fit, the data acquisition where is the digital voltage obtained from the sensor.
system readings were recorded against corresponding Eppley This digital correction of the signal, which is done by means
pyranometer readings and (1) used to estimate the radiation. of an autocalibration procedure on the computer as the data are
Fig. 5 shows how well the DAS fit compares with the data retrieved, substantially improved the accuracy of the data [6].
from the Eppley pyranometer. There is very close agreement
with an error of about 13 W/m [6]. However, during partly
cloudy days, relatively wide scatters were obtained. This is V. CONCLUSION
mainly due to the difference in response times of the two A low-cost microcontroller-based data acquisition system
instruments, with the Eppley PSP pyranometer less able to that automatically takes measurements and records the data
respond quickly to rapid changes in irradiance levels. The data has been designed, developed and programmed and applied
acquisition system takes about 2 ms to do 20 A/D conversions to monitor solar radiation. It has been successfully interfaced
compared to a response time of about 1 s for the Eppley. So the to a computer for initial setup of the system and for data
wide scatters were primarily due to the Eppley being unable to retrieval. The data stored are sent to a computer by a serial
follow rapid changes of radiation associated with clear-cloudy link upon request, and subjected to graphical analysis. In
transitions during partly cloudy conditions. Consequently some spite of the insensitivity of the SolData silicon-cell for large
significant calibration errors occurred during the transition wavelengths, the use of it as a solar radiation sensor resulted in
period. This aspect is discussed by Michalsky et al. [3] and good correlation with the Eppely PSP pyranometer. Field tests
Suereke et al. [4]. and comparisons against the standard Eppley PSP pyranometer
The data acquisition system operates from a rechargeable have shown that the accuracy of this measurement system is
battery pack so that the supply voltage, fluctuates with fairly good, typically 13 W/m This error is acceptable for
time and state of charge. As the analog-to-digital conversion a lot of applications in solar energy. The overall quality of
depends on this voltage, all conversions were checked against the data is good due to intrinsically small errors involved
a reading obtained from a 2.5 V reference derived from in digital data handling compared to conventional manual
the LM336 voltage reference and the following correction measurements. Moreover, the system is easily operated and
procedure was applied. When the battery pack is fully charged does not require any programming expertise. The system
1238 IEEE TRANSACTIONS ON INSTRUMENTATION AND MEASUREMENT, VOL. 48, NO. 6, DECEMBER 1999
is could be used to monitor various other environmental Raphael Mukaro was born on August 31, 1968
parameters. in Harare, Zimbabwe. He received the B.Sc. and
B.Sc.(Hon.) degrees in physics from the University
of Zimbabwe, Harare, in 1992 and 1993, respec-
ACKNOWLEDGMENT tively. He is currently pursuing the Ph.D. degree in
physics at the same university.
The following people have significantly contributed to the He joined the Physics Department, University of
work presented here: Prof. A. Colavita, Director of the Mi- Zimbabwe, in 1993, and has been working as a
Teaching Assistant since then. His current inter-
croprocessor Laboratory, and all staff at the Microprocessor est is microprocessor/microcontroller applications in
Laboratory, and R. B. Ijadoula of the Agriculture University, physics and environmental monitoring and assess-
Abeokuta, Nigeria. ment.
REFERENCES
[1] P. S. Dahl, “A PC and Lotus-based data acquisition/reduction system
for an ICP spectrometer,” Comput. Geosci., vol. 16, no. 7, pp. 881–892.
[2] E. Lou, N. G. Durdle, V. J. Raso, and D. L. Hill, “A system for
measuring pressures exerted by braces in the treatment of scoliosis,”
IEEE Trans. Instrum. Meas., vol. 43, pp. 661–664, Aug. 1994.
[3] J. J. Michalsky, R. Perez, L. Harrison, and B. A. Lebaron, “Spectral and
temperature correction of silicon photovoltaic solar radiation detectors,” Xavier Francis Carelse was born in South Africa.
Solar Energy, vol. 47, pp. 299–305, 1991. He is Lecturer with the Department of Physics,
[4] H. Suereke, C. P. Ling, McCormick, “The dynamic response of instru- University of Zimbabwe, Harare. He has qualifi-
ments measuring instantaneous solar radiation,” Solar Energy, vol. 44, cations in physics and electronic engineering and
pp. 145–148, 1990. has worked for eight years in industrial research
[5] R. Mukaro and X. F. Carelse, “A serial communication program for
and development in the U.K. and, in addition to
accessing a microcontroller-based data acquisition system,” Comput.
lecturing in four universities in Africa, has also
Geosci., vol. 23, no. 9, pp. 1027–1032, 1997.
served as a Visiting Lecturer at three universities in
[6] R. Mukaro, X. F. Carelse, and L. Olumekor, “First performance anal-
the U.S. His specialty is electronic instrumentation
ysis of a silicon-cell microcontroller-based solar radiation monitoring
and he is mainly interested in the development of
system,” Solar Energy, vol. 63, no. 5, pp. 313–321, 1998.
undergraduate laboratory experiments.