Temperature and humidity reading from RHT03 (also known as DHT22) using ESP8266 WeMos D1 mini board.

As many other examples available on the internet, it was inevitably to post myself a temperature and humidity reading application.

The values from sensors are displayed on the mobile phone, using Blynk IoT framework.


ESP8266 WeMos D1 mini board


RHT03 temperature and humidity sensor

rht03-dht22 sensor
Sensor specifications:

  • 3.3-6V Input
  • Humidity from 0-100% RH, ±2% RH accuracy
  • -40 – 80 degrees C temperature range,±0.5 degrees C

source: http://cdn.sparkfun.com/datasheets/Sensors/Weather/RHT03.pdf

Details here: https://learn.adafruit.com/dht

Download and install DHT22 arduino library into your Arduino IDE. The library is available here: https://github.com/adafruit/DHT-sensor-library

dht library arduino

Blynk knowledge and blynk app installed on your android or iphone.


Breadboard and wires


Ok, let’s put this ingredients into one “bowl”, like this


Connect the data pin of the sensor to GPIO2 (marked as D4) which already has an internal 10k pull-up resistor.


Change your BlynkAuthWiFiNetworkWiFiPassword to your settings.

This program generate a serial output like this:

esp-utput serial


The blynk app has a gauge, a value display and a history graph item


updated 2020.07.23

BOM used in this article:


ESP8266: DHT22 temperature sensor
Tagged on:                         

6 thoughts on “ESP8266: DHT22 temperature sensor

  • February 3, 2017 at 16:09

    This is EXACTLY what I needed!
    Many thanks for documenting this so good.

    • February 3, 2017 at 16:12

      Still working right now in my home.
      Glad it helps!

      I’ve added a loop of 3 times readings from the sensor (with a pause of 3 seconds) if I get a fail reading from the sensor.

  • February 17, 2017 at 06:42

    Thank you. This is one of the best well expleined instructions. Is this code suitable for ESP8266 only (without WeMos D1 mini board) if we program the ESP8266 module via CP2102 USB UART Board (mini)? I want to miniaturize the setup that is why I am asking:)

    • February 17, 2017 at 10:03

      Thanks for reading.
      This instructions and my knowledges are gathered from many sources. You cand find many instructables with this setup.

      To answer on you question, yes, you can use this code on any ESP8266 module. The only mention is that to check if the board/module you have has an internal pull-up resistor on D4 pin (for this example).
      If you are using any other digital pin, the reading of the sensor will also be ok.
      Here is an example with nodemcu board
      Join us on facebook group “ESP8266” to get specific answers.

  • July 22, 2020 at 22:06

    Just a little tip. Do not use the delay() function, IT will delay your commands to Blynk

    • July 23, 2020 at 13:10

      Hello, thank you for the suggestion! That delay should not be inside the loop.

      I’ve changed the code above, thank you.


Leave a Reply to Gumus Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.