A Low-Cost Microcontroller Based Air Temperature, Humidity and Pressure Datalogger System Design for Agriculture

Agricultural datalogger, Arduino, Climate change, Microcontroller. Abstract: Nowadays, it is accepted that climate change can threaten food safety. Losses in production areas due to climate change have the potential to create major devastating effects. In agricultural areas, rapid and effective measures should be taken against climate parameters that are not under human control. For this purpose, approaches such as precision or smart agriculture are becoming widespread. Low cost microcontroller-based devices that can help to take the necessary measures by rapidly measuring the basic climate parameters are gaining importance especially in the lands of small scale agricultural enterprises. For this purpose, developed a customizable and re-programmable datalogger system which can measure the basic meteorological values for agricultural purposes under field conditions with low-cost parts. The system consist of an Ardunio UNO R3 microcontroller card, a Bosch Sensortech BME280 integrated environmental sensor, a data storage unit, a LCD and an USB supported battery unit which allows the system to be used as a portable. The BME280 sensor is widely used in scientific studies, can measure air pressure, relative humidity and temperature, and communicate with microcontrollers. For the operation of the system, a software was developed in Arduino IDE (Internal Development Environment) and installed on microcontroller of Arduino UNO R3. The system was left on outdoor conditions with a top cover for one week in spring and one week in summer and it was found that it could record data continuously for one hour intervals.

**Parts of this research were presented as an oral presentation at the "Natural Nutrition, Healthy Life & Sport 2019" congress held on 02-06 October 2019 in Ankara.

