B站演示连接
STM32F103C8T6 DHT11温湿度传感器模块_哔哩哔哩_bilibili
DHT11驱动函数
#include "stm32f10x.h" // Device header
#include "Delay.h"
#define DHT GPIO_Pin_8
#define DHT_PORT GPIOA
#define OUT 1
#define IN 0
#define DHT_Low GPIO_ResetBits(DHT_PORT,DHT)
#define DHT_High GPIO_SetBits(DHT_PORT,DHT)
uint8_t Time;
void DHT11_SendInit(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin =DHT ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(DHT_PORT,&GPIO_InitStructure) ;
} //把GPIO口配置为推挽输出模式
void DHT11_ReceiveInit(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2P