单片机型号选择:STM32F103C8T6;物联网通信选择:WIFI
功能整体描述:
WIFI:ESP01S
显示OLED
温湿度模块:DHT11
土壤湿度模块
wifi模块ESP8266(透传)
两个继电器(加水,加湿)
三按键
蜂鸣器
指示灯""土壤湿度传感器:检测土壤的湿度,温湿度传感器:检测空气的温度和湿度,ESP8266无线传输模块实现数据的传输。屏幕:显示当前的温度、湿度和土壤湿度等信息。加水继电器和加湿继电器:分别用于控制水和湿度的供应,三个按键:用于用户交互,比如进入阈值修改界面其他设置操作。
图2.1 系统整体功能框图
实物图:
代码:
void userHandle(void)
{
/*
currentDataPoint.valueTempSet = ;
currentDataPoint.valueHumiSet = ;
currentDataPoint.valueSoilSet = ;
currentDataPoint.valueAirTemp = ;
currentDataPoint.valueAirHum = ;
currentDataPoint.valueSoilHum = ;
*/
uint8_t ret = 0;
static uint32_t thLastTimer = 0;
if((gizGetTimerCount() - thLastTimer) > 1000 ) //上报间隔读取温度2S
{
modeset(currentDataPoint.valueMODEL);
//采集三种数据
dht11Read((u8*)¤tDataPoint.valueAirTemp,(u8*)¤tDataPoint.valueAirHum);
currentDataPoint.valueSoilHum =(uint16_t)(Get_Adc_Average(ADC_CHANNEL_0,10 ));
currentDataPoint.valueSoilHum=(4095 - currentDataPoint.valueSoilHum)/41;
currentDataPoint.valuelight = (Get_Adc_Average(ADC_CHANNEL_1,10 ))/41;
//显示三种数据
OLED_ShowNum(40,2,(uint16_t)currentDataPoint.valueAirTemp,2,16);
OLED_ShowNum(40,4,(uint16_t)currentDataPoint.valueAirHum,2,16);
OLED_ShowNum(40,6,(uint16_t)(currentDataPoint.valueSoilHum),2,16);
OLED_ShowNum(90,6,(uint16_t)(currentDataPoint.valuelight),3,16);
if(currentDataPoint.valueMODEL==0) //自动模式
{
if(currentDataPoint.valueAirTemp > currentDataPoint.valueTempSet
|| currentDataPoint.valueAirHum < currentDataPoint.valueHumiSet)
{
HUMON;
currentDataPoint.valueaddhumiopen = 1;
}
else
{
HUMOFF;
currentDataPoint.valueaddhumiopen = 0;
}
if(currentDataPoint.valueSoilHum < currentDataPoint.valueSoilSet)
{
LEDON;
currentDataPoint.valueBoomOpen = 1;
}
else
{
LEDOFF;
currentDataPoint.valueBoomOpen =0;
}
if(currentDataPoint.valuelight < currentDataPoint.valuelightset)
{
LED1ON;currentDataPoint.valueLED = 1;
}
else
{
LED1OFF;currentDataPoint.valueLED = 0;
}
// if(currentDataPoint.valueAirTemp > currentDataPoint.valueTempSet
// || currentDataPoint.valueAirHum < currentDataPoint.valueHumiSet
// ||currentDataPoint.valueSoilHum < currentDataPoint.valueSoilSet)
// {
// BEEpON;LED1ON;
// }
// else
// {
// BEEpOFF;LED1FF;
// }
if(currentDataPoint.valueAirTemp > currentDataPoint.valueTempSet )
{
OLED_ShowString(80,2,"*",16); // currentDataPoint.valueTempAlarm = 1;
}
else
{
OLED_ShowString(80,2," ",16); // currentDataPoint.valueTempAlarm = 0;
}
if(currentDataPoint.valueAirHum < currentDataPoint.valueHumiSet )
{
OLED_ShowString(80,4,"*",16); // currentDataPoint.valueTempAlarm = 1;
}
else
{
OLED_ShowString(80,4," ",16); // currentDataPoint.valueTempAlarm = 0;
}
if(currentDataPoint.valueSoilHum < currentDataPoint.valueSoilSet )
{
OLED_ShowString(80,6,"*",16); // currentDataPoint.valueTempAlarm = 1;
}
else
{
OLED_ShowString(80,6," ",16); // currentDataPoint.valueTempAlarm = 0;
}
}
thLastTimer = gizGetTimerCount();
}
}
图纸:
源码:https://gitee.com/szangell_2240885967/jiaohua.git
演示视频:https://www.bilibili.com/video/BV1YMEuzCEce/
购买定制:739175369