Introduction
Nowadays, it is accepted that climate change can threaten food safety. Losses in production areas due to climate change have the potential to create major devastating effects. In agricultural areas, rapid and effective measures should be taken against climate parameters that are not under human control. For this purpose, approaches such as precision or smart agriculture are becoming widespread.
Farmers make their production planning under uncertainty conditions due to the difficulty of predicting many factors such as weather conditions, yield levels, crop prices, agricultural inputs, food demand, and production costs. Measurements of weather conditions from these factors can be used for estimations (Çiftçi et al., 2019).
Low cost microcontroller-based devices that can help to take the necessary measures by rapidly measuring the basic climate parameters are gaining importance especially in the lands of small scale agricultural enterprises. Various data are needed in all agricultural processes to keep production under control. Collecting, transmitting and analyzing data from the field such as temperature, precipitation, air humidity, soil moisture and nutrient levels is an important problem.
For decades, humanity has tried various methodologies in the field of agriculture, since adopting newer techniques to meet the needs of the growing population has become a necessity. Therefore, in the age of technology, modern agricultural methods are developing rapidly (Ramya et al., 2017). The use and spread of information and communication technologies (ICTs) as a means to support agriculture and agricultural production has been particularly important in the last decade. Examples of these technologies include multiple hardware and software applications that provide services to reduce the effects of diseases and pests in crops, as well as real-time monitoring of weather conditions and water quality parameters for farming. Some of the issues that data analytics and big data solutions in agriculture can help solve; providing sustainable supply, increasing productivity, cost reduction and risk management (Corrales et al., 2018).
Spatial and temporal variability are taken into account in precision agriculture which is widely used in fields such as planting, fertilizing, pest control, weed and disease management, harvesting and irrigation (Jimenez et al., 2018). Current and upcoming weather forecasts play a very important role, from large companies to individuals. It generally uses data provided by national weather organizations to counter the adverse effects of weather conditions on daily activities in each country. Unfortunately, this data gives an average estimate for a particular area of interest (Pietraru et al., 2018).
Local weather prediction is necessary for many areas of activity. But it is known that, because of the confused attitude of the atmosphere, weather forecasts can be rather uncertain. Many efforts have taken by meteorologists to improve the quality of the weather forecasts, but forecasts of weather variables remain vague. Weather forecasts can be major importance especially for designate control strategies are used to controlling agricultural systems. Furthermore in the agriculture the understanding of the intercourse between weather evolution and the interchange of soil parameters can only be done by local measurements (Doeswijk and Keesman, 2005). The inadequacy of air monitoring systems in developing low-income countries adversely affects the management of natural resources and associated risks (Strigaro et al., 2019).
Physiological processes in plants such as photosynthesis, respiration, leaf growth and seed germination are all affected by temperature. Also air humidity is important in the functioning of a plant, as it determines the rate of water loss in sweating and has a direct effect on many plants' stomata. Stomata tend to close in dry air, thereby limiting water loss but also reducing CO 2 assimilation (Jones, 2013). In meteorology, the humidity of the air is often referred to as relative humidity. Relative humidity is the ratio of the amount of water vapor present in the air to the amount of water vapor that will saturate the same air and it's expressed in percent (Akman, 2011). Air pressure directly affects cells and organelles in leaves also the diffusion coefficients and degrees of solubility of CO2 and O2 (Takeishi et al., 2013).
Dataloggers are electronic devices that record data from sensors at specified time intervals. They are generally used as a datalogger system consisting of microprocessor, memory and sensors. Being mobile because of their small size is one of the advantages of a datalogger system. Another advantage is the feature of automatically collecting data without human surveillance for a long time. Datalogger systems are designed according to the needs of the specific environments or applications (Kale, 2015). In addition, they can be used in remote areas or dangerous situations. They are more accurate because there is no possibility of human error when recording. With the help of graphics obtained from their records, they help to better understand scientific experiments and scientific concepts (Anonymous, 2020).
Although they have important advantages, dataloggers have some disadvantages. They are expensive and their initial investment costs are high for small businesses. Usually they do not have all the features required by the user, so changes may be required in the software or application. Some data may be lost or not saved if they fail. Some dataloggers can only take readings in the initially configured fixed intervals. In addition, basic training is required to use them (Anonymous, 2020).
Devices that convert physical quantities into the form of electrical signals are called sensors. These quantities can be heat, humidity, motion, pressure, light, etc. (Joshi, 2016). Microcontrollers (MCs) are integrated circuits (ICs) designed specifically for monitoring and control tasks, including all components that enable them to operate independently (Gridling & Weiss, 2007). Microcontrollers can also be described as single chip microcomputers and are also suitable for automation of machines and processes. A typical microcontroller consists of a single IC and has a central processing unit (CPU), input/output (I/O) and serial ports, timers, counters, analog-to-digital converters (ADCs), digital-to-analog converters (DACs), interrupt logic unit, oscillator circuit and so on. The benefits of having all units in one chip; the smaller size of the control board, lower power consumption, more reliable operation capability and ease of integration in application designs. Designers can focus on applications and development aspects rather than dealing with complex interfaces of peripherals, because microcontrollers reduce automation costs and offer greater flexibility. Thanks to their data processing and memory capability microcontrollers can be programmed to make various systems to be intelligent. After learning about the use of a microcontroller family, it is possible to switch from other brands to other microcontroller families. Intel's MCS family, Motorola's 68HC12 family and Microchip's PIC (peripheral interface controller) family are examples of commonly used microcontrollers (Deshmukh, 2007).
Arduino, is a physical programming platform that uses Atmel AVR microcontrollers and has a variety of digital and analogue inputs and outputs. An Arduino card's microcontroller has a preinstalled bootloader software. These development cards can be used to evaluate analog and digital signals from sensors used for a variety of purposes. These evaluation results can be used as input for other systems. It is necessary to select the most appropriate arduino card before working (Beyaz ve Beyaz, 2015). The Arduino hardware, which is an open source platform, has many clones and special purpose cards (D'Ausilio, 2012).
According to D'Ausilio (2012), Arduino UNO R3 is the right platform for some laboratory tests. The most important advantage of the Arduino is that hardware schemes and source codes are available free of charge for many projects in the developing large open source community, forums, and mailing lists. Arduino UNO R3 microcontroller card have an Atmel ATmega328 microcontroller. ATmega328 has 14 digital I/O pins and six analog inputs. The card can be powered with a USB (Universal Serial Bus) connection or an external DC power supply.
The BME280 is an integrated environmental sensor with low power consumption (3.6 µA in 1Hz) and small dimensions (2.5×2.5×0.96 mm) and was developed by Bosch Sensortec especially for mobile applications. The sensor can measure relative humidity (0 to 100%), air temperature (-40 to 85°C) and air pressure (300 to 1100 hPa) at 1 second intervals (Makukha and Yagodkina 2016). Valenzuela et al. (2018) have worked to develop an Arduino-based system for wireless sensor networks that could be used for future agricultural monitoring purposes. They used the BME280 sensor for temperature, humidity and air pressure measurements in the system. They have stated that the system is cost-effective and programmable using Arduino IDE directly. Sudantha et al. (2018) have developed an open source environment monitoring system (EMS) based on Arduino Mega2560. The parameters measured by the system are solar radiation, wind direction and speed, air temperature, precipitation, relative humidity, soil moisture and air pressure. They used BME280 sensor for humidity and air pressure measurements. They placed 27 samples of this system in different locations in Sri Lanka and made measurements from March 2018 to July 2018. They used Davis Vantage Pro-2 stations as reference stations to check the accuracy of the developed system. Strigaro et al. (2019) have developed arduino based fully open architecture and low-cost weather monitoring system for low-income and developing countries. They used the BME280 sensor for temperature, humidity and air pressure measurements in their research. They tested the system for an 8-month period and compared the observations with an authorized weather station nearby. They have reported that the system collects data of appropriate quality for natural resource and risk management.

