[Resource Download] The download address is as follows:
https://docs.qq.com/doc/DTlRSd01BZXNpRUxl
51 Watering System Design-Soil-Liquid Level-Water Pump-Toggle-Bluetooth
This design consists of STC89C52 single-chip circuit + soil moisture sensor + liquid level sensor + water pump control circuit + toggle switch circuit + Bluetooth module circuit + power supply circuit.
1. Set the working mode through the toggle switch. The threshold of soil moisture can be set through the mobile APP.
2. The liquid level has 3 levels of low (L), medium (M), and high (H), uploading via Bluetooth;
3. Upload the liquid level, soil moisture and soil moisture threshold to the mobile APP.
4. Manual mode: The mobile phone APP can control the switch of the water pump.
5. Automatic mode: When the soil moisture is lower than the threshold, the water pump will water, otherwise, the water pump will not water.
*S12# //Set threshold
Manual mode:
*OOO# //Open
*CCC# //Turn off
sbit ywG = P1^0;
sbit ywD = P1^1;
sbit beng = P1^2;
sbit sw = P3^2;
unsigned char firstin =0; //首次接收到标志
unsigned char tab[20]; //串口数据暂存
unsigned char Count=0; //串口接收计数
unsigned char uartbusy =0; //串口判忙
char dis0[16]; //打印数组初始化
char dis1[16]; //打印数组初始化
unsigned long time_20ms=0; //定时器计数
bit reportFlag; //上报标志
unsigned int tuRang=80; //湿度
unsigned int setNum = 40; //设置值
void Init_Timer0(void); //函数声明
void uartSendStr(unsigned char *s,unsigned char length);
void UART_Init(void);
void uartSendByte(unsigned char dat);