# Smart Hydroponic Cultivation System for Lettuce
## 2 Materials and Methods
### Monitoring and Control System  
For the implementation of the monitoring and control system, based on the state of the art, continuous monitoring of critical environmental variables such as air temperature, RH, \(CO_{2}\) and PPF was identified as a priority. These variables directly affect photosynthesis [20,21], making them a priority for the automation of the growth chamber. The proposed smart monitoring and control system was developed based on the architecture presented by [17,36], which suggests a six-layer structure. However, this work simplifies the architecture into five layers: physical layer (Figure 3A), network layer (Figure 3B), middleware layer (Figure 3C), service layer (Figure 3D) and user experience layer (Figure 3E). The analysis layer is not considered in the proposed architecture, as it is planned for future work. The physical layer of the proposed system, shown in Figure 4, utilizes a board based on the ATmega2560 microcontroller (Microchip Technology Inc., Chandler, AZ, USA) (Figure 4I) to collect data every minute from sensors that monitor environmental conditions within the growth chamber, including air temperature, RH, \(CO_{2}\) and PPF (Figure 4H). Based on this data, decisions are made using an ON/OFF control scheme with hysteresis to regulate the activation of actuators. RH was stabilized using four ultrasonic humidifiers (model UH200, Bontill, Plano, Texas, USA), each with a 2.5 L capacity (Figure 4D). Their activation is managed via a relay module (Figure 4E), which also controls the pumps responsible for delivering the nutrient solution in the NFT system (Figure 4B). Air temperature is maintained using a mini split air conditioner (model X32, Mirage, Monterrey, Mexico) (Figure 4A). Additionally, a real-time clock (RTC) circuit (model DS1302, Maxim Integrated, San Jose, CA, USA) (Figure 4F) was implemented to automate decisions based on the time of day, ensuring photoperiod regulation through full-spectrum LED lamps  
Figure 2: Model of the NFT hydroponic system used in the experiment. The system is composed of (A) hydroponic channels; (B) root system exposed to the flow of the nutrient solution; (C) nutrient solution circulating through the channels; (D) nutrient solution distribution system powered by a pump; (E) support structure constructed with CPVC piping measuring 100 cm long, 50 cm wide and 27 cm high; and (F) nutrient solution storage tank. The arrows indicate the direction of the solution flow. (model INWT80421265 Ec, Barrina Inc., Livermore, CA, USA) (Figure 4C). The program is executed automatically every minute. Figure 4: Diagram of the physical layer of the proposed agricultural monitoring and control system. The architecture includes (**A**) mini split air conditioning unit for air temperature control; (**B**) NFT hydroponic system for plant cultivation; (**C**) full-spectrum LED lamps; (**D**) ultrasonic humidifiers; (**E**) relay module responsible for actuating the control mechanisms; (**F**) real-time clock circuit; (**G**) IoT module for data transmission; (**H**) set of sensors for environmental monitoring; and (**I**) development board based on the ATmega2560. Figure 3: Architecture of the proposed smart agricultural monitoring and control system based on IoT architecture. The system consists of five layers: (**A**) physical layer, which includes environmental sensors, a real-time clock module, video monitoring, growth lamps, humidifiers, pumps, a mini split air conditioner, the ATmega2560 microcontroller and an IoT module; (**B**) network layer, which enables data transmission via the internet; (**C**) middleware layer; (**D**) service layer, based on the Thing5 peak platform; and (**E**) user experience layer, accessible from mobile devices or computers via a web connection. The selection of the ATmega2560 microcontroller (Microchip Technology Inc., Chandler, AZ, USA) was based on its accessibility, ease of implementation and the extensive range of available documentation, which facilitates rapid development of embedded systems.