基于51单片机的大棚温湿度检测系统的设计与实现 - 图文 联系客服

发布时间 : 星期四 文章基于51单片机的大棚温湿度检测系统的设计与实现 - 图文更新完毕开始阅读7ebce89a70fe910ef12d2af90242a8956becaabc

基于51单片机的大棚温湿度监测系统的设计与实现

摘 要:随着经济的快速发展,我国的农业产业结构发生了很大的变化,其中较为突出的是温室大棚种植业。鉴于大棚种植业在不同的季节都有较大的产量,所以越来越多的农民采用温室大棚种植蔬菜。温度、湿度和光照度的控制是温室大棚得到高产量的关键要素。若要测量温湿度和光照度,对于大量的大棚而言,仅靠温度测量计来实现,需要更多的人力和物力。随着农业的产业范围不断发展与扩大,采用这种传统测量大棚温湿度的方法,具有很大的局限性和不足之处。如今,自动监测棚内温湿度的装置被越来越多的用户采用。

本文设计了基于STC89C52RC单片机的温室大棚温湿度监测系统,主要包括电路设计和软件设计等。该系统以单片机为核心通过数字温湿度传感器DTH11和光照传感器BH1750对大棚的温湿度和光照度进行数据采集。传感器将采集的数据传输给单片机,单片机根据收到的数据做出相应的分析和处理,其结果显示在LCD1602液晶显示屏上。如果超出预先设定的温湿度和光照度限制范围,单片机控制开启指示灯,同时控制对应的继电器驱动打开设备工作,使大棚温湿度值达到适宜的范围值。

关键字:STC89C52RC单片机;数字温湿度传感器DTH11;光照传感器BH1750 FVI;LCD1602液晶显示屏

I

Design and implementation of the greenhouse temperature and humidity detection system based on 51 single chip

microcomputer

Abstract: With the development of economy, great changes have taken place in the agricultural industry in our country, one of the more prominent changes is the greenhouse planting. In different seasons, the greenhouse planting has a great production, more and more farmers use greenhouses to grow vegetables. Controlling of temperature, humidity and illumination are the key factors of high production in greenhouse. If we need to measure the temperature and illumination, it will need more man-power and material resources for a large number of greenhouses. With the development and expansion of agricultural industry, the traditional methods of measuring the temperature and humidity will has many limitations and shortcomings. Now, the automatic monitoring device of temperature and humidity is adopted by more and more farmer in the shed.

In this paper, the temperature and humidity monitoring system of greenhouse based on STC89C52RC MCU are designed, mainly including circuit design and software design. The system uses the single-chip microcomputer as the core through the digital temperature and humidity sensor DTH11 and light sensor BH1750 to collect the temperature and humidity and light intensity of the greenhouse. The data are collected by the sensor feed back to the MCU for the corresponding analysis and processing according to the received data, the results are shown on the LCD1602 liquid crystal display monitor. If beyond the preset temperature, humidity and light intensity limit, the microcontroller control open indicator lamp, while controlling the corresponding relay drive to open the equipment work, so that the greenhouse temperature and humidity values to the appropriate range of value.

Keywords:-STC89C52RC-MCU;Digital-Temperature-and-Humidity-Sensor-DTH11;Llight Sensor BH1750 FVI;LCD1602 Liquid Crystal Display Monitor

II

目 录

一、论文(设计)正文.................................................................................................错误!未定义书签。

1绪论 ............................................................ 4

1.1选题背景与意义 .............................................................................................. 4 1.2国内外研究现状 .............................................................................................. 4 1.3主要研究内容 .................................................................................................. 6 1.4论文结构 ........................................................................................................ 6 2总体分析与设计 ................................................... 7

2.1可行性分析 ...................................................................................................... 7 2.2需求分析 .......................................................................................................... 8 2.2.1系统需求 ....................................................................................................... 8 2.2.2用户需求 ....................................................................................................... 8 2.2.3功能需求 ....................................................................................................... 9 2.2.4性能需求分析 ............................................................................................... 9 2.3系统总体结构 ................................................................................................ 10 2.3.1系统设计要求 ............................................................................................. 10 2.3.2系统结构分析 ............................................................................................. 10 2.4系统实现原理 ................................................................................................ 11 3硬件部分设计 .................................................... 12

3.1 STC89C52单片机 ......................................................................................... 12 3.1.1 STC89C52的主要特性 .............................................................................. 12 3.1.2 STC89C52的引脚图 .................................................................................. 12 3.1.3电源电路设计 ............................................................................................. 13 3.1.4复位电路设计 ............................................................................................. 14 3.1.5晶振电路设计 ............................................................................................. 15

1

3.1.6按键电路设计 ............................................................................................. 15 3.1.7控制电路设计 ............................................................................................. 16 3.2温湿度传感器 ................................................................................................ 16 3.2.1数字温湿度传感器简介 ............................................................................. 16 3.2.2工作原理 ..................................................................................................... 17 3.2.3温湿度传感器电路 ..................................................................................... 19 3.3光照传感器 .................................................................................................... 20 3.3.1光照传感器的简介 ..................................................................................... 20 3.3.2光照传感器的主要特性 ............................................................................. 20 3.3.3光照传感器电路 ......................................................................................... 21 3.4 LCD1602液晶显示屏 ................................................................................... 22 3.4.1 LCD1602简述 ............................................................................................ 22 3.4.2 LCD1602引脚 ............................................................................................ 22 3.4.3 LCD1602指令表 ........................................................................................ 23 4 软件部分设计 ................................................... 26

4.1程序语言及开发环境 .................................................................................... 26 4.2程序流程图 .................................................................................................... 26 4.2.1系统总体流程图 ......................................................................................... 26 4.2.2温湿度控制流程图 ..................................................................................... 27 4.2.3光照度控制流程图 ..................................................................................... 28 4.3系统模块的代码实现 .................................................................................... 29 4.3.1按键模块 ..................................................................................................... 29 4.3.2数据采集模块 ............................................................................................. 32 4.3.3 数据接收与显示模块 ................................................................................ 33 4.3.4 指示灯与继电器模块 ................................................................................ 34 5系统功能实现与测试 .............................................. 36

5.1系统功能实现 ................................................................................................ 36

2