Materials and Methods
Due to dataloggers disadvantages, it is important to develop low-cost, user-customizable and re-programmable datalogger systems for specific purposes in order to record the desired parameters for agriculture. In this scope, develop a customizable and re-programmable datalogger system which can measure the basic meteorological values for agricultural purposes under field conditions with lowcost parts was the main scope of the study. For this purpose, an Arduino UNO R3 (Figure 1) was chosen as the microcontroller board used in the developed system (Figure 2). Similarly a BME280 module (Figure 3) was chosen because it can collect air temperature, relative humidity and air pressure values in a single module. In addition to the Arduino UNO R3 and the BME280, the system consists of a storage unit (SD memory card), a character LCD and an USB powered battery unit that allows the system to be used as portable. All parts of the system are chosen at low-cost.   A microcontroller software was developed in Arduino IDE (Internal Development Environment) with the C/C++ programming language and installed in the Arduino UNO R3's Atmega328 microcontroller to enable the system to record data at one hour intervals. Microcontrollers are designed to work continuously and therefore their software is prepared in the form of an "infinite loop". The software developed is also programmed to run continuously in an "infinite loop".
After switching on the Arduino, the data is first received from the BME280, then displayed on the LCD and finally written to the SD card, and then the same cycle is repeated once every hour. The one-hour intervals are provided using the Arduino's internal timer function.
The developed low-cost system was placed at a distance of about 200 meters from Haymana Tarım Meteorological Station ( Figure 4) and it was left on outdoor conditions with a protective top cover for one week in spring and one week in summer seasons. ICAO call sign of the station is HTRM and its geographical position is 39°36'46.84"N, 32°40'19.27"E. The air pressure, relative humidity and air temperature data obtained from Haymana Tarım Meteorological Station (HTMS) in the spring and summer periods and data obtained from the low-cost system (LCS) in the same periods were compared with regression analysis. Regression models were formed by comparing the results of the regression equations and the measurement.

Results
During the development phase and the fieldwork period, it was observed that the system was able to continuously record data on the data storage unit at one hour intervals, as determined in the software. The data obtained from HTMS and the data obtained from the LCS were compared with the regression analysis.
One week measurement period in spring season, the regression value of air temperature, relative humidity and air pressure values between the HTMS and the LCS found as 90.9%, 92.8% and 85.3% and can be seen in Figure 5-7 respectively.   Similarly, one week measurement period in summer season, the regression value of air temperature, relative humidity and air pressure values between the HTMS and the LCS found as 92.6%, 89.9% and 83.8% and can be seen in Figure 8-10 respectively.

Discussion and Conclusion
It is expected that the measurement of spatial and temporal variability will gain much more importance in future agriculture shaped by approaches such as precision farming. It is clear that a large number of measuring devices will be needed for the monitoring of these variations. Therefore, it is important that the devices to be developed are multifunctional, miniature, portable and cost-effective.
The microcontrollers and the basic sensors connected to them have the capacity to reduce the purchase costs of the measuring devices and the added cost to food prices, since they are very inexpensive and easily portable. The total price of the components used in this case study is less than $50. Another important point is that with the modular and easy to learn microcontroller platforms such as Arduino, farmers and experts have the opportunity to design their own special measuring devices. Of course, these devices cannot compete with laboratory measuring devices and precision meteorological stations in terms of measuring accuracy. However, when the situation is considered as cost-benefit, it can be useful. Due to their reasonable prices, they can be expected to receive interest in developing countries and provide significant benefits. In addition, capital losses will be small due to thier low costs when they are damaged.
As a result; the microcontroller based measurement system developed is an example of similar systems that can be used in agricultural activities due to its low cost and portable although it is less sensitive than meteorological stations. In the future, it is expected that inexpensive agricultural datalogger devices that can measure more climate parameters will be developed and will be widely used in agriculture. According to this expectation, sensors measuring the values such as air temperature, air humidity, air pressure, solar radiation, wind speed, wind direction and precipitation can be added to the devices to be developed in the future studies.