Keywords

1 Introduction

The value of the world orchid market is around 400 million US dollars in 2019, and most of the orchid are tropical ones [1]. Also, more than 69 nations worldwide have orchid markets in their countries, and significant exporters include Thailand, Japan, the United States, Vietnam, China, and India, which currently account for 68.28% of the total export [1]. Among those countries, Thailand is the world’s biggest exporter of the cut orchid. In Thailand, most orchid farms are of traditional farming; that is, agriculture is done under opened and uncontrolled environment. Therefore, to increase the yield and to industrialize the farming, ICT and embedded system technologies have been suggested since 2003 [13]. Those technologies can be used in monitoring and controlling environmental parameters concerning the cultivation, and with them, the intensive farming is just a few steps ahead. The core idea of such monitoring and control systems is intuitive and straightforward, i.e., the environment should be controlled to match the plant’s needs concerning current environmental factors [2, 14]. For orchid farming, the factors that affect the quality and quantity of the product are temperature, humidity, nutrients, air quality, and light intensity [12]. One of the crucial and demanding factors in automatic monitoring is the air humidity since the humidity sensor tends to degrade when it is continuously exposed under a high humid condition [4]. As a consequence and in a sense, data read from the humidity sensor are quite noisy. Therefore, as the first step toward orchid greenhouse control, this work’s focus is to improve the accuracy of the humidity sensor by using a data-driven approach.

One of the popular methods in sensor accuracy improvement is Kalman filtering. For example, A. Lesniak et al. applied a Kalman filter to magnetotelluric recordings to reduce noise in multichannel data and found that it is effortless and useful in practice [6]. The Kalman filter has been used not only to improve the accuracy of sensor data but also to extract a clean signal from a noisy one. M. Fujimoto et al. used a Kalman filtering algorithm to remove noise from speech signals and found that it worked comparably to traditional methods [3]. Besides noise reduction or accuracy improvement, the Kalman filter has been adopted in greenhouse control systems. For example, D. H. Park et al. used the Kalman filter to automatically control the greenhouse climate [9]. In their work, a feedback control system with a Kalman filter was used to maintain the temperature and humidity to the predefined values. Similarly, P. Shi et al. applied an extended Kalman filter for the same purpose [11]. According to their model, the temperature and humidity were controlled by controlling the heater, ventilation, and foggy machine. The result of this work is impressive. It could minimize the error between the values read from the sensors and those of the requirements. However, the focus of this work is different from ours since it did not aim to improve the accuracy of the sensor itself.

To the best of our knowledge, no work has yet to apply the Kalman filtering algorithm to improve the accuracy of the humidity sensor used in the orchid agriculture domain. Therefore, this paper aims to investigate such the application and to report experiments conducted to verify its effectiveness. This paper has also studied the possibility of applying it in the case that the sensor fails to operate normally. In this case, the Kalman gain will be adjusted so that the Kalman filter believes more in the prediction model.

2 Background

The overview of the monitoring system that was deployed to collect data used in this work and, for the completeness in itself, the one-dimensional Kalman filter, are introduced in this section.

2.1 Overview of an Orchid Greenhouse Monitoring System

The monitoring system for collecting data is installed at a commercial greenhouse of the size of \(6\ \times \,20\) square meters, which is located in Ratchaburi, Thailand. The system consists of 21 humidity and temperature sensors, three dataloggers, a gateway, some fan and foggy controllers, and a weather station. Each humidity-temperature sensor is spatially separate to cover \(2\ \times \,2.5\) square meters. Data read from it are to be sent to a datalogger, of which its function is to re-format the collected data and forward them to the gateway. The gateway then regularly send data from all loggers to a database through a GPRS network. The user can access those data via a web browser.

The humidity-temperature sensor used in the project is a digital sensor, called SHT31, of the Sensirion company. It operates based on the principle of capacitance measurement. According to the collected data under this project for more than a year, we found that some sensors work improperly after eight months. For example, data are noisier and drifted from the actual values. This is in part due to the environment under which they are exposed. For instance, spraying liquid such as water (for controlling humidity) or insecticide chemicals constantly for some time could cause failure in relative humidity measurement. In such a high humid condition, this problem with the polymer dielectric-based sensor has been broadly observed [4].

2.2 One-Dimensional Kalman Filtering

According to the Kalman filtering, we can describe any linear system in the steady-state by two equations: state equation and measurement equation [5,6,7,8, 10]. The state equation assumes that the state \(x_k\) of a system at time k is evolved from a linear combination of the previous state at time \(k\!-\!1\), a control input \(u_{k-1}\), and some zero-mean process noise \(w_{k-1}\) with a variance of Q. Thus,

$$\begin{aligned} x_k = Ax_{k-1} + Bu_{k-1} + w_{k-1}, \end{aligned}$$
(1)

where A is a known state-transition factor that applies the effect of the previous state on the current state, and B is a control input factor that applies the effect of the input on the state.

