## 2 Proposed System
### Leaf Temperature Monitoring  
The schematic diagram of leaf temperature monitoring is illustrated in Figure 2. It consists of three units: an AMG8833 thermal camera, a Raspberry Pi Zero W single-board computer, and the Haiwell IoT Cloud HMI. The AMG8833 measures the temperature of the monitored object on the \(8\times 8\) pixels, as shown in the figure (top left). These temperature data are then read by the Raspberry Pi Zero W using the I\({}^{2}\)C protocol and converted to the thermal image. The image processing task can be performed once the data are in image format. It is worth noting that for the leaf temperature calculation using the Otsu thresholding, the pixel values are the original temperature data of the thermal camera. However, the pixel values of saved and displayed thermal images are converted to the heat-map color for easy visualization. The thermal image is also stored in the SDCard memory of the Raspberry Pi Zero W for data analysis. At first, we collect the images during the day to observe the variation in the leaf and background temperatures. The results from observation show that the temperature of leaf objects is always lower than the background. This can be analyzed from the fact that the temperature of concrete and soil of the background tend to be higher than the air temperature. Since the experiments are conducted in a tropical climate where the daily temperature ranges from 20 to 40 \({}^{\circ}\)C, the leaf temperature will be lower than the background (concrete and soil) temperature. Based on this observation, we define the leaf temperature by a simple image segmentation using the Otsu thresholding. \begin{table}
\begin{tabular}{l c} \hline Power supply & 5–18 V DC \\ \hline Processor & Cortex-M3 \\ \hline Main frequency & 96 MHz \\ \hline Operating system & FreeRTOS \\ \hline Wireless standard & 802.11 b/g/n \\ \hline WiFi band & 2.412–2.484 GHz \\ \hline \multirow{2}{*}{Neywork protocol} & IP, TCP, UDP, DHCP, DNS, HTTP Server/Client, ARP, BOOTP, \\  & AutoIP, ICMP, Web socket, Telnet, uPNP, NTP, Modbus TCP \\ \hline Network mode & STA/AP/STA + AP \\ \hline Serial port & RS485 \\ \hline Price & US$ 17 \\ \hline \end{tabular}
\end{table} 
Table 6: Elfin-EW11 specifications. The Otsu thresholding is a simple and popular image segmentation technique for separating the object from background. The Otsu thresholding is an automatic thresholding technique, where the optimal threshold (\(T_{opt}\)) is obtained by maximizing between-class variance of the background and foreground. The \(T_{opt}\) is calculated as [55]:  
\[T_{opt}=\text{argmax}\Bigg{\{}\frac{cf(T_{opt})\times\left[1-cf(T_{opt}) \right]\times\left[m_{f}(T_{opt})-m_{b}(T_{opt})\right]^{2}}{cf(T_{opt})\times \sigma_{f}^{2}(T_{opt})+\left[1-cf(T_{opt})\right]\times\sigma_{b}^{2}(T_{opt })}\Bigg{\}} \tag{1}\]  
\[cf(g)=\sum_{i=0}^{g}pf(i) \tag{2}\]  
\[m_{f}(T)=\sum_{g=0}^{T}g\times pf(g) \tag{3}\]  
\[m_{b}(T)=\sum_{g=-T+1}^{255}g\times pf(g) \tag{4}\]  
\[\sigma_{f}^{2}(T)=\sum_{g=0}^{T}\left[g-m_{f}(T)\right]^{2}\times pf(g) \tag{5}\]  
\[\sigma_{b}^{2}(T)=\sum_{g=-T+1}^{255}\left[g-m_{b}(T)\right]^{2}\times pf(g) \tag{6}\]  
where \(pf(g)\) is the probability mass function, \(g\) is the intensity value in the image (\(g=0\),..., 255), \(m_{f}(T)\) is the mean of the foreground, \(m_{b}(T)\) is the mean of background, \(T\) is the thresholding level, \(\sigma_{f}^{2}(T)\) is the variance of the foreground, and \(\sigma_{b}^{2}(T)\) is the variance of the background. The algorithm to calculate the leaf temperature is as follows:  
Figure 2: Schematic diagram of leaf temperature monitoring. 1. Apply the Otsu thresholding technique to separate an image into two parts, foreground and background, using an optimal threshold \(T_{opt}\);
2. The foreground pixels are defined as the pixels whose values are lower than \(T_{opt}\), and the background pixels are defined as the pixels whose values are higher than \(T_{opt}\);
3.