Introduction: Room Temperature & Humidity Monitoring With the ESP32 and AskSensors Cloud

About: IoT Maker, co-founder of

In this tutorial you will learn how to monitor the temperature and humidity of your room or desk using the DHT11 and the ESP32 connected to the cloud.

Our tutorials updates can be found here.

DHT11 Specs:

The DHT11 sensor is able to measure temperature from 0°C to 50°C (accuracy ±2°C) and humidity from 20% to 90% (accuracy ±5%). The sensor requires 5V to operates properly and outputs temperature and humidity in serial data.

So let's get started!

Step 1: Hardware Requirements


In this demo we will need:

  • ESP32 WiFi module.
  • A computer running Arduino IDE.
  • Breadboard
  • DHT11 or DHT22
  • 47K Resistor
  • Wires for connections between the DHT11 and the ESP32.
  • USB Micro cable to connect the ESP32 to your computer.


The connections are pretty easy, connect the followings pins as shown in the image above:

  • DHT VCC to ESP32 5V.
  • DHT Ground to ESP32 Ground.
  • DHT Data to ESP32 IO4 (specified in the code).
  • Connect the Data (IO4) pin and the 5V with a 47K or 10K pull up resistors.

Step 2: Software Requirements

AskSensors account

Sign up for a free account in AskSensors IoT platforms (it is so quick!). Then you will be able to store your data in cloud, access them remotely over the internet and get many features like visualizing your data in graphs, export it in CSV files and setting email alerts...

Create a new sensor with two modules as explained in this getting started guide. Don't forget to copy down your 'Api Key In', It is mandatory for the next steps.

Install ESP32 in arduino IDE

If this is the first time you work with ESP32, please refer to this tutorial where I'm showing you a step by step guide on how to install your ESP32 in Arduino IDE and connect it to the cloud.

Install libraries

Install the DHT library from github (You can also install it by going to Sketch > Include Library > Manage Libraries, and search for adafruit dht library)

Step 3: Writing the Code

Download this demo from AskSensors Github page and decompress it.

The sketch reads temperature and humidity from DHT11 sensor and sends it AskSensors using HTTP GET Requests.

All you need is to modify the following:

const char* ssid     = "..............."; //Wifi SSID
const char* password = "..............."; //Wifi Password
const char* apiKeyIn = "................"; // API Key

Note that the DHT Data pin is connected to the ESP32 IO4 pin. if needed, you can change it here:

// DHT config.<br>

#define DHTPIN            4         // Pin which is connected to the DHT sensor.

Step 4: Run the Test

  1. Connect the ESP32 to your computer through a USB cable.
  2. Open Arduino IDE and upload the code.
  3. Open a serial terminal. You should see your ESP32 connecting to internet through WiFi, Then, the ESP32 will periodically reads the temperature and the humidity and send it to AskSensors.

Step 5: Results

Now, return back to AskSensors.

  1. Sign in and open your Sensor dashboard.
  2. Click on Modules and add graphs to Module 1 and Module 2.
  3. You should see your data steam displayed in the graph as shown in the figures above.

Note: I used a Hair dryer in order to see variations of temperature and humidity ;-)

Step 6: Thanks!

Do you Have any question or suggestion? Just comment, we will be very happy to see your feedback!

Did this tutorial helped you in any way? Please do hit on that little heart :-)