Automatic watering, humidity detection, adjustable upper and lower limits of humidity, automatic and manual modes!
The physical picture produced is as follows:
Functional introduction
Single-chip soil humidity detection automatic watering system The system is designed with STC89C52 single-chip microcomputer + ADC0832 + LCD1602 liquid crystal + soil humidity sensor + waterproof temperature sensor + pumping motor + button + buzzer. The
first line of the LCD displays the actual humidity .
The second line of the LCD displays the upper limit of humidity and the lower limit of humidity.
Button description:
From the first one on the left, minus key, plus key, set key.
1. Single-chip microcomputer model: STC89C52/51, AT89C52/51, AT89S52/51 are optional.
2. The product comes with a single-chip microcomputer power-on reset circuit, a manual reset circuit (reset button), and a crystal oscillator circuit (providing a clock cycle for the single-chip microcomputer).
3. The LCD1602 liquid crystal displays soil humidity and temperature, and the alarm parameters can also be displayed at the same time, which is intuitive and clear.
4. The upper and lower limit alarm ranges of humidity and temperature can be set, and the function of power-off saving is available. The alarm is saved in the STC microcontroller and does not need to be reset when powered on.
5. When the humidity is lower than the lower limit, the water pump is turned on for automatic irrigation with sound and light alarm. When the humidity is higher than the upper limit, the water pump is automatically turned off to stop irrigation.
6. When the temperature is higher than the upper limit, the water pump is turned on for automatic irrigation with sound and light alarm. When the temperature is lower than the lower limit, the water pump is automatically turned off to stop irrigation.
7. With manual mode, press the minus key to manually turn on the pumping motor, and press the plus key to manually turn off the pumping motor.
8. A water pipe for the matching water pump is provided.
Back:
The simulation schematic diagram is as follows (the proteus simulation project file can be downloaded in the attachment of this post)
The circuit schematic diagram is as follows:
D0 on the sensor does not need to be connected to AO connected to the 0832 chip.
Note: The contents of the above four folders are the same, but they are opened with different software.
1. .SchDoc is in Altium Designer format: Altium Designer software needs to be installed.
2. .sch is in Protel 99SE format: you need to install Protel 99SE software.
3. PDF format: you can open it with PDF software, such as Foxit PDF Reader, Adobe Reader, etc.
4. Word format: you can open it with Word or WPS software.
Component list of automatic watering system version 2:
No. "Comment
" "Description
" "Quantity
"
1 BUZZER Buzzer 1
2 10uF direct-plug electrolytic capacitor 1
3 30pf direct-plug ceramic capacitor 2
4 104 direct-plug ceramic capacitor 1
5 220uF direct-plug electrolytic capacitor 1
6 Light-emitting diode 5mm direct-plug light-emitting diode 1
7 LCD1602 LCD1602 liquid crystal display 1
8 Header 2 pin 2-Pin 1
9 POWER DC power socket 1
10 Header 3 pin 3-Pin 1
11 S9012 PNP transistor 2
12 2.2K color ring resistor 1
13 1K color ring resistor 3
14 10K color ring resistor 2
15 SW-PB button 6X6X5MM 4
16 SWITCH Self-locking switch 1
17 MCU 51 single-chip microcomputer 1
18 ADC0832 analog-to-digital conversion chip 1
19 12M crystal oscillator 1
Supporting equipment
1 Wire XXcm 1
2 Solder XXcm 1
3 USB to DC3.5mm power cable System power supply 1
4 9*15 multi-purpose board 1
5 Single-chip microcomputer socket 40-pin IC socket 1
6 IC socket 8-pin IC socket 1
7 LCD1602 socket 16P female header 1
8 LCD1602 lead pin 16P pin header 1
The single-chip microcomputer source program is as follows:
#include #define uchar unsigned char //unsigned character macro definition variable range 0~255 #define uint unsigned int //Unsigned integer macro definition variable range 0~65535 #include sbit SCL=P1^4; //SCL is defined as the 3rd pin of P1 port, connected to ADC0832 SCL pin sbit DO=P1^5; //DO is defined as the 4th pin of P1 port, connected to ADC0832DO pin sbit CS=P1^3; //CS is defined as the 4th pin of P1 port, connected to ADC0832 CS pin sbit beep = P3^3; //Buzzer IO port definition uint temperature,s_temp; //temperature variable uchar shidu; //humidity level uchar s_high = 70,s_low = 25; //Humidity alarm parameters sbit dianji = P1^6; //Motor IO definition bit flag_300ms; uchar key_can; //Key value variable uchar menu_1; //Menu design variables //These three pin references sbit rs=P1^0; //1602 data/command selection pin H: data L: command sbit rw=P1^1; //1602 read and write pin H: data register L: instruction register sbit e =P1^2; //1602 enable pin falling edge trigger uchar code table_num[]="0123456789abcdefg"; /******************************************************************** * Name: delay_uint() * Function: small delay. * Input: None * Output: None ***************************************************************************/ void delay_uint(uint q) { while(q--); } /******************************************************************** * Name: write_com(uchar com) * Function: 1602 command function * Input: Input command value * Output: None ***************************************************************************/ void write_com(uchar com) { e=0; rs=0; rw=0; P0=com; delay_uint(3); e=1; delay_uint(25); e=0; } /******************************************************************** * Name: write_data(uchar dat) * Function: 1602 write data function * Input: Data to be written to 1602 * Output: None ***************************************************************************/ void write_data(uchar dat) { e=0; rs=1; rw=0; P0=dat; delay_uint(3); e=1; delay_uint(25); e=0; } /******************************************************************** * Name: write_sfm2(uchar hang,uchar add,uchar date) * Function: Display a 2-digit decimal number. If you want the fifth character of the first line to display "23", call this function as follows write_sfm1(1,5,23) * Input: row, column, need to enter 1602 data * Output: None ***************************************************************************/ void write_sfm2(uchar hang,uchar add,uint date) { if(hang==1) write_com(0x80+add); else write_com(0x80+0x40+add); write_data(0x30+date/10%10); write_data(0x30+date%10); } /******************************************************************** * Name: write_string(uchar hang,uchar add,uchar *p) * Function: Change the value of a certain bit in the LCD. If you want the fifth character in the first line to start displaying "ab cd ef", call this function as follows write_string(1,5,"ab cd ef;") * Input: row, column, need to enter 1602 data * Output: None ***************************************************************************/ void write_string(uchar hang,uchar add,uchar *p) { if(hang==1) write_com(0x80+add); else write_com(0x80+0x40+add); while(1) { if(*p == '') break; write_data(*p); p++; } } /******************************************************************** * Name: init_1602() * Function: Initialize 1602 LCD * Input: None * Output: None ***************************************************************************/ void init_1602() { write_com(0x38); write_com(0x38); write_com(0x0c); write_com(0x06); delay_uint(1000); write_string(1,0," shidu:00% "); write_string(2,0," SH:00% SL:00% "); write_sfm2(2,4,s_high); //Display humidity upper limit write_sfm2(2,12,s_low); //Display humidity lower limit } /**************************1ms delay function********************************/ void delay_1ms(uint q) { uint i,j; for(i=0;i } /***********Reading analog conversion data************************************************************/ //Please first understand the serial protocol of ADC0832 analog-to-digital conversion, and then read this function. It is mainly to understand the corresponding timing diagram. This function simulates the serial protocol of 0832 // 1 0 0 channel // 1 1 1 channel unsigned char ad0832read(bit SGL,bit ODD) { unsigned char i=0,value=0,value1=0; SCL=0; DO=1; CS=0; //Start SCL=1; //first rising edge SCL=0; DO=SGL; SCL=1; //Second rising edge SCL=0; DO=ODD; SCL=1; //The third rising edge SCL=0; //The third falling edge DO=1; for(i=0;i<8;i++) { SCL=0; SCL=1; //Start receiving data from the fourth falling edge value<<=1; if(DO) value++; } for(i=0;i<8;i++) { //Receive verification data value1>>=1; if(DO) value1+=0x80; SCL=1; SCL=0; } SCL=1; if(value==value1) //Compare with the verification data, return the data if it is correct, otherwise return 0 return value; return 0; for(j=0;j<120;j++);
Previous article:Communication program between ESP8266 module and microcontroller (detailed explanation of hardware and software)
Next article:MCU+ADC0832+MQ2 temperature and smoke alarm control
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- I have read several books, but I still don't understand the difference between LWM2M and COAP. Can you please guide me?
- Let Arduino make your useless board playable Part 3 How to play ESP-C3, ESPS2
- Risking my life to tell the administrator: The title has too few words, and the problem description was cut off before it was finished.
- Violent disassembly of Xiaomi's latest 2-in-1 power bank
- Ended|Maxim & Avnet [Typical applications in the era of the Internet of Things]
- CC2640 debugging experience: adding serial port
- 【NXP Rapid IoT Review】+ GUI Usage
- N32WB452 asked: Does N32WB452 have a basically complete ported RT-Thread development kit?
- IoT Gateways – A Simple Guide to the Internet of Things
- [Bluesun AB32VG1 RISC-V evaluation board] IDE installation and use