当前位置:网站首页>Chapter I use of DHT11 temperature and humidity sensor
Chapter I use of DHT11 temperature and humidity sensor
2022-07-16 06:35:00 【Bi sheda escape】
Among the ten Bi design works , At least four devices will use temperature and humidity sensors , So this article first teaches you how to use DHT11 Temperature and humidity sensor . Enter... On Taobao “DHT11” You can find this sensor directly , The price is cheaper .
Here's the picture ,DHT11 The temperature and humidity sensor has four pins , But in practice, we only use three pins , They are connection 3.3V or 5V Of 1 Pin 、 Responsible for data communication 2 Pins and connections GND Of 4 Pin , and 3 Pin No. is named NC, It means empty pin , There's no practical use . Many students found three pins on Taobao DHT11 sensor , Those three pins are in the picture 1、2、4 Pin , So don't worry about whether the temperature and humidity sensor you buy is different from the temperature and humidity sensor introduced in this chapter .

Let's talk about STM32F103C8T6 And DHT11 Communication code , Follow the official account at the bottom of the article , There is a code download link at the bottom of the corresponding tweet section of the official account , After downloading the materials , According to the wiring diagram in the data , DuPont line STM32F103C8T6 And DHT11 Connect the temperature and humidity sensors , Re pass Jlink or STlink Burn the code into STM32 Then you can .

wendu[ ] and shidu[ ] These two arrays store DHT11 Temperature and humidity data transmitted by the sensor .
delay_init( ) Initialization delay function , After executing this statement ,28 Yes delay_ms(1000) The delay effect will be accurate .
14 Row sum 16 Line is only related to serial port printing , among NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2) Is to set interrupt priority grouping ,uart_init(9600) Responsible for initializing the serial port 1, The baud rate is 9600. Deleting these two lines of code will not affect STM32 Acquisition of temperature and humidity data .
DHT11_INIT( ) DHT11 Initialization function , After initialization, temperature and humidity data can be collected .
Read_DHT_Data(wendu, shidu) Get the numerical function of temperature and humidity , After executing this statement ,DHT11 The detected temperature data is stored in wendu[ ], Humidity data is stored in
shidu[ ] in . among wendu[0] Stored is an integer of the temperature value ,wendu[1] Stored is the decimal of the temperature value ,shidu[0] Stored is an integer of humidity value ,shidu[1] The decimal of humidity value is stored .
24 Row sum 26 Yes printf( ) It is a serial port printing function , As long as you don't delete 14 Row sum 16 Line code , Whole main Function code can realize every 1 Seconds to print temperature and humidity data .
Since then, the code explanation has been completed , Students who want to know the specific implementation process of each function can download the code at the bottom of the article .
When our design uses DHT11 Temperature and humidity sensor , Just know the function marked in red above , You can easily transplant the linked code into your own design code , In later chapters , I will show you .( The premise is that the master of the design MCU choose STM32F103C8T6)

边栏推荐
- [paper notes] - RESNET - 2015-cvpr
- EasyCVR国标协议接入设备,设备在线、通道却不在线的原因是什么?
- 01kNN_Regression
- RT_thread信号量的使用
- 语音芯片JQ8400的使用心得
- STM32—TIM3输出PWM信号驱动MG996R舵机(按键控制)
- CodeBlocks快捷键
- Keil5 software reports error: l6406e: no space in execution regions with ANY selector matching xxx
- 01机器学习:评估指标
- Stm32f429+lan4720a+lwip problem record and solution
猜你喜欢

RT_thread信号量的使用

第十二届蓝桥杯嵌入式模拟题
![[Multisim] problems that must be paid attention to when using ne5532p series operational amplifier simulation](/img/16/496c26d87407cc8e67182f209fe70b.png)
[Multisim] problems that must be paid attention to when using ne5532p series operational amplifier simulation

RTthread-线程的创建

嵌入式软件开发 STM32F407 跑马灯 HAL库版

【Multisim】关于Multisim仿真“过零比较器”出现的问题以及解决方法

基于RT_thread的分布式无线温度监控系统实战(一)
![[matlab] matlab lesson 2 - preliminary drawing](/img/8d/bcceb32c26b527d8cac6d7a8ba3a3a.png)
[matlab] matlab lesson 2 - preliminary drawing

C语言位操作(适用于操作单片机寄存器)

【信号调理】精密检波电路和PCB示例
随机推荐
CodeBlocks快捷键
HDU 3078 Network (lca+排序)
第十二届蓝桥杯嵌入式模拟题
【MATLAB】matlab第二课——绘图初步
RT_thread空闲线程及两个常用的钩子函数
[signal conditioning] example of precision detection circuit and PCB
C语言动态内存分配原理以及堆区的使用(malloc、calloc、realloc、free)
Max3232ese problem record and solution
C language macro definition (macro parameter creation string, pretreatment adhesive)
第一章 DHT11温湿度传感器的使用
STM32入门之GPIO详解
Stm32f429+lan4720a+lwip problem record and solution
Download and installation of CodeBlocks on the official website
[matlab] matlab lesson 3 - advanced drawing
Aidl for Hal
嵌入式软件开发 STM32F407 跑马灯 HAL库版
IIC通讯
自动化仪表与过程控制(期末复习)
OPENGL 3D图形开发小记,地形,光照,阴影等
梯度下降法的向量化