DHT11 Temperature & Humidity Sensor

The DHT11 is a composite sensor that measures relative humidity and ambient temperature.

Sensors9 blocksMicroPythonC++
DHT11

At a glance

Pins and properties exactly as the circuit editor and simulator define this part. The text below explains how to use them.

Pinout

Pinout of the DHT11, drawn as in the circuit editor. Select a label to see that pin in the table below.

Pins

Pins of this part
PinLabelType
VCCVPower in
DATAS1-Wire
NCNCSignal in
GND-Ground

Properties

What you can change in the Property Inspector.

Properties of this part
PropertyRange or choicesDefault
Temperature0 to 80 °C25 °C
Humidity0 to 100 %60 %

The DHT11 is a composite sensor that measures relative humidity and ambient temperature. It contains a resistive humidity sensing component and an NTC temperature sensing element, communicating with the microcontroller via a single-wire digital protocol.


1. Hardware Specifications

  • Operating Voltage: 3.3V to 5.5V.
  • Humidity Measurement Range: 20% to 90% RH (accuracy ±5% RH).
  • Temperature Measurement Range: 0°C to 50°C (accuracy ±2°C).
  • Sampling Rate: 1 Hz (requires 1 second between consecutive readings).
  • Pin Configuration:
    • VCC: Connect to 3.3V or 5V.
    • DATA: Digital I/O pin (requires a 4.7kΩ to 10kΩ pull-up resistor to VCC on bare boards).
    • NC: Not Connected.
    • GND: Common Ground.

2. Communication Protocol & Timing

  • Single-Wire Bidirectional Protocol: The microcontroller pulls the DATA pin low for 18 milliseconds, then lets it pull high to start the transmission. The DHT11 responds by pulling the pin low for 80µs and high for 80µs, followed by transmitting 40 bits of data (8-bit integral temp, 8-bit decimal temp, 8-bit integral humidity, 8-bit decimal humidity, and 8-bit checksum).
  • Time-Gated Protection (Python only): To prevent sensor errors and communication failure, the generated Python code enforces an explicit 2-second rate-limiting guard (_dht_measure_PIN(), shared across every DHT11 block for that pin) — rapid consecutive calls silently skip re-measuring and reuse whatever the sensor last returned. The C++ code path has no equivalent custom guard; it calls readTemperature()/readHumidity() directly every time, relying entirely on the real Adafruit DHT library's own internal timing.

3. Component Properties (Property Inspector)

  • Temperature (temperature): Simulates ambient temperature.
    • Default: 25 °C
    • Range: 0 °C to 80 °C
  • Humidity (humidity): Simulates relative humidity.
    • Default: 60 %
    • Range: 0 % to 100 %

4. Supported Blockly Blocks

Drawing the blocks…

5. Simulator Behavior

  • Environment Controller: Drag the temperature and humidity sliders in the Property Inspector to immediately update the sensor's readings.
  • Error Rate-Limiter (Python): The DHT11 hardware requires a minimum of 1 second between readings; the generated Python code enforces a conservative 2-second guard. Reading faster than that doesn't log anything to any console — it just silently re-returns whatever the sensor last measured, with no user-visible notice. This guard doesn't exist in the generated C++ path (see Section 2).
DHT11 Temperature & Humidity Sensor — OMS Parts