The output \(y_k\) of the system that we can measure is assumed to be a linear combination of the state \(x_k\) that we want to estimate and some measurement white noise \(v_k\) with a variance of R. Thus,

$$\begin{aligned} y_k = Cx_k + v_k, \end{aligned}$$
(2)

where C is an observation factor that relates the state \(x_k\) to the measurement \(y_k\). In a nutshell, the Kalman filter estimates \(x_k\), which is denoted by \(\hat{x}_k\) and called a posteriori estimate, by combining a predicted state estimate \(\hat{x}^-_k\) (a priori estimate) and the difference between the measurement \(y_k\) and a predicted measurement \(\hat{y}_k\). That difference is sometimes called a residual or a measurement innovation. Thus, the state estimate can be expressed mathematically as

$$\begin{aligned} \hat{x}_k = \hat{x}^-_k + K(y_k - \hat{y}_k) = \hat{x}^-_k + K(y_k - C\hat{x}^-_k), \end{aligned}$$
(3)

where K is a blending factor, called the Kalman gain. The Kalman filtering algorithm calculates the Kalman gain K such that the expectation of the square of the difference between the state \(x_k\) and the state estimate \(\hat{x}_k\) is minimized. The difference (i.e., \(x_k\!-\!\hat{x}_k\)) is called a posteriori estimate error, and the expectation is a posteriori error variance, which is denoted by \(P_k\).

The Kalman filtering algorithm consists of five steps as follows. First, given the previous state estimate \(\hat{x}_{k-1}\), it projects the state ahead from the equation

$$\begin{aligned} \hat{x}^-_k = A\hat{x}_{k-1} + Bu_{k-1}. \end{aligned}$$
(4)

Note that, for \(k\!=\!1\), we denote the previous state estimate \(\hat{x}_{k-1}\) by \(\hat{x}_0\), which is called the initial state.

Second, a priori error variance \(P^-_k\), which is defined by the expectation of the square of the difference between the state \(x_k\) and the predicted state estimate \(\hat{x}^-_k\), is projected ahead from the equation

$$\begin{aligned} P^-_k = AP_{k-1}A + Q, \end{aligned}$$
(5)

where \(P_{k-1}\) is the previous (a posteriori) error variance. For \(k\!=\!1\), we denote the previous error variance \(P_{k-1}\) by \(P_0\), which is called the initial error variance. In a sense, \(P^-_k\) is a measure of the uncertainty in the state estimate \(\hat{x}_k\) due to a process noise and the propagation of the uncertainty of the previous predicted state estimate \(\hat{x}^-_{k-1}\). The first two steps form the prediction stage of the algorithm.

Third, the Kalman gain K is computed by the equation

$$\begin{aligned} K = \frac{P^-_kC}{CP^-_kC + R}. \end{aligned}$$
(6)

Fourth, the Kalman gain K is used to scale the measurement innovation (i.e., \(y_k\!-\!C\hat{x}^-_k\)), and the state estimate \(\hat{x}_k\) is updated by adding the scaled measurement innovation to the predicted state estimate \(\hat{x}^-_k\), i.e.,

$$\begin{aligned} \hat{x}_k = \hat{x}^-_k + K(y_k - C\hat{x}^-_k). \end{aligned}$$
(7)

Last, the state error variance is updated by the equation

$$\begin{aligned} P_k = (1 - KC)P^-_k. \end{aligned}$$
(8)

The steps from number three to number five form the measurement update stage of the Kalman filtering algorithm, and it can be seen that given some initial state estimate \(\hat{x}_0\) and some initial error variance \(P_0\), the Kalman filter can estimate the state \(x_k\) for any k.

3 Proposed Method

As mentioned in the previous section, the Kalman filtering algorithm calculates the Kalman gain to weigh its belief between the prediction and the measurement. In this work, the latter is data read from the humidity sensor at the location of interest. The former used to estimate a humidity value is constructed based on another Kalman filter. This second Kalman filter projects the humidity value by assuming that the data read from neighbour sensors are a sequence of measurements, and the predicted (a priori) state estimate is the previous state estimate.

Figure 1 shows the structure of the proposed method. As an instance, in our experiment, we want to accurately estimate the actual humidity value of the sensor no. 4. The other sensors that surround the sensor no. 4 are the neighbour sensors, as shown in Fig. 1(a). In this work, the state equation of the first Kalman filter is formulated as follows.

$$\begin{aligned} x_k = x_{k-1} + w_{k-1}, \end{aligned}$$
(9)

where \(x_k\) is the humidity value at the location of the sensor no. 4 at time k and \(w_{k-1}\) is the process noise at time \(k\!-\!1\). The measurement equation is

$$\begin{aligned} y_k = x_k + v_k, \end{aligned}$$
(10)

where \(y_k\) is the data read from the sensor no. 4 at time k and \(v_k\) is the measurement noise at time k. The predicted (a priori) state estimate \(\hat{x}^-_k\) is then computed by

