Design of a smart home watering device using AT89S52 microcontroller

Publisher:BlissfulDreamsLatest update time:2013-09-06 Source: 21icKeywords:AT89S52 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

With the improvement of people's living standards, flowers are gradually favored by people, cultivating sentiment and purifying the air. Using a single-chip microcomputer, a home intelligent watering device is designed to realize automatic watering, saving manpower and facilitating people's business trips without affecting the growth of flowers. If you are at home, you can also turn off the watering device and water the flowers manually. The watering device can be set in two ways, one is timed quantitative watering, and the other is watering according to humidity. Which method is used is controlled by buttons or infrared remote control. When using timed quantitative watering, the digital tube displays the time and water flow time. When watering according to humidity, the digital tube displays the current humidity.

1 Overall Design

An automatic watering device is designed using the AT89S52 single-chip microcomputer. For different flowers, this intelligent watering device is set to two modes: one is to water flowers at a fixed time and quantity, and the other is to use a humidity sensor to detect the humidity of flowers (can also be used for vegetables, etc.). The collected humidity is transmitted to the single-chip microcomputer chip. The single-chip microcomputer controls whether to water according to the humidity. If watering is required, a pin p2.0 of the single-chip microcomputer is set to a high level, so that the relay coil is energized, the open contacts are closed, and the solenoid valve is opened to achieve automatic watering at a fixed time and quantity. When the set time is reached, the solenoid valve is automatically closed, and the water flow time is adjustable. A digital tube is installed on it, and there is a button to set the length of watering time according to the different water requirements of different flowers. The length of watering time can be displayed on the digital tube; if the humidity is detected to be sufficient, p2.0 remains at a low level and the solenoid valve is not opened. Which method is used is controlled by buttons or infrared remote control. When using fixed-time quantitative watering, the digital tube displays the time and water flow time. When watering according to humidity, the digital tube displays the current humidity.

The technical solution adopted by this technology is: use the single-chip microcomputer to realize automatic control, first detect which method is used to water the flowers, if it is timed and quantitative watering, start watering the flowers at the specified time, and water the flowers according to the set watering time; if it is based on humidity control whether to water, set a pin of the single-chip microcomputer to a low level, the humidity sensor detects the humidity and transmits it to the single-chip microcomputer chip. When it detects that the humidity is insufficient, the pin of the single-chip microcomputer becomes a high level, the relay is attracted, the normally open contact is closed, and the solenoid valve coil is energized. At this time, the solenoid valve is closed and disconnected, and water flows through to water the flowers. Its structure is shown in Figure 1.

Design of a smart home watering device based on AT89S52 single-chip microcomputer

2 Hardware Design

The hardware circuit is composed of a single-chip microcomputer, a humidity sensor, a relay, a solenoid valve, a digital tube, a 1302 chip, a button, an infrared remote control receiver, etc. Note that if the solenoid valve is placed too close to the single-chip microcomputer, it will not work properly. The solution is: 1) The solenoid valve is away from the single-chip microcomputer; 2) Add resistors and capacitors. The method of adding resistors and capacitors is adopted here, which makes it convenient to concentrate the components and the controller is relatively small. The schematic diagram of the smart watering device is shown in Figure 2.

Design of a smart home watering device using AT89S52 microcontroller

2.1 Timed and quantitative watering method

Timed quantitative watering means starting watering at a specified time every day, setting the watering time, for example, 1 minute, and stopping watering after 1 minute. Specific hardware: 2 three-digit common anode digital tubes and 1 two-digit common anode digital tube are installed to display the time and the length of watering time. The buttons control the time adjustment and time setting adjustment, and there is a button to set the length of watering time according to the different water requirements of different flowers, which is displayed on the digital tube. The 1302 chip realizes time retention, and the time is not affected when the power is off. [page]

Here, it can be assumed that the flowers are watered automatically at 7:20 every morning, and the watering time is 1 minute. At 7:20 in the morning, the single-chip microcomputer controls the intelligent watering device to start watering the flowers. The single-chip microcomputer P2.0 pin is connected to the relay, and the relay is connected to the solenoid valve. The solenoid valve controls the water flow. At 7:20, a command is given to the single-chip microcomputer, setb 02.0, and the three-pole tube is turned on. In this way, the relay coil has current passing through, and the corresponding normally open contact is closed, so that the solenoid valve coil is energized. At this time, the solenoid valve changes from closed to open, and water flows through to water the flowers. When the 1 minute is up, a command clr p2.0 is given to the single-chip microcomputer, so that the single-chip microcomputer P2.0 pin outputs a low level, the transistor is cut off, the relay coil has no current passing through, the normally open contact is restored to open, and the solenoid valve coil loses power. At this time, the solenoid valve is closed and the water flow stops. The time here is displayed on the digital tube. It can be adjusted by key control. At the same time, the watering time can also be set by key, and the length of the watering time can also be adjusted by key. At the same time, a 1302 chip is added to prevent the time from being affected when the power is off, and to avoid the need to readjust the time after each power outage. Figure 3 is a diagram of the structure of timing and quantitative watering.

2.2 Humidity Control Watering Method

