Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES Buy from JP

In this lesson, we will show how to use a DHT11 sensor module to get environment temperature and humidity through Arduino Graphic programming tool.

The digital temperature and humidity sensor DHT11 inside contains a chip that does analog to digital conversion and spits out a digital signal with the temperature and humidity, compatible with any MCUs, ideal for those who want some basic data logging stuffs. It’s very popular for electronics hobbyists because it is very cheap but still providing great performance.

First, please plug Osoyoo Magic I/O shield into UNO board. Then connect the DHT11 sensor module to the D3 port of the Magic I/O shield with a 3-pin PNP cable as below:

Notice: Shut off your battery or Unplug your power adapter when upload sketch code to OSOYOO Basic Board for Arduino.

You can download the code directly, then click “Open” in Mixly to choose the code you download:

Download the Code

Or you can do as following operations:

After above operations are completed, connect the OSOYOO Basic Board for Arduino to your computer using the USB cable. The green power LED (labelled PWR) should go on.Open the Graphical Programming software Mixly and follow the next operations:

Drag out Setup block from Control category.

Set the serial baudrate as 9600 and choose the Serial print fuction and drag it to the blank area.

Add some text to the code as below.

Drag out the Serial print and Serial printin from SerialPort category as follows.

Add some text to the code as below.

Find the Sensor block and select the DHT11 related funtion.

Follow the code, and you will get the humidity data and temperature data from the DHT11 sensor.

At last, we drag a Delay block and set the value to 1000ms.

Save and upload program to OSOYOO Basic Board for Arduino.

A few seconds after the upload finishes, open the Serial Monitor, you should now see the humidity and temperature readings displayed at one second intervals.


The DHT11 measures relative humidity. Relative humidity is the amount of water vapor in air vs. the saturation point of water vapor in air. At the saturation point, water vapor starts to condense and accumulate on surfaces forming dew.

The saturation point changes with air temperature. Cold air can hold less water vapor before it becomes saturated, and hot air can hold more water vapor before it becomes saturated.

The formula to calculate relative humidity is:

RH = (\frac{\rho_{w}}{\rho_{s}}) \ x \ 100 \% \\ \\ RH: \ Relative \ Humidity \\ \rho_{w}: \ Density \ of \ water \ vapor\\ \rho_{s}: \ Density \ of \ water \ vapor \ at \ saturation

Relative humidity is expressed as a percentage. At 100% RH, condensation occurs, and at 0% RH, the air is completely dry.


The DHT11 detects water vapor by measuring the electrical resistance between two electrodes. The humidity sensing component is a moisture holding substrate with electrodes applied to the surface. When water vapor is absorbed by the substrate, ions are released by the substrate which increases the conductivity between the electrodes. The change in resistance between the two electrodes is proportional to the relative humidity. Higher relative humidity decreases the resistance between the electrodes, while lower relative humidity increases the resistance between the electrodes.

The DHT11 measures temperature with a surface mounted NTC temperature sensor (thermistor) built into the unit.

With the plastic housing removed, you can see the electrodes applied to the substrate, an IC mounted on the back of the unit converts the resistance measurement to relative humidity. It also stores the calibration coefficients, and controls the data signal transmission between the DHT11 and the OSOYOO Basic Board for Arduino: