Arduino for BPI:bit 4 :use DHT11 module


(bpi team) #1

DHT11 module is used to complete the collection of humidity and temperature

dht11 module

bpi:bit board

dht11 Lib

main function

void cjt_DHT11_Init()

unsigned char cjt_DHT11_Read_Bit()

void cjt_DHT11_Read()

expamle code

#include "cjt_DHT11.h"
#include <Arduino.h>

cjt_DHT11 dht11(26);			//对应 DATA 的 pin 脚

void setup()
{

  Serial.begin(9600);
  Serial.printf("OK!");
  Serial.println();

}

void loop()
{
  dht11.cjt_DHT11_Read();			
  Serial.printf("temp:");
  Serial.print(dht11.dht11_temp);

  Serial.printf("humt:");
  Serial.print(dht11.dht11_humt);

  delay(1300);  //这里的延时要长些才能读取下一次
}

summary

This DHT11 is written after someone else’s library, mainly to feel how to write a library according to the manual. As long as it’s well encapsulated, it doesn’t feel very complicated to implement in code