# Smart Hydroponic Cultivation System for Lettuce
## 2 Materials and Methods
### Monitoring and Control System
Its compatibility with the MODBUS RS-485 communication protocol via the Universal Asynchronous Receiver-Transmitter (UART) module, along with the wide availability of reliable libraries, enabled the integration of various industrial sensors for environmental monitoring. Although there are more advanced development boards such as the STM32, which offer greater processing capacity, modular architecture and support for real-time operating systems, these platforms require more specialized programming environments and are associated with higher costs. Using the MODBUS RS-485 communication protocol, the microcontroller retrieves data from the sensors. This protocol enables the interconnection of up to 32 devices on a single bus segment, with a communication range of up to 1200 m under standard conditions. Agronomic sensors with an IP67 rating were selected, providing dust resistance and allowing them to function effectively under higher RH conditions compared to other types of sensors. The selected sensors for each variable, along with their measurement ranges, are detailed in Table 2.  
All sensors were used with their factory calibration, in accordance with the specifications provided by the manufacturer. Their proper functioning was verified by comparison with other measurement systems. Programming logic enables automatic activation of control mechanisms, such as ultrasonic humidifiers and full-spectrum LED lamps, based on ambient conditions inside the growth chamber and predefined schedules. As described in Listing 1, humidity control was implemented by reading the air temperature and RH sensor at one-minute intervals. The system compares the measured value with predefined maximum (hum_max) and minimum (hum_min) RH thresholds. When the RH inside the growth chamber drops below the minimum threshold, the humidifier activates; conversely, when the humidity exceeds the maximum threshold, the humidifier switches off. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Model** & **Manufacturer** & **City, Country** & **Environmental Variable** & **Measurement Range** \\ \hline \multirow{2}{*}{JXBS-3001-TH-RS} & \multirow{2}{*}{JXCT Electronics} & \multirow{2}{*}{Jinan, China} & Air temperature & \(-\)40–80 \({}^{\circ}\)C \\ \cline{3-5}  & & & Relative Humidity & 0\%RH–100\%RH \\ \hline \multirow{2}{*}{JXBS-3001-\(CO_{2}\)-RS} & \multirow{2}{*}{JXCT Electronics} & \multirow{2}{*}{Jinan, China} & \(CO_{2}\) & 0–500 ppm \\ \cline{3-5}  & & & & \\ \hline \multirow{2}{*}{RS-GH-N01-AL} & \multirow{2}{*}{
\begin{tabular}{c} Shandong Renke Control \\ Technology Co., Ltd. (Renke) \\ \end{tabular} } & \multirow{2}{*}{Jinan, China} & \multirow{2}{*}{PPF (400–700 nm, PAR)} & \multirow{2}{*}{0–2500 \(\upmu\)mol m\({}^{-2}\) s\({}^{-1}\)} \\ \cline{1-1} \cline{5-5}  & & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Sensors used in the physical layer of the proposed system. The table presents the model, manufacturer, city and country of origin, as well as the environmental variable measured by each sensor and its respective measurement range. ```
```  
Listing 1: Code snippet used to control the activation and deactivation of the humidifiers based on ambient RH. void pedirHumTemp(){ if(node.readHoldingRegisters(0x0000, 2) == node.ku8 MBSuccess){  Humedad = node.getResponseBuffer(0x00)/10.0f;//RH  Temp = node.getResponseBuffer(0x01)/10.0f;//Air Temperature } } void control_humedad(){ if(Humedad < hum_min){ digitalWrite(HUMID, LOW);//Activate humidifiers } elseif(Humedad > hum_max){ digitalWrite(HUMID, HIGH);//Disactivate humidifiers } }
```

Figure 5 shows the behavior of the environmental variables--air temperature, RH, \(CO_{2}\) and PPF--inside the plant growth chamber. The control over the lamps can be observed, as they are turned on at 2:00 P.M. and turned off at 4:00 A.M. the following day. Similarly, control actions to maintain air temperature and humidity within the established ranges are also evident.