欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
STM32F103VET6 溫濕度采集DHT11上報(bào)PC
[打印本頁]
作者:
xiexuedi
時(shí)間:
2020-4-22 01:16
標(biāo)題:
STM32F103VET6 溫濕度采集DHT11上報(bào)PC
程序功能 DHT11采集溫度 --》 stm32 PE6端口 - -》stm32校驗(yàn)DHT11輸入的數(shù)據(jù) --》 stm32 USART1上報(bào)PC。
串口軟件設(shè)置:
波特率: 9600;
校驗(yàn)位: 無;
數(shù)據(jù)位: 8;
停止位: 1;
輸出方式 :ASII;
采集頻率:1s/次;
#include "../DRIVER/inc/dht11.h"
uint16_t DHT11_Buffer[5];
/**************************************
* 函 數(shù) : 初始化DHT11
* 參 數(shù) :無
* 返回值 :無
***************************************/
void DHT11_InitConfing(void)
{
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOE,ENABLE );
DHT11_O();
DHT11_H;
}
/**************************************
* 函 數(shù) : DHT11配置為輸出
* 參 數(shù) :無
* 返回值 :無
***************************************/
void DHT11_O(void){
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6;
GPIO_Init( GPIOE ,&GPIO_InitStruct);
}
/**************************************
* 函 數(shù) : DHT11配置為輸入
* 參 數(shù) :無
* 返回值 :無
***************************************/
void DHT11_I(void){
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6;
GPIO_Init( GPIOE ,&GPIO_InitStruct);
}
/**************************************
* 函 數(shù) : DHT11讀取電平
* 參 數(shù) :無
* 返回值 :高電平 1、 低電平 0
***************************************/
uint8_t DHT11_R(void){
return GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_6);
}
/**************************************
* 函 數(shù) : DHT11讀取數(shù)據(jù)
* 參 數(shù) :無
* 返回值 :高電平 1、 低電平 0
***************************************/
uint8_t DHT11_ReadBit(void){
while( DHT11_R() == RESET);
Delay_us(40);
if( DHT11_R() == SET )
{
while( DHT11_R() == SET);
return 1;
}else
return 0;
}
/**************************************
* 函 數(shù) : DHT11讀取字節(jié)
* 參 數(shù) :無
* 返回值 :字節(jié)
***************************************/
uint8_t DHT11_ReadByte(void){
uint8_t i,data = 0;
for( i = 0 ; i < 8 ; i++ ){
data <<= 1;
data |= DHT11_ReadBit();
}
return data;
}
/**************************************
* 函 數(shù) : DHT11讀取溫濕度
* 參 數(shù) :無
* 返回值 :SUCESS 1 ,F(xiàn)AIL = 0
***************************************/
uint16_t DHT11_ReadData(void)
{
uint8_t i;
DHT11_O();
DHT11_L;
Delay_us(19000);
DHT11_H;
Delay_us(30);
DHT11_I();
//DHT11_R;
if( DHT11_R() == RESET){
while( DHT11_R() == RESET);
while( DHT11_R() == SET );
for( i = 0; i < 5 ;i++ )
DHT11_Buffer[i] = DHT11_ReadByte();
DHT11_O();
DHT11_H;
if( (DHT11_Buffer[0] + DHT11_Buffer[1] + DHT11_Buffer[2] + DHT11_Buffer[3]) == DHT11_Buffer[4] )
return 1;
else
return 0;
}else
return 0;
}
復(fù)制代碼
全部資料51hei下載地址:
2020-04-21_STM32_DHT11.7z
(177.37 KB, 下載次數(shù): 66)
2020-4-22 02:27 上傳
點(diǎn)擊文件名下載附件
stm32f103vet6與DHT11溫度采集
下載積分: 黑幣 -5
作者:
i林小拽
時(shí)間:
2020-4-23 23:57
謝謝樓主,我正在找這樣的好文件,誰知道你這么快就發(fā)了
作者:
ahdsdq
時(shí)間:
2020-4-24 07:20
謝謝樓主,很好
作者:
zhaoxla
時(shí)間:
2020-4-25 14:28
感謝,下載看看。
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1