1. Temperature and Humidity sensor (DHT11)


1.1. Introduction

DHT11 is a commonly used sensor to detect the humidity and temperature in a lot of STEM project, it contain different advantage such low cost, easy to use and digital output.

1.2. The principle

The DHT11 contain two major components to detect humidity and temperature respectively.

The first component is using the Conductivity to measure the environment humidity. When humidity is changing, the polymer between two electrodes will change the conductivity, causing the resistance between electrodes drop or rise. The chip on DHT11 will use it to determine correct humidity.

For the second component on DHT11, it is a Negative Temperature Coefficient(NTC) thermistor, when the temperature is rising, the resistance will decrease as follow. The chip will use that to determine the environment temperature. pic_70

1.3. Specification

  • Supply Voltage: 3.3V to 5V

  • Range of Temperature reading: 0-50°C with +- 2°C accuracy

  • Range of Humidity reading: 20%~80% with +- 5% accuracy

  • Sampling Rate: 1Hz

1.4. Pinout Diagram

Pin Function
G Ground
V Voltage Supply
S Signal Output(Digital)

1.5. Outlook and Dimension


Size: 33.5mm X 25mm

1.6. Quick to Start/Sample

Best practice

  • Connect the DHT11 to development board (direct plugin or using wire) auto_fit

  • Open Makecode, using the https://github.com/smarthon/pxt-smartcity PXT

  • After Initial the OLED, setup two variables to store the reading value, then load the value from the DHT11 function to variable

  • The DHT11 function have internal 1s delay for enough sampling time to ensure DHT11 working properly.

  • Show the temperature and humidity variable on the OLED auto_fit

1.7. Result

The Room Temperature and Humidity showing on the OLED screen pic_50

1.8. FAQ

Q: Why the termperature and humidity reaction on DHT11 have delay?
A: The DHT11 sensor required some time to reach the accuracy value, form the official datasheet, the minimum response time of the Temperature and Humidity is 10 second and 6 second respectively.

1.9. Datasheet