[vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”Introduction” tab_id=”1395588864-1-66″][vc_column_text]
In our daily life, temperature and humidity on our lives has a great impact, especially for food and factory production. If we do wrong with them, it can bring in a great loss. In this project, we will look at how to use a temperature and humidity breakout board [bigcommerce link=”/breakout-of-dht11-temperature-and-humidity-sensor/” target=”_blank”]DHT11 digital temperature and humidity sensor [/bigcommerce]. It has a calibrated digital signal output. The product has excellent quality, fast response, anti-interference ability, high cost and other advantages. Single Wire serial interface allows quick and easy system integration.
[/vc_column_text][/vc_tab][vc_tab title=”Specifications” tab_id=”1395927443536-4-0″][vc_column_text]Technical Parameters:
- Supply voltage: 3.3 ~ 5.5V DC
- Output: single-bus digital signal
- Measuring range: Humidity 20-90% RH, Temperature 0 ~ 50 ℃
- Accuracy: Humidity + -5% RH, temperature + -2 ℃
- Resolution: Humidity 1% RH, temperature 1 ℃
- Long-term stability: <± 1% RH / Year
Notes
1. Avoid to use in the condensation conditions
2. Long-term storage temperature 10-40 ℃, humidity below 60%
3. Make sure a use of correct voltage and good ground connection.[/vc_column_text][/vc_tab][vc_tab title=”Parts List” tab_id=”1395590550281-2-10″][vc_column_text]
- 1 x [bigcommerce link=”/arduino-usb-board-uno-r3/” target=”_blank”]Arduino controller[/bigcommerce]
- 1 x USB data cable
- 1 x [bigcommerce link=”/breakout-of-dht11-temperature-and-humidity-sensor/” target=”_blank”]DHT 11 module[/bigcommerce]
[/vc_column_text][/vc_tab][vc_tab title=”Wire Diagram” tab_id=”1395588864-2-77″][vc_column_text]The module DHT11 is connected to the Arduino board using the following way:
The above figure shows a typical connection of DHT11 to MCU.
The following are details:
- ‘+’ of DHT11 breakout -> 5v of Arduino
- “-” of DHT11 breakout -> Ground of Arduino
- ‘S’ of DHT11 breakout -> GPIO 7 of Arduino
[/vc_column_text][/vc_tab][vc_tab title=”Code” tab_id=”1395590610521-3-8″][vc_column_text]
int DHpin = 8; byte dat [5]; byte read_data () { byte data; for (int i = 0; i <8; i + +) { if (digitalRead (DHpin) == LOW) { while (digitalRead (DHpin) == LOW); / / wait for 50us; delayMicroseconds (30); / / determine the duration of the high level to determine the data is '0 'or '1'; if (digitalRead (DHpin) == HIGH) data | = (1 << (7-i)); / / high front and low in the post; while (digitalRead (DHpin) == HIGH); / / data '1 ', wait for the next one receiver; } } return data; } void start_test () { digitalWrite (DHpin, LOW); / / bus down, send start signal; delay (30); / / delay greater than 18ms, so DHT11 start signal can be detected; digitalWrite (DHpin, HIGH); delayMicroseconds (40); / / Wait DHT11 response; pinMode (DHpin, INPUT); while (digitalRead (DHpin) == HIGH); delayMicroseconds (80); / / DHT11 a response, pulled the bus 80us; if (digitalRead (DHpin) == LOW); delayMicroseconds (80); / / DHT11 80us after the bus pulled to start sending data; for (int i = 0; i <4; i + +) / / receives temperature and humidity data, the parity bit is not considered; dat [i] = read_data (); pinMode (DHpin, OUTPUT); digitalWrite (DHpin, HIGH); / / sending data once after releasing the bus, wait for the host to open the next Start signal; } void setup () { Serial.begin (9600); pinMode (DHpin, OUTPUT); } void loop () { start_test (); Serial.print ("Current humdity ="); Serial.print (dat [0], DEC); / / display the humidity-bit integer; Serial.print ('.'); Serial.print (dat [1], DEC); / / display the humidity decimal places; Serial.println ('%'); Serial.print ("Current temperature ="); Serial.print (dat [2], DEC); / / display the temperature of integer bits; Serial.print ('.'); Serial.print (dat [3], DEC); / / display the temperature of decimal places; Serial.println ('C'); delay (700); }
We burn the program into Arduino board, and then wait minutes and then open the Serial Monitor window to watch results displayed.
When we hold the sensor with our hand, we can see the temperature increasing.
[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]
Leave a Reply
You must be logged in to post a comment.