zigbee CC2530 tutorials temperature and humidity sensor 15 Experiment DHT11

Seeing all links courses:

zigbee CC2530 series of tutorials 0 Courses

 

4.12 DHT11 experimental temperature and humidity sensor

4.12.1 Purpose 

Learn to use the temperature and humidity sensors DHT11, and displays the temperature and humidity in the serial data.

4.12.2 Introductory Lecture

First determining temperature and humidity sensors connected to pins DHT11 CC2530 chip and hardware development board according to the schematics shown in Figure 4-14.

FIG 4-14 DHT11 Interface FIG.

DHT11 module parameters are as follows:

1 can detect the ambient temperature and humidity

2. The sensor uses DHT11

3. Humidity measuring range: 20% -95% (range 0 ° -50 °) Humidity measurement error: + --5%

4. The temperature measuring range: 0 -50 degrees of the temperature measurement error: + - 2 degrees

4. Operating voltage 3.3V-5V

The output in the form of a digital output

6. a fixing bolt hole, easy to install

7. platelets PCB size: 3.2cm * 1.4cm

8. The power indicator (red)

 

DHT11 module interface specification

1 VCC external 3.3V-5V

2 DATA platelets switching digital output interface IO port connected microcontroller

3 GND GND External

 

The main function of the program is as follows:

#include <ioCC2530.h>

#include <string.h>

#include "UART.H"

#include "DHT11.H"

/***************************

          主函数

***************************/

void main(void)

{

    Delay_ms(1000);//让设备稳定

    InitUart();    //串口初始化

while(1)

{          

         DHT11();       //获取温湿度

         P0DIR |= 0x40;  //IO口需要重新配置

         /******温湿度的ASC码转换*******/

         temp[0]=wendu_shi+0x30;

         temp[1]=wendu_ge+0x30;

         humidity[0]=shidu_shi+0x30;

         humidity[1]=shidu_ge+0x30;

         /*******信息通过串口打印********/

         Uart_Send_String(temp1,5);

         Uart_Send_String(temp,2);

         Uart_Send_String("\n",1);

         Uart_Send_String(humidity1,9);

         Uart_Send_String(humidity,2);

         Uart_Send_String("\n",1);

         Delay_ms(2000);  //延时,使周期性2S读取1次

      }

      }

4.12.3 experimental results

Figure 4-15 experimental results in FIG.

Published 133 original articles · won praise 51 · Views 200,000 +

Guess you like

Origin blog.csdn.net/aa120515692/article/details/104007169
Recommended