Frontiers in Computing and Intelligent Systems ISSN: 2832-6024 | Vol. 12, No. 3, 2025 79 Design and Implementation of an IoT‐Based Smart Greenhouse System Kunlin Miao, Zhaobo Wang and Jinchao Zhao Zhengzhou University of Light Industry, Zhengzhou Henan, 450000, China Abstract: The integration of Internet of Things (IoT) technology into greenhouse systems effectively addresses prevalent challenges such as temperature and humidity imbalances, as well as insufficient lighting in greenhouse management. This system utilizes the STM32 microcontroller as its control core and incorporates various modules, including soil moisture sensors, temperature sensors, and light-sensitive sensors. The system's design comprises an environmental parameter monitoring module, an intelligent decision-making module, an execution module, a network communication module, and a human-machine interaction module. By employing intelligent algorithms, it automatically regulates irrigation, supplementary lighting, and other equipment. Consequently, this approach ensures optimal growth conditions for plants, simplifies maintenance processes, and enhances the survival rate of green plants. Keywords: Smart Greenhouse; Internet of Things; STM32. 1. Introduction The trend of the Internet of Things is reshaping various sectors, including facility agriculture. By real-time monitoring of the temperature and humidity coupling relationship within the crop growth environment, the growth status of crops can be precisely analyzed. Modern agricultural systems have deployed intelligent sensor networks in scenarios such as grain monitoring and greenhouse regulation, achieving closed-loop management that encompasses dynamic collection of environmental parameters, threshold warnings, and automatic adjustments. In China, Huawei's [1] agricultural intelligent agent has successfully integrated 5G+AI greenhouse technology into pilot agricultural fields in Shandong, reducing human intervention to 10% and significantly conserving manpower and resources. Topyun Nong[2] not only employs traditional sensors but also integrates infrared sensors and cameras for pest identification. After analyzing sensor data, including temperature and humidity, it links with steaming and fumigation equipment for automated pest control, thereby reducing the use of chemical agents and avoiding unnecessary harm to humans. This technology has been widely adopted in grain warehouses across various regions of the China Grain Reserves Corporation. The gap between domestic and international research in this field is relatively narrow, yet there are still some technical approaches worth emulating. Dutch company Priva[3] combines traditional sensors with weather forecasts to predict environmental conditions, achieving a globally leading resource utilization rate in Dutch tomato greenhouses. Similarly, Spread, a Japanese firm, has significantly boosted agricultural yields by deploying multi-layer sensor networks in vertical farms and integrating them with industrial robots to dynamically optimize growth parameters. 2. Overall Design The system is designed around the STM32F103C8T6 microcontroller, employing a modular architecture. Environmental data is gathered using sensors such as the YL- 69 humidity sensor, the DS18B20 digital temperature sensor, and the GL5528 photoresistor (for illuminance detection). This collected data is processed by the MCU, and subsequently, it is transmitted to the APP for real-time monitoring and control through the ESP8266 WIFI module. The comprehensive block diagram is illustrated in Figure 1. A/D conversion STM32 DS18B20 Tempreature Collection Button Settings USB-5V Input A/D conversion WIFI Serial Port Wireless Communication Transmission Control Light Control Water Pump Control Buzzer Alarm Fig 1. Block Diagram 80 The microcontroller integrates a central processing unit (CPU), memory (ROM/RAM/Flash), and programmable input-output ports (GPIO). The control program is compiled and loaded via a dedicated development environment. This system utilizes the STM32F103C8T6, a microcontroller featuring an ARM Cortex-M3 core, which operates within a voltage range of 2.0-3.6V. It boasts 64KB of Flash memory and 20KB of SRAM, and supports online debugging as well as rapid flash erasing and writing. Thanks to its high cost- performance ratio and low power consumption, it delivers precise real-time control in smart greenhouse systems and Internet of Things terminal devices. The software architecture of this system is meticulously crafted based on a structured and modular design philosophy, showcasing exceptional functional scalability. All program codes are meticulously developed and implemented in the C programming language. The humidity sensing unit efficiently transmits the collected raw binary data of humidity via a three-wire digital interface to the main control chip. This data is subsequently processed by the built-in nonlinear compensation algorithm, yielding precise physical quantity values. The refined processing results are then seamlessly transmitted through the bus to the LCD display module for clear visual output. The software component is expertly developed using the Keil 5 integrated development environment. The software flowchart of the system is illustrated in Figure 2. Start STM32 Configure Initialization WIFI Serial Port Initialization OLED WIFI/ Button Settings Manual Mode Direct Button Control Water Pump/ Light/ Fan Set Humidity Upper Limit Set Temperature Upper Limit Set Light Lower Limit Lower LimitUpper LimitUpper Limit Turn on the Fan Turn on the Water Pump Turn on the Light Buzzer Audible Visual Alarm Buzzer Audible Visual Alarm OLED LCD Display Return Y N YY N Fig 2. Flowchart of System 81 During the execution of the main program loop, the key trigger status is initially detected. Upon detection of user operation, the system enters the threshold setting mode to update the upper limit value of the alarm. Subsequently, the data acquisition process is initiated to retrieve the sensor's raw data and perform accuracy calibration, followed by threshold comparison and evaluation. If the environmental humidity is found to exceed the safety range, the system promptly activates the sound and light alarm device and automatically maintains the alarm state until the environmental parameters fall back below the threshold. In the realm of industrial process control, data acquisition systems face significant challenges due to the complex electromagnetic environments they encounter. The pervasive electromagnetic interference presents at production sites [23] overlays high-frequency noise onto the weak analog signals emitted by sensors, severely compromising measurement accuracy and emerging as the principal technical bottleneck for these systems. To address this, digital filtering algorithms and self-recovery mechanisms for abnormal states are integrated at the software level, creating a synergistic software-hardware solution for noise suppression. 3. System Module Design 3.1. Temperature Acquisition Module The temperature acquisition module is realized by controlling the DS18B20 digital temperature sensor, and conducts data interaction with the STM32 microcontroller using the single-bus protocol. Finally, the measurement results are presented on the OLED display screen [4]. The execution process of this subroutine includes the following key operations: Firstly, complete the initialization configuration of the GPIO port, and then send a reset pulse to start the sensor communication protocol. When the response signal of DS18B20 is detected, the temperature data reading and format conversion are performed, and finally the processed data packet is transmitted to the display unit to complete the periodic task. 3.2. Soil Moisture and Light Intensity Collection Module The soil moisture and light intensity detection modules are both realized through the built-in ADC analog-to-digital conversion unit of the microcontroller. Both adopt the same data processing architecture and only distinguish multiple parameters by selecting different ADC input channels. The analog signal output by the sensor is transmitted to the designated ADC pin through the signal conditioning circuit (configured as B0 and B1 channels in this system), and then quantization conversion is performed after initialization by the ADC module. Configure the working mode of the target ADC channel and perform module initialization to start the conversion process and obtain the original data: ad_value_temp = Read_ADC(0), perform the 8-bit data sequence reading operation, and convert the obtained digital quantity into physical quantity values. This conversion process strictly follows the standard ADC workflow. The key operations include: analog signal sampling and holding, successive approximation quantization conversion, serial reading of digital quantity and numerical reconstruction. The system achieves the precise extraction and synthesis of data bits through cyclic shift and bit operation instructions [5], ensuring the accuracy of the measurement results. 3.3. Hardware Design Module The key interface adopts a four-pin mechanical switch element. In practical applications, only two sets of signal lines need to be connected (the electrical characteristics between the pins are the same). Its core detection mechanism is based on the recognition of GPIO port level status: When the key is triggered, the corresponding I/O port level jumps from high (1) to low (0), and the main control chip triggers the function response by real-time scanning of the port status changes. The four function keys are respectively defined as: Increment key: Forward switching of parameters/modes; Subtraction key: Reverse adjustment of parameters/modes; Confirmation key: Parameter writing and interface jump; Manual control key: Emergency drainage trigger [6]. The functions of each key are managed in layers, and differentiated control functions are mapped on different operation interfaces (parameter setting, real-time monitoring, historical query). In the software implementation, a two-level anti-false touch mechanism is strictly adopted: at the hardware level, a 10kΩ pull-up resistor is configured to ensure the stability of the level, and at the software level, a 20ms state filtering delay is implanted to effectively eliminate the risk of false triggering caused by mechanical jitter. It is mainly applied to the setting of alarm thresholds (such as upper and lower limits of humidity, range of light intensity, and other parameter configurations). During the operation of the main program, real-time polling is conducted to monitor whether each sensor parameter is within the preset safety range. Once a parameter out-of-bounds event is detected, the sound and light alarm subsystem is activated immediately. The alarm drive circuit of this system adopts an active buzzer as the core alarm device. Its electrical drive characteristics are similar to those of a conventional speaker, and it requires a relatively large working current (usually ≥30mA) to produce sound normally. The direct drive capability of the GPIO port of the far ultra- micro controller (the typical output current at TTL level is ≤20mA). When PB12 outputs a high level (3.3V), the BE junction of the transistor is forward biased and conducts, the power supply circuit of the buzzer closes (Vcc→ buzzer → transistor CE→GND), and the device continues to sound. When PB12 is set to a low level (0V), the transistor cuts off, the circuit is disconnected and the sound stops [7]. The wireless communication scheme is implemented by using the ESP8266 module, communicating with the main controller through the UART serial communication protocol, and cooperating with the AT instruction set to complete the WIFI data transmission function[8]. The working voltage range of the module is 3-3.6V DC, the peak RF output power is 20dBm, the instantaneous working current reaches 240mA, and the serial port rate configuration is 115200bps. The hardware connection only requires the establishment of a four-wire communication link to build the physical layer connection between the main control system and the wireless module. The module is configured in AP mode to establish an independent wireless hotspot. Mobile terminal devices can receive the sensor data stream (parameters such as temperature, humidity, and smoke concentration) transmitted through the WIFI channel in real time. The communication protocol stack strictly follows the LWIP architecture[9], and 82 realizes the functions of network parameter configuration and data transparent transmission through a streamlined sequence of AT instructions. 4. System Testing and Analysis To validate the stability and effectiveness of the intelligent monitoring system for greenhouse conditions powered by the Internet of Things, comprehensive system tests and performance analyses were conducted. The goal was to confirm its stability, accuracy, and user-friendliness. The test results indicate that the system can precisely collect and process data from various sensors and automatically adjust the greenhouse environment based on predefined rules. In the event of abnormalities, the system promptly issues alerts to guide managers in taking appropriate actions. From an economic perspective, the implementation of this Internet of Things management system has markedly enhanced the yield and quality of greenhouse crops, reduced the consumption of energy and water resources, and broadened the profit margins in agricultural production. The application of this system has demonstrably improved economic benefits by increasing crop yield and quality, decreasing resource usage, and expanding profitability in agricultural endeavors. 5. Summary The intelligent greenhouse monitoring system, leveraging Internet of Things technology, markedly enhances the efficiency and stability of environmental management by means of precise data collection and automated control, thereby offering a more scientific and intelligent solution for greenhouse management. Looking ahead, as sensor technology continues to advance and communication technology is further optimized, the system's accuracy and response speed will see substantial improvements. This will facilitate more diversified and refined environmental regulation, propelling the advancement of greenhouse environmental management to a higher level. References [1] Li Yuqiang Huawei: Empowering Agriculture with Digital Technology [N]. Agricultural Science and Technology News, October 26, 2021 (004). DOI: 10.28608/n.cnki. nnykj. 2011. 001093. [2] Li Yunzeng Top Cloud Agriculture: Actively Promoting China's Agricultural Digital Transformation [J]. China Plant Protection Guide, 2020, 40 (06): 95-96. [3] Lan Yu, He Zheng, Zhang Li, etc Analysis of photosynthetic performance of miniature roses based on Priva system [J]. Agricultural Science Research, 2021, 42 (01): 43-46. DOI: 10.13907/j.cnki.nykxyj.2021.01.008Information on: www. ISSS conf. org. [4] Zhang Renyi, Yuan Jianli, Aide Xiecuo Production of Environmental Factor Measuring Instrument Based on ESP8266 Module [J]. China Educational Technology Equipment, 2023, (14):38-42. [5] Wang Yingjian, Wen Jiahe, Cai Changyou Design and Implementation of STM32 Agricultural Greenhouse System [J]. Internet of Things Technology, 2025, 15 (08): 149-152. DOI: 10.16667/j. issn. 2095-1302.25.08.033. [6] Zhang Jingjing, Wang Lei, Zhou Yi, etc Design and Implementation of Intelligent Irrigation Control System [J]. Agricultural Equipment and Vehicle Engineering, 2025, 63 (03): 26-32. [7] Gao Junqi, Research on Noise Suppression Mechanism of Magnetoelectric Heterojunction Magnetic Sensor for Real Application Environment Heilongjiang Province, Harbin Engineering University[C], March 31, 2023. [8] Shrivastava A ,Prasad S J S ,Yeruva R A, et al. IoT Based RFID Attendance Monitoring System of Students using Arduino ESP8266 & Adafruit.io on Defined Area[J]. Cybernetics and Systems, 2025,56(1):21-32. [9] Kamil A A ,Mousa J A, Rahaim A A L. Smart Cloud Computing System for Environment Based on MQTT Protocol and Node MCU (ESP8266) [J].Journal Europ éen des Systèmes Automatisés, 2024.