DHT11, DS18b20, & MLX90614 with ESP8266 and Arduino IoT Cloud

(Last Updated On: December 12, 2021)

DHT11, DS18b20, & MLX90614 with ESP8266:

Arduino IoT Cloud based Temperature Monitoring using DHT11, DS18b20, & MLX90614-  I have been using DHT11 Temperature and Humidity Sensor, DS18b20 one-wire waterproof digital temperature sensor, and MLX90614 non-contact infrared temperature sensor for quite a long time in different types of temperature monitoring projects using Arduino, ESP32, ESP8266, and Raspberry Pi.

In this article, you are going to learn how to use all these different types of temperature sensors at the same time with only one controller board “Nodemcu ESP8266”. We will monitor all these different temperature sensors using Arduino IoT Cloud. This article is going to be very informative I will try to explain each sensor individually and then in the end we will combine all these sensors to make the final temperature monitoring system.

For this project you will need the following three temperature sensors.

  • DHT11
  • DS18B20
  • MLX90614

If you already know how to use these temperature sensors then you can jump to the very end of this article where you will find the final circuit diagram and the final code. But if you are a beginner and you have a little knowledge about these temperature sensors then I highly recommend reading this article completely, because I am going to explain things in order. I will connect one sensor at a time; I will explain its interfacing and its basic programming before I will explain the final code and circuit diagram.  

Amazon Links:

MLX90614 Non-Contact Infrared Temperature Sensor

DHT11 Temperature and Humidity Sensor

DS18b20 One-wire waterproof digital temperature Sensor

Nodemcu ESP8266 WiFi Module

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

For the Absolute beginners:

As a beginner, you will never want yourself to be discouraged. If you go step by step you will find everything very easy to understand. As a beginner first you will need to know about the Nodemcu ESP8266 controller board as this project is entirely based on the ESP8266. You need to know about its pinouts and technical stuff. You will also need to install the Nodemcu board. So, read my article on “ Getting started with Nodemcu ESP8266”. This article will help you understand the basics and getting your ESP8266 ready for your first project. Then you can read the following articles to further expand your knowledge.

DHT11 Sensor with Nodemcu ESP8266 and Arduino IoT Cloud

Arduino DS18B20 Temperature Sensor

Nodemcu ESP8266 and DS18b20 Temperature Sensor

Arduino MLX90614 Infrared Temperature Sensor

After reading these few articles, you will completely understand how to develop basic, intermediate, and complex level projects. Now, let’s start working on the project.

Interfacing DHT11 sensor with NodeMCU ESP8266:

This sensor module utilizes DHT11Temperature and Humidity Sensor as the sensitive component and has a bypass capacitor and a pull-up resistor on-board. The DHT11 is a pre-calibrated digital output temperature and humidity sensor, with fixing bolt holes for easy installation.


Power supply voltage: 3.3~5V
Output form: digital output
Size: 3.2 x 1.4 cm
Sampling interval: 2 seconds or more
Communication distance: up to 20 m (2.54 mm pitch 3P connection)


Resolution: 1 °C
Accuracy: ± 2 °C
Measurement range: 0-50 °C


Resolution: 1% RH
Accuracy: ± 5% RH (0-50 °C)

DHT11, DS18b20, & MLX90614

  • Connect the VCC of the DHT sensor with the 3V of the Nodemcu
  • Connect the ground of the DHT sensor with the ground of the NodeMCU
  • Connect the digital pin of the DHT sensor with the digital pin 4 of the NodeMCU

DHT11 Nodemcu ESP8266 Code Explanation:

Then in the sketch we will write the code for the DHT11 sensor for which we will first add the DHT.h library.

This line will be used to define the pin which is connected with the NodeMCU

This command is used for the type of the DHT sensor

We will make separate function for reading the data of the DHT11 sensor which will be called in the void loop.

Interfacing DS18B20 sensor with NodeMCU ESP8266:

DS18B20 Description:

3.0V ~ 5.5V power supply
9 to 12 adjustable resolution
Wide temperature range of -55 ℃ ~ +125 ℃
No external components, a unique single-bus interface
Red (VCC), yellow (DATA), green (GND)
Output leads: red (VCC), white (DATA), black (GND)

Now in order to connect the DS18B20 sensor with the NodeMCU:

  • Connect the data pin with the digital pin D2 of the NodeMCU ESP8266
  • Connect the ground wire with the ground of the NodeMCU ESP8266
  • Connect the VCC which is red wire to the 3V of the NodeMCU ESP8266

