ESP8266 DHT11 Humidity Temperature Data logger

In this tutorial we are interfacing DHT11 or DHT22 Humidity temperature sensor with ESP8266 NodeMCU. We are making complete Humidity and Temperature data logger with DHT11 and NodeMCU. Data logger web server with real time graphs and tables, mostly seen on thingspeak. But this time we are putting complete graphs and tables all inside NodeMCU without using thingspeak. For this we need graphs library that we are using from an open source Chart drawing library and Knowledge of alax, html and javascript.

Node MCU data logger

The DHT11 (or DHT22 and similar) are cheap temperature and humidity sensors. The communicate with a ESP8266 is over a single wire, but unfortunately it is not compatible with the 1-Wire protocol defined by Dallas Semiconductors.

The electric connection to the NodeMCU is very simple, as the DHT series can be powered direct with 3.3V. Only 3 wires are needed: VCC, GND and the data line.

Things we need

  1. NodeMCU ESP8266
  2. USB Cable
  3. Laptop
  4. Internet and wifi router
  5. DHT11 Humidity Temperature Sensor

DHT11 Connections with NodeMCU

ESP8266 DHT11 Interfacing

DHT11 Sensor Specifications

DHT11 Temperature & Humidity Sensor features a temperature & humidity sensor complex with a calibrated digital signal output. By using the exclusive digital-signal-acquisitiontechnique and temperature & humidity sensing technology, it ensures high reliability and excellent long-term stability. This sensor includes a resistive-type humidity measurement component and an NTC temperature measurement component, and connects to a high-performance 8-bit microcontroller, offering excellent quality, fast response, anti-interference ability and cost-effectiveness.

If you are using module it comes with a 4.7K or 10K resistor. You need external 10K or 4.7K pull up on data pin to VCC.

DHT11 Pinout for ESP8266

DHT11 Specifications:

  • Low cost
  • 3 to 5V power and I/O
  • 2.5mA max current use during conversion (while requesting data)
  • Good for 20-80% humidity readings with 5% accuracy
  • Good for 0-50°C temperature readings ±2°C accuracy
  • No more than 1 Hz sampling rate (once every second)
  • Body size 15.5mm x 12mm x 5.5mm
  • 4 pins with 0.1″ spacing

NodeMCU Program for Temperature Humidity Data Logger

Before moving directly on coding install required libraries.

Go to menu Sketch >> Include Library >> Manage Library

Install DHT sensor library for ESPx by beegee library. or DownloadNodeMCU DHT11 LibraryAfter installing library

To draw graphs we use chart.js from CDN. you can use char.js file directly inside the NodeMCU for this see : AJAX Web Server

To get knowledge of real time data update without refresh read this.

Program consists of two parts one is HTML, Javascipts and Arduino Code

Arduino IDE Code For Graphs ESP8266 and Data Logging

Before directly uploading make changes in WiFi SSID and Password as per yours WiFi. most of the things are explained inside code comments. also make index.h header file and save it near to your ino file.

In this example we are creating web server inside ESP8266 for data logging. It has two parts one part that displays HTML web GUI and second is that takes AJAX request and reads ADC data.


index.h HTML Code File for data logger


After uploading program in NodeMCU open serial monitor with 115200 baud rate and get IP address of NodeMCU. Open it in web browser.

ESP8266 Humidity Temperature Datalogger




5 thoughts on “ESP8266 DHT11 Humidity Temperature Data logger

  1. Hi! I understood this. It is that I would like to know if it is possible to store a series of measures on my web page and read them off-line without using third parties. i.e. Excell sheets on Google or external clouds. Thank you! Claude

  2. It works perfectly. But I have a question. When I refresh the web page, the measurement starts again, losing the data. It would be possible for every “x” minutes to upload these acquired data and put them on my web page. Pure and graphical data. Thanks for your help. Thank you! Claude G.

Leave a Reply