»ùÓÚ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