DHT11, DS18b20, & MLX90614

Then in the sketch, we will write the separate function for the DS18b20 sensor but before this sensor we will insert the library for it which is:

In the loop function we will called the function  ds18b20_sensor(). Now when this line will be executed it will go to that function

Interfacing MLX90614 sensor with the NodeMCU ESP8266:

  • MLX90614 is an infrared thermometer for non-contact temperature measurements.
  • Both the IR sensitive thermopile detector chip and the signal conditioning ASIC are integrated in the same TO-39 can.
  • Integrated into the MLX90614 are a low noise amplifier, 17-bit ADC and powerful DSP unit thus achieving high accuracy and resolution of the thermometer.
  • The thermometer comes factory calibrated with a digital SMBus output giving full access to the measured temperature in the complete temperature range(s) with a resolution of 0.02°C.
  • The user can configure the digital output to be pulse width modulation (PWM). As a standard, the 10-bit PWM is configured to continuously transmit the measured temperature in range of -20 to 120°C, with an output resolution of 0.14°C.

Now to interface it with the NodeMCU ESP8266 we will perform the following steps:

  • Connect the SDA pin with the D0 of the NodeMCU ESP8266
  • Connect the SCL with D1 of the NodeMCU ESP8266
  • Connect the ground pin of the MLX90614 with the ground of the NodeMCU ESP8266
  • Connect the Vin of the MLX90614 with the ground of the Nodemcu ESP8266

DHT11, DS18b20, & MLX90614

Now in the sketch we will write the following code for the MLX90614 sensor

Then we will write the separate function which will be called in the loop function.

Now, you know about the basic connections and codes, now we will combine all these codes and use it in the Arduino IoT Cloud so that we can monitor all these temperature sensors from anywhere around the world.

Designing Application in Arduino IoT:

So in order to use these sensors we will first design Arduino IoT Cloud application for which we will visit Arduino IoT Cloud website. I have a very basic getting started tutorial on the Arduino IoT Cloud. This article explains every single thing that will help you on your journey towards making your very first IoT Dashboard for PC and IoT app for your cell phone. Anyways When you have opened the Arduino IoT Cloud, click on the create things. Then click on the add variables and create the variables for the DHT11 sensor, ds18b20 sensor and MLX90614 sensor. All the variables will be of float type.

DHT11, DS18b20, & MLX90614

Then we will click on the add device which will be used in this project as we are using NodeMCU ESP8266 so we will select ESP8266 and add then select NodeMCU and click on the continue. Then give the name Temperature monitoring and click on the next. Then click on the download button in order to save the secret key.

DHT11, DS18b20, & MLX90614

After that click on the done button the device is added. Then we will click on the network button and  enter the WiFi name, password and secret key.

DHT11, DS18b20, & MLX90614

When we click on the save button the network will be added. So we have created the variables, device, and network.

DHT11, DS18b20, & MLX90614

Then we will click on the dashboard and start adding four different gauges for all the temperature sensors. So, first we will click on the add button and select the gauge.

DHT11, DS18b20, & MLX90614

Then we will give the name to the gauge which is DHT11 and click on the link the variable.

DHT11, DS18b20, & MLX90614

When we will click on the link variable, then we will select the DHT variable and click on the link variable.

DHT11, DS18b20, & MLX90614

Now the variable is successfully linked with the variable. In the similar way, we will link the other variables and gauges. I didn’t explain each and every step in very detail, because I have already explained all these steps in my previous article, link to which I have already shared above.

Temperature Monitoring Complete circuit diagram:

DHT11, DS18b20, & MLX90614

In the beginning, I explained the connection of each temperature sensor individually, you can clearly see the pins remains exactly the same. This time all the three temperature sensors “ MLX90614, DS18b20, and DHT11” are connected with the Nodemcu ESP8266.

Temperature Monitoring System ESP8266 Complete code:

If you take a look at the code, you will find that I just combined the three codes, and some codes are automatically generated. I made a few changes so that I can send the temperature values to the IoT Cloud PC dashboard or to the cell phone app.

After uploading the code to the NodeMCU ESP8266 you will be able to monitor all the sensors using the Arduino IoT app and Arduino IoT Cloud website.

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

%d bloggers like this: