| For the high cost,insufficient network and a single measurement of environmental factors and other issues that exist in the greenhouse in China,it develops a remote control system based on an STM32 for greenhouse.This system uses the STM32 as the central controller in the greenhouse and MFC to design control software to achieve remote monitoring and control of air temperature, air humidity,light intensity and CO2 concentration in the greenhouse.Hardware circuit includes STM32 controller, data acquisition module, device control module,network interface module, real-time display module and data storage module. The data acquisition module uses DHT11, MG811 and BH1750 sensors to measure environmental factors,the device control module controls relays to open and close the execution devices such as heating system and lighting system inside the greenhouse, STM32 accesses network to realize remote control by ENC28J60,the display module uses LCD12864 to achieve real-time display of various environmental factors and the data storage module uses an external SD card to storage related data.STM32 procedures adopts the library functions to design measure program, display program and control program.The transplantation of μC/OS operating system in STM32 can achieve multitask control and the transplantation of Lw IP protocol can realize network control.It designs an easy using control interface by using MFC in VC 6.0 platform and it sends data and commands by TCP/IP protocol between the software and the STM32 controller.The main function of the software is to achieve remote monitoring and control of the environment in the greenhouse. It uses object-oriented approach to pack operational functions to the class so that it is easier to upgrade and it uses multi-threading approach to solve the situation of multiple tasks running simultaneously.Preservation of large amount of data that is produced in the process of the control to the database can make it more convenient for data analysis and utilization.To test the system, it built a small greenhouse and installed the controller in the greenhouse.After testing,the control system that is designed in this thesis can achieve real-time remote monitoring of the air temperature, air humidity, light intensity and CO2 concentration.Data will be updated once per second.When the above-mentioned environmental factors are outside the range that has been set on the software, the system will alarm and the execution devices can be controlled on and off by the software to adjust the factors to the range that has been set. |