$$\begin{aligned} \hat{x}^-_k = \hat{x}_{k-1}, \end{aligned}$$
(11)

where \(\hat{x}_{k-1}\) is the previous state estimate that is determined by the second Kalman filter, which is called the inner Kalman filter in this work. Hence, the first Kalman filter is the outer one.

The state equation and the measurement equation of the second Kalman filter are as follows.

$$\begin{aligned} x^p_l = x^p_{l-1} + w^p_{l-1}, \end{aligned}$$
(12)

and

$$\begin{aligned} y^p_l = x^p_l + v^p_l, \end{aligned}$$
(13)

where \(x^p_l\) is the humidity value at time l (and it is to be used as the previous state estimate \(\hat{x}_{k-1}\) of the first Kalman filter), \(w^p_{l-1}\) is the process noise at time l of the second Kalman filter, \(x^p_0\) is the initial state estimate of the second Kalman filter, \(y^p_l\) is the measurement at time l of the second Kalman filter, and \(v^p_l\) is the measurement noise of the second Kalman filter. Similarly, the predicted (a priori) state estimate \(\hat{x}^{p-}_l\) is computed by

$$\begin{aligned} \hat{x}^{p-}_l = \hat{x}^p_{l-1}, \end{aligned}$$
(14)

where \(\hat{x}^p_{l-1}\) is the previous state estimate and is assumed to be a constant for a given k, which is the average value of \(y^p_l\)s.

Let N be a set of indices of the neighbour sensors. For instance, in our experiment, \(N\!=\!\{1,2,6,7\}\), as illustrated in Fig. 1(a). The proposed method assumes that \(y^p_l\) for \(l\!=\!1\) to n(N), where n(N) is the cardinality of N, is a sequence of \(y_{k,i}\), where \(y_{k,i}\) is the data read from the neighbour sensor no. i for \(i\in \!N\). Also, it assumes that the initial state estimate \(x^p_0\) is the average value of the humidity values of \(y_{k,i}\) for all is.

Fig. 1.
figure 1

Positions of sensors used in this paper and the diagram of nested Kalman filter.

4 Experiment and Results

4.1 Experimental Setup

In this work, humidity data are collected and sent to the database every 5 min. Therefore, there are 288 datapoints a day. In our experiment, the duration for data analysis is about 314 days, i.e., from 21 September 2018 to 31 July 2019. The aim of this work is to apply the proposed method to estimate the actual humidity value read by the sensor no. 4. Also, we assumed that that actual humidity value could be approximated by the humidity value read by the sensor no. 5. The reason for this assumption is that, according to our back analysis on variances and drifts of data from all sensors, we found that the sensor no. 5 was most stable and has the smallest drift. In addition, the sensors no. 4 and no. 5 are close to each other. As shown in Fig. 1, the neighbour sensors are sensors no. 1, no. 2, no. 6 and no. 7.

We compared the proposed method with the average model Kalman filter and interested sensor. The average model uses the average value from a nearby sensor instead of the inner Kalman filter to be used as the prediction state.

4.2 Experimental Result

Figure. 2 shows the estimated values of the proposed method, compared to data read from sensor no. 4, the average of data read from neighbour sensors, and values estimated a Kalman filter, of which its prediction is the average of data read from neighbour sensors (which is denoted by ‘average model’ in the figure). In this work, we use the root-mean-square error (RMSE) to evaluate the error between the reference sensor no. 5 and other methods. The comparison of the RMSEs among different methods is shown in Table 1.

Fig. 2.
figure 2

Humidity data obtained from the proposed method in comparison with those obtained from other methods.

Table 1. Comparison of the RMSEs of the proposed method and other methods.

When the nested Kalman filtering was deployed in improving the accuracy of the humidity measurement, the average RMSE dropped from 2.92754 to 1.99012, i.e., the average RMSE dropped approximately 32.02%. The average RMSE of the average model was 2.15350, which is 26.44% less than the average RMES of sensor no. 4. It can be noticed that the RMSE values obtained from the proposed method were less than the average model by approximately 7.59%. Therefore, the Kalman filtering with the proposed method could considerable improve the accuracy of the humidity sensors.

5 Discussion

The proposed method not only can improve the accuracy of sensor but also has a potential for estimating actual values when the sensor works improperly. For example when a sensor is malfunction, as shown in Fig. 3, we can adjust the variances of the measurement so that the Kalman filter relies more on the prediction. The result from the adjustment is shown in Fig. 3.

Note that this adjustment was done based on back analysis of the collected data by hand, not by automatic procedure, which is to be investigated further.

Fig. 3.
figure 3

Applying the proposed method to a malfunction sensor.

6 Conclusion

This paper proposed a method for accuracy improvement in humidity measurement by using two nested Kalman filters. The outer Kalman filter is used to estimate the actual values of humidity data read from one sensor, and the inner Kalman filter is used as the prediction model of the outer Kalman filter. The experimental results showed that this technique could improve the accuracy of the humidity measurement considerably.