First, set the humidity by pressing the button. The humidity sensor selected here is the LTM8901 humidity sensor. The LTM8901 is a digital temperature and humidity probe specially provided for users to design their own products. Its humidity measurement range is 1% to 99%RH, the resolution is 0.5%RH, and the measurement accuracy is ±3.0%RH (typical value); the temperature measurement range is -25 to +60℃, the resolution is 0.0625℃, and the measurement accuracy is ±0.5℃; the typical response time is 5 s; the operating voltage range is 4.5 to 5.5 V. The LTM8901 directly outputs the measurement results as digital signals, which are serially transmitted to the microcontroller through the "one-line bus". There is no need for analog-to-digital conversion, which reduces components and is simple and convenient. The humidity is detected by the LTM8901 humidity sensor and transmitted to the microcontroller for processing. The humidity is displayed on the digital tube. When the humidity is lower than the set value, a command is given to the microcontroller, seth p2.0, and current flows through the relay coil. The corresponding normally open contact closes, and the solenoid valve coil is energized. At this time, the solenoid valve changes from closed to open, and watering is carried out. When it is equal to or higher than the set value, clr p2.0, the relay coil loses power, the corresponding normally open contact is disconnected, the solenoid valve coil loses power, the valve closes, and water cannot flow through, stopping watering. The humidity control watering structure is shown in Figure 4.

2.3 Mode Setting

It can be set by pressing the button manually. Pressing an odd number of times sets the watering mode to timed quantitative watering, and pressing an even number of times sets the watering mode to watering according to humidity. The watering mode can also be set by infrared remote control. The transmitter uses a TV remote control, and the receiving circuit uses a trinity receiver to receive the signal. The 1st pin of the trinity receiver is grounded, the 2nd pin is connected to the power supply, and the 3rd pin (signal pin) is connected to an I/O pin of the microcontroller. When the signal comes, it is decoded and processed differently. When the signal is received once, the flowers are watered according to timed quantitative watering, and when the signal is received again, the flowers are watered according to humidity. According to the number of times pressed, the odd number of times uses the timed quantitative watering mode, and the even number of times uses the humidity control watering mode. This is mainly for different flowers. When the signal is received, the light-emitting diode flashes for 30 seconds. The buzzer sounds for 10 seconds to remind you. The external structure of the intelligent watering device is shown in Figure 5.

 

3 Programming

3.1 Programming ideas

1) Mode setting: The working mode is determined by detecting the number of times the button is pressed. Let the number of times pressed be n. The first time it is pressed, n=1. Each time n is pressed, it increases by one. When it reaches a certain number of times, 1,000, n starts from 0. If (n=10000) (n=0); the pin connected to the button is high at the beginning, and once it is pressed, it becomes low. The number of times the high level changes to the low level is detected to detect whether it is pressed. If it is pressed an odd number of times, the flowers are watered by timing and quantity. If it is pressed an even number of times, the flowers are watered by detecting humidity. If (n%2=0) is used to judge, if the remainder is 0, it means an even number of times, otherwise it is an odd number of times. [page]

2) To water the flowers at a fixed time and quantity, first write the time display program, and then determine whether it is the set watering time and how long the watering time should be.

In the program, c represents hours, b represents minutes, a represents seconds, and w represents the set time. First, if the time is not up, the p2.0 pin is 0 (P2_0=0), and no watering occurs. When the time is up (if (c==7&b==20&0

3) Humidity detection watering first starts the conversion, reads the humidity detected by LTM8901, makes a comparison and judgment, and finally executes.

3.2 Flowchart

The program flow chart of the intelligent watering device is shown in Figure 6.

4 Conclusion

This paper introduces the design of a household intelligent watering device, conducts hardware design and program analysis, and has been made into a physical object with good use effect. The household intelligent watering device has a wide range of uses. By changing the program, it can also be used as a timer switch, dormitory lighting system, temperature-controlled plastic greenhouse, etc. This household intelligent watering device can also be used for intelligent watering of lawns and vegetables, etc., by removing the water tank and directly connecting the faucet. The innovation of the system design lies in the realization of different ways of automatic watering and the retractable water pipe, which helps to change the distance between the flower pot and the water source; the problem that needs to be paid attention to in the design process is to prevent the microcontroller from resetting when the solenoid valve is closed, and add resistors and capacitors for buffering. The capacitor selected in this system is 400 V withstanding voltage.

Keywords:AT89S52 Reference address:Design of a smart home watering device using AT89S52 microcontroller

Previous article:Design and implementation of wireless transmission system based on USB
Next article:Application of STC89C58RD+ MCU in the Design of MP3 Player

Recommended ReadingLatest update time:2024-11-15 17:33

What is the difference between the two types of microcontrollers, AT89S51 and AT89S52?
AT89S51 AT89S51 is a low-power, high-performance CMOS 8-bit microcontroller. It contains 4KB of Flash read-only program memory that can be repeatedly erased and written 1000 times. The device is manufactured using high-density, non-volatile storage technology and is compatible with the standard MCS-51 instruc
[Microcontroller]
Design of Temperature and Humidity Monitoring System Based on RS-485 Bus
1 Overview    The temperature and humidity indicators in environmental conditions are important parameters in many workplaces. Whether it is warehouse management, book preservation or industrial measurement and metrology verification, they all need to meet the temperature and humidity environmental conditions specified
[Microcontroller]
Design of Temperature and Humidity Monitoring System Based on RS-485 Bus
Design of intelligent electronic scale system using AT89S52 microcontroller
Introduction to AT89S52 microcontroller AT89S52 is an 8-bit microcontroller. All the on-chip ROM adopts FLASH ROM technology and is fully compatible with the MCS-51 series. It can operate at an ultra-low voltage of 3V and the crystal oscillator clock can reach up to 24MHz. AT89S52 is a standard 40-pin dual in-line int
[Microcontroller]
Design of intelligent electronic scale system using AT89S52 microcontroller
What are the advantages and disadvantages of the microcontroller at89s52 compared with other microcontrollers?
The microcontroller at89s52 is a high-performance, low-power 8-bit microcontroller manufactured using CMOS technology. It provides the following standard features: 8K bytes of program memory, 256 bytes of RAM, 32 I/O lines, 2 16-bit timer/counter, an interrupt structure with 5 interrupt sources and two priority levels
[Microcontroller]
What are the advantages and disadvantages of the microcontroller at89s52 compared with other microcontrollers?
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号