标题:
STM32F103C8T6户外环境监测系统程序 运用了DHT11模块,GY-30数字光强度模块
[打印本页]
作者:
王者不可阻挡
时间:
2021-8-1 17:36
标题:
STM32F103C8T6户外环境监测系统程序 运用了DHT11模块,GY-30数字光强度模块
基于STM32F103C8T6最小开发板设计的户外环境监测系统(运用了DHT11模块,GY-30数字光照模块,低电平触发蜂鸣器,OLED显示)
实践成果展示:
7.jpg
(101.24 KB, 下载次数: 41)
下载附件
2021-8-1 17:36 上传
6.png
(85.33 KB, 下载次数: 53)
下载附件
2021-8-1 17:35 上传
单片机源程序如下:
#include "stm32f10x.h"
#include "usart.h"
#include "delay.h"
#include "DTH117.h"
#include "sys.h"
#include "bh1750.h"
#include "oled.h"
#include "bmp.h"
#include "Beep.h"
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
/*
*读取温湿度传感器DHT11的值,并用串口打印出来
*/
void clock_init(void);
u8 temp = 0,humi = 0,Light=0;
/**************************************************************************
函数名:int main(void)
参数说明:无
返回值:无
函数作用:主函数
***************************************************************************/
int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
delay_init();
DHT11_Init();
clock_init();
bh1750_Init();
OLED_Init();
Beep_Init();
OLED_Clear();
Usart1_Init(115200); //初始化串口
Usart2_Init(115200);
//UsartPrintf(USART_DEBUG,"HardWare init OK\r\n");
while(1)
{
//if (timeCount % 40==0){
bh1750_ReadOneTime();
bh1750_ReadContinuous1();
DHT11_Read_Data(&temp,&humi);
Light=getValue();
UsartPrintf(USART_DEBUG,"\r\n 温度:%d,湿度:%d,光照:%d",temp,humi,Light);
OLED_Clear();
OLED_ShowCHinese(0,0,0);
OLED_ShowCHinese(15,0,1);
OLED_ShowCHinese(30,0,2);
OLED_ShowCHinese(45,0,3);
OLED_ShowCHinese(60,0,4);
OLED_ShowCHinese(75,0,5);
OLED_ShowCHinese(90,0,6);
OLED_ShowCHinese(105,0,7);
OLED_ShowCHinese(0,2,8);
OLED_ShowCHinese(17,2,9);
OLED_Show(temp,humi,Light);//屏幕显示成果
delay_ms(50);//建议不要低于这个数值
Beep_Warn(temp,humi);
//}
delay_ms(10);
}
}
// }
/**************************************************************************
函数名:void clock_init(void)
参数说明:无
返回值:无
函数作用:开启高速外部时钟,
ADCCLK设置为12MHZ, SYSCLK设置为72Mhz,PCLK1设置为36MHZ,PKLC2设置为72mhz
***************************************************************************/
void clock_init(void)
{
RCC->CR = 0x1010000;
RCC->CFGR = 0x1DC402;
}
复制代码
Keil代码下载:
代码.7z
(208.34 KB, 下载次数: 154)
2021-8-1 17:53 上传
点击文件名下载附件
下载积分: 黑币 -5
作者:
小云吖
时间:
2021-9-30 20:42
GY30 接线是怎样的呢
作者:
13560423097
时间:
2023-2-4 23:58
代码有错误
作者:
chen丨chao
时间:
2023-2-6 14:35
可以,很强
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1