MSP430 & DHT11 Temperature / Humidity Sensor

by drselim in Circuits > Microcontrollers

5931 Views, 1 Favorites, 0 Comments

MSP430 & DHT11 Temperature / Humidity Sensor

MSP430 Launchpad & DHT11 Sensor

DHT11 is one of the most popular temperature and humidity sensors that are used with microcontrollers such as arduino and microcomputers such as Raspberry Pi. However, most of the time, its usage and working principles are not described properly. Most of the projects include the sensor's libraries and you just use it without knowing how it works.

In this instructable, we'll see how the sensor works in detail and we''ll use the C code that I wrote from scratch in Code Composer Studio (without using any libraries) in order to make it work with the MSP430G2553 microcontroller.

If you just want to make the DHT11 work with MSP430, you can directly jump to the video and use the code in the github link with the proper connections shown in the slides.

C Code to be used in Code Composer Studio

Supplies

MSP430 Launchpad, Breadboard, DHT11 sensor, jumper cables, resistor (10 kOhm), Code Composer Studio

Overview of the DHT11 Sensor

dht11_overview.png

As the DHT11 is initiated, DHT11 will start sending the values with the following order (as seen in the slide above):

-Humidity(Integer)

-Humidity(Fractional) - One remark here, DHT11 always sends 0 as fractional humidity (According to my experience)

-Temperature(Integer)

-Temprature(Fractional)

Connections

dht11.png
temp_humidity_sensor_bb.jpg

The connections should be done as seen above in order to work with our code. (P2.4 is used)

Communicating With the DHT11

dht11_comm_process.png

DHT11 uses a single bus connection meaning that we can only use one connection for both sending and receiving data to the sensor. This provides a small obstacle since we have to set the direction of the port (of MSP430) first as an output and then as an input.

Once properly initiated with the sequence that is mentioned in the slide, DHT11 starts to send the data (1+40) frames which correspond to Ready to Send (1 bit) + (1 byte humidity int.) + (1 byte humidity frac.) + (1 byte temperature int.) + (1 byte temperature frac.) + (1 byte checksum) = 41 bits (total)

In the frames that the DHT11 Sends:

50 μs low & 26~28 μs high corresponds to bit 0

50 μs low & 70 μs high corresponds to bit 1

Communicating With the DHT11 (Continued)

dht11_comm_diagram.png

As seen in the slide above, the DHT11 send the values in 40 frames (+1 ready to send in the beginning)

Loading the Code to the MSP430 and Reading the Values.

Once you upload & debug the C code to the MSP430 with the Code Composer Studio, you'll be able to read the values in the expressions window (after resuming the code). This will be a one-time read. However if you want to read the values in a loop and write the output to the Terminal, you can follow the instructions that I described in the following video:

Serial Monitor for MSP430 & DHT11 Example

If you like the content please subscribe to my YouTube channel for similar tutorials and projects.

https://www.youtube.com/c/drselim

Thank you for your time.