You are on page 1of 7

ADVANCED MICROCONTROLLER

MINI PROJECT
Interface DHT11 with MSP43

Division: B Batch: B2
Sr. No. Roll No. Name
01 16010320049 Shreesh Parte
02 16010320052 Niraj Patil
03 16010320053 Deep Pattani

Course coordinator
Prof. Savita Raut
Introduction

 The DHT11 is a commonly used Temperature and humidity sensor


that comes with a dedicated NTC to measure temperature and an 8-bit
microcontroller to output the values of temperature and humidity as serial
data.

DHT11 Specifications

 Operating Voltage: 3.5V to 5.5V


 Operating current: 0.3mA (measuring) 60uA (standby)
 Output: Serial data
 Temperature Range: 0°C to 50°C
 Humidity Range: 20% to 90%
 Resolution: Temperature and Humidity both are 16-bit
 Accuracy: ±1°C and ±1%

 These sensors are very basic and slow, but are great for hobbyists who
want to do some basic data logging. The DHT sensors are made of two
parts, a capacitive humidity sensor and a thermistor.

 There is also a very basic chip inside that does some analog to digital
conversion and spits out a digital signal with the temperature and
humidity. The digital signal is fairly easy to read using any
microcontroller.
Code

#include <msp430.h>
volatile int temp[50];
volatile int diff[50];
volatile unsigned int i=0;
volatile unsigned int j=0;
volatile unsigned char hh = 0;
volatile unsigned char hl = 0;
volatile unsigned char th = 0;
volatile unsigned char tl = 0;
volatile unsigned char checksum = 0;
volatile unsigned char check = 0;
volatile unsigned char dataok = 0 ;
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
__delay_cycles(2000000);
P2DIR |= BIT4;
P2OUT &= ~BIT4;
__delay_cycles(20000);
P2OUT |= BIT4;
__delay_cycles(20);
P2DIR &= ~BIT4;
P2SEL |= BIT4;
TA1CTL = TASSEL_2|MC_2;
TA1CCTL2 = CAP | CCIE | CCIS_0 | CM_2 | SCS ;
_enable_interrupts();
while(1){
if (i >= 40){
for (j = 1; j <= 8; j++){
if (diff[j] >= 110)
hh |= (0x01 << (8-j));
}
for (j = 9; j <= 16; j++){
if (diff[j] >= 110)
hl |= (0x01 << (16-j));
}
for (j = 17; j <= 24; j++){
if (diff[j] >= 110)
th |= (0x01 << (24-j));
}
for (j = 25; j <= 32; j++){
if (diff[j] >= 110)
tl |= (0x01 << (32-j));
}
for (j = 33; j <= 40; j++){
if (diff[j] >= 110)
checksum |= (0x01 << (40-j));
}
check = hh+hl+th+tl;
if (check == checksum)
dataok = 1;
else
dataok = 0;
}

}
}

#pragma vector = TIMER1_A1_VECTOR


__interrupt void Timer_A1(void){
temp[i] = TA1CCR2;
i += 1;
if (i>=2) diff[i-1]=temp[i-1]-temp[i-2];
TA1CCTL2 &= ~CCIFG ;
}
Flowchart
Circuit
Output

Conclusion
In this mini project we have successfully interfaced DHT-11 Sensor
with MSP430 Launchpad and obtained output values of temperature
and humidity.

You might also like