A temperature monitoring system measures, monitors, and controls the temperature and humidity in a specific environment.
Objective
The aim of this experiment is to help the user:
- Learn how to use DHT 11 Sensor
- Interfacing DHT 11 sensor with microcontroller.
- Learn the applications of the circuit containing temperature sensors.
Component knowledge
What is a DHT11 Sensor? The DHT11 sensor commonly uses a dedicated NTC to measure temperature and an 8-bit microcontroller to output temperature and humidity values as serial data.
Figure: DHT 11 sensor
Pin Identification of the DHT 11
The DHT 11 sensor comes in a 3-pin package. Here’s a breakdown of the pins:
- VCC (Power Supply): This pin provides power to the sensor. It typically operates on a +5V or +3.5V supply.
- NC : No connection and hence not used.
- GND (Ground): Connect the ground pin to the negative or ground of the power supply.
- DATA: Outputs both Temperature and Humidity through serial Data The voltage increases linearly with temperature.
How an DHT 11 Sensor Works
This device uses a thermistor to monitor temperature and a capacitive humidity sensor to measure relative humidity. A dielectric substrate separates the electrodes of a humidity-detecting capacitor and retains moisture. When the humidity level fluctuates, the capacitance value changes as well. The IC measures, processes, and stores analog resistance values, then translates them into digital values.
The system monitors the sensor’s resistance value as it warms up using a negative temperature coefficient thermometer (NTC). Manufacturers commonly make this sensor from semiconductor ceramics to achieve a higher resistance value even with the smallest temperature change.
With a 2°C precision, the DHT11’s temperature range is 0 to 50 degrees Fahrenheit. This sensor can accurately monitor humidity levels from 20% to 80% with a 5% degree of precision. One reading per second, or 1Hz, is the sampling rate of this sensor. The microcontroller DHT11 has a power consumption of 3 to 5 volts. The sensor draws a maximum current of 2.5 mA during a measurement.
Testing a DHT 11 Sensor
1. Testing with a Microcontroller (e.g., Arduino)
The DHT 11 can easily be connected to an Arduino or similar microcontroller to read temperature values.
Wiring:
- VCC to 5V on the Arduino.
- GND to the GND pin on the Arduino.
- DATA to any analog input pin on the Arduino (e.g., A0).
Explanation:
- The Arduino reads the analog value from the DHT 11 sensor and converts it into a temperature and humidity reading.
- The arduino IDE will provide a serial monitor for you in order to see the output temperature and humidity range which is detected.
2. Testing with a Multimeter
If you don’t have a microcontroller, you can test the DHT 11 using a multimeter to measure the output voltage, and then calculate the temperature.
- Power the Sensor:
- Connect the VCC pin to a 5V or 3.5V power supply.
- Connect the GND pin to the ground of the power supply.
- Measure the Output:
- Use a multimeter to measure the DATA pin’s voltage relative to GND.
- The multimeter will show a small voltage value in millivolts.
- Convert to Temperature:
- Use the formula: Temperature (°C) = Vout (mV)
- For example, if the multimeter reads 30 mV, the temperature is 30 mV= 30°C.
The DHT 11 temperature sensor is a simple, low-cost, and accurate device for measuring temperature and humidity.The sensor can measure temperature from 0°C to 50°C and humidity from 20% to 90% with an accuracy of ±1°C and ±1%. So if you are looking to measure in this range then this sensor might be the right choice for you.
Materials to use
Circuit diagram
Figure: DHT11 connection to the source and arduino
NOTE: Refer to project 16 for LCD display connection
Figure: Components used to make connection on the board
Arduino Codes
Code Knowledge
This block includes the DHT sensor library and defines the constant Type as DHT11, specifying the sensor type used.
Explanation of the Code Block
#define Type DHT11: Sets a constant called Type with the value DHT11, which tells the program which DHT sensor it will be working with.
#include "DHT.h": Adds the DHT sensor library to your project, enabling functions to interact with DHT11 and DHT22 sensors.
This block initializes the DHT Sensor and variables. The following are the details of each line:
The Arduino connects its digital pin 2 to the data pin of the DHT11 sensor.
DHT HT(sensePin, Type);: Creates a DHT object named HT, specifying the data pin and sensor type (DHT11).
humidity, tempC, tempF: Float variables to store humidity, temperature in Celsius, and temperature in Fahrenheit, respectively.
setTime = 500: A delay time of 500 milliseconds used in the setup to allow the sensor to stabilize.
The code declares the variable dt = 1000, possibly intending to use it for a delay time between readings, but it doesn’t actually use it.
This function in Arduino programming runs once at the start of the program. It initializes settings, configures pins, and prepares the hardware components before the main loop begins.
HT.begin();: Initializes the DHT11 sensor for data collection.
delay(setTime);: Waits for 500 milliseconds to allow the sensor to stabilize before taking readings.
humidity = HT.readHumidity();: Reads the humidity from the DHT11 sensor and stores it in the humidity variable.
tempC = HT.readTemperature();: Reads the temperature in Celsius from the sensor and stores it in tempC.
tempF = HT.readTemperature(true);: Reads the temperature in Fahrenheit by passing true as an argument, and stores it in tempF.
This block displays data on the LCD in the following sequence:
The line lcd.setCursor(0, 0); positions the cursor at the start of the first row.
At that location, lcd.print("Temp F= "); writes the label “Temp F= “. Right after, the Fahrenheit temperature is displayed using lcd.print(tempF);.
To show the humidity on the next line, the command lcd.setCursor(0, 1); moves the cursor to the beginning of the second row.
The label “Humidity= ” is then printed with lcd.print("Humidity= ");.
This is followed by the humidity value via lcd.print(humidity);, and a percentage symbol is added using lcd.print(" %"); to clarify the unit.
A short pause is introduced with delay(500);, giving users time to read the screen.
Finally, lcd.clear(); wipes the display, getting it ready for the next set of readings.
This block is about sending Data to the Serial Monitor. So, here is the meaning of each line:
The code Serial.print("Humidity: "); displays the label “Humidity: ” on the Serial Monitor.
Following that, Serial.print(humidity); outputs the actual humidity reading.
To separate humidity from temperature data, Serial.print("% Temperature "); is used.
Next, Serial.print(tempC); shows the temperature in Celsius.
This is followed by Serial.print(" C ");, which appends the Celsius unit.
The Fahrenheit value is then printed using Serial.print(tempF);.
Finally, Serial.println(" F "); adds the Fahrenheit unit and moves the cursor to the next line for the next reading.
Results
The system displays the reading on both an LCD screen and the Serial Monitor. Here’s a breakdown of the expected outputs:
- Expected LCD Output:
Row 1: Temperature (in Fahrenheit) and Row 2 Humidity (in percentage)
Example output:
Temp F= 77.00
Humidity= 60.00 %
The screen clears and updates every 500 ms to reflect new sensor readings.
- Serial Monitor:
Humidity and temperature (in Celsius and Fahrenheit) to the Serial Monitor every 500 ms.
Example Output: If the DHT11 sensor reads 60% humidity and 25°C (77°F) the serial monitor would show Humidity: 60.00% Temperature 25.00 C 77.00 F.
These readings will update approximately every 500 ms.