Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use Temperature/Humidity Sensor: Examples, Pinouts, and Specs

Image of Temperature/Humidity SensorDesign with Temperature/Humidity Sensor in Cirkit Designer

Introduction

The DH-11 Sensor by Kuongshun Electronics is a reliable and cost-effective device designed to measure ambient temperature and humidity levels. It is widely used in applications such as weather monitoring systems, HVAC (Heating, Ventilation, and Air Conditioning) systems, and smart home automation. The sensor provides digital output, making it easy to interface with microcontrollers like Arduino, Raspberry Pi, and other embedded systems.

This sensor is ideal for projects requiring basic environmental monitoring, offering a balance of accuracy, simplicity, and affordability.

Explore Projects Built with Temperature/Humidity Sensor

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!

Technical Specifications

The following are the key technical details of the DH-11 Sensor:

Pin Configuration and Descriptions

The DH-11 Sensor has a 4-pin interface, but typically only 3 pins are used in most applications. Below is the pinout:

Pin Number Pin Name Description
1 VCC Power supply (3.3V to 5.5V DC)
2 DATA Digital data output (1-wire protocol)
3 NC Not connected (leave unconnected)
4 GND Ground (0V reference)

Note: Some DH-11 modules may include a pull-up resistor on the DATA pin. If not, you may need to add an external 10kΩ pull-up resistor.

Usage Instructions

How to Use the DH-11 Sensor in a Circuit

  1. Power the Sensor: Connect the VCC pin to a 3.3V or 5V power source and the GND pin to the ground.
  2. Connect the DATA Pin: Attach the DATA pin to a digital input pin on your microcontroller. Use a 10kΩ pull-up resistor if one is not already included on the module.
  3. Read Data: Use a compatible library or write a custom 1-wire protocol to read temperature and humidity data from the sensor.

Example Circuit

Below is an example of how to connect the DH-11 Sensor to an Arduino UNO:

Arduino Code Example

Here is a sample Arduino sketch to read data from the DH-11 Sensor using the DHT library:

#include <DHT.h>

// Define the pin where the DH-11 DATA pin is connected
#define DHTPIN 2

// Define the type of DHT sensor (DHT11 in this case)
#define DHTTYPE DHT11

// Initialize the DHT sensor
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600); // Start serial communication at 9600 baud
  dht.begin();        // Initialize the DHT sensor
  Serial.println("DH-11 Sensor Initialized");
}

void loop() {
  delay(2000); // Wait 2 seconds between readings

  // Read temperature and humidity values
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();

  // Check if the readings are valid
  if (isnan(humidity) || isnan(temperature)) {
    Serial.println("Failed to read from DH-11 Sensor!");
    return;
  }

  // Print the results to the Serial Monitor
  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" °C");
}

Important Considerations and Best Practices

Troubleshooting and FAQs

Common Issues and Solutions

  1. No Data Output:

    • Ensure the sensor is powered correctly (3.3V to 5.5V).
    • Verify the pull-up resistor on the DATA pin.
    • Check the wiring connections for loose or incorrect connections.
  2. Incorrect or NaN Readings:

    • Ensure the sampling rate is not faster than 1 Hz.
    • Verify that the sensor is operating within its specified temperature and humidity range.
    • Check for electromagnetic interference (EMI) from nearby devices.
  3. Sensor Not Responding:

    • Confirm that the correct pin is defined in the code.
    • Test the sensor with a different microcontroller or port to rule out hardware issues.

FAQs

Q1: Can the DH-11 Sensor measure negative temperatures?
No, the DH-11 Sensor is designed to measure temperatures in the range of 0°C to 50°C.

Q2: How accurate is the DH-11 Sensor?
The temperature accuracy is ±2°C, and the humidity accuracy is ±5%. For applications requiring higher precision, consider using the DHT22 sensor.

Q3: Can I use the DH-11 Sensor outdoors?
The DH-11 Sensor is not waterproof and is intended for indoor use. If used outdoors, ensure it is housed in a protective enclosure.

Q4: What is the maximum cable length for the DH-11 Sensor?
The recommended maximum cable length is 20 meters. For longer distances, use a shielded cable and reduce the pull-up resistor value to 5kΩ.

By following this documentation, you can effectively integrate the DH-11 Sensor into your projects for reliable temperature and humidity monitoring.