DHT11 Library


With the DHT11 library, the humidity and temperature sensor DHT11 can be read out via one wire and a microcontroller of the MSP430 series. As microcontroller is used the MSP430G2553 (on the EXP430G2 launchpad) and as a development environment is used the IAR Embedded Workbench.

Download DHT11 library

dht11-library.zip

Schematic EXP430G2 and DHT11

The circuit is quite simple. The DHT11 can tolerate voltages of 3 up to 5.5 V, but since the MSP430 can handle 3.3 V, both ICs are operated with 3.3 V. In addition, a 4.7 kΩ pull-up is required. The complete circuit can be seen in the following figure.

DHT11 library and schematic

Description DHT11 library

void DHT11_init (void)
Initialization of DHT11, the MSP430 Timer A and GPIO-Pin 1.4 are initialized

 

int DHT11_read (unsigned char *p)
Reads a complete packet (humidity, temperature, and CRC checksum) from the DHT11.
*p Array contains the information for temperature and humidity. The array has the following format:

P [0] = start bit

P [1] = humidity of the DHT11

P [2] = humidity (decimal place) of the DHT11

P [3] = temperature of the DHT11

P [4] = temperature (decimal place) of the DHT11

P [5] = CRC check sum of the DHT11

return Returns the status of the DHT.

-1: Transmission is faulty

0: Transmission correct

-4: No start bit

 

 

Leave a comment

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.