Measuring Temperature and Humidity Using DHT11 and ESP8266 NodeMCU

ESP8266 15-10-25
17 0

Tutorial plan

1- Objective of the tutorial

2- The necessary components

3- ESP8266 Assembly with I2C LCD Display and DHT11 sensor

4- Program ESP8266 NodeMCU with MicroPython

 

 

Objective of the tutorial

The objective of this tutorial is to design and implement a system capable of measuring and displaying real-time temperature and humidity using the DHT11 sensor and the ESP8266 NodeMCU microcontroller, with the results shown on an LCD I2C screen.

This tutorial aims to teach how to:

- interface the DHT11 sensor with the ESP8266 NodeMCU to acquire temperature and humidity data through a digital signal.

- connect and configure an I2C LCD display to the ESP8266 NodeMCU to visualize the measured values in real time.

- write and upload a MicroPython program that reads data from the DHT11 sensor and sends the results to the LCD screen for display.

- understand the operation of the DHT11 sensor, including its method of measuring temperature and humidity and its communication protocol.

Develop a compact and efficient environmental monitoring system, which can serve as the foundation for more advanced IoT applications such as smart weather stations or home automation systems.

 

The necessary components

1. ESP8266 NodeMCU

The ESP8266 NodeMCU acts as the main controller that reads the temperature and humidity data from the DHT11 sensor and sends the results to the LCD screen.

2. DHT11 Temperature and Humidity Sensor

The DHT11 sensor is a digital sensor that measures both temperature and humidity.

An internal microcontroller that processes and transmits the data in digital form.

The DHT11 provides an accuracy of about ±2°C for temperature and ±5% for humidity.

It communicates with the ESP8266 via a single digital pin.

3. LCD I2C 20x4 Display

The 20x4 LCD display can show two lines of 20 characters each, allowing you to visualize temperature and humidity readings clearly.

In this project, it is connected to the ESP8266 through an I2C module.

This display is used to show real-time temperature and humidity values measured by the DHT11 sensor.

4. Jumper Wires

Fils de connexion

Jumper wires are used to make electrical connections between the ESP8266 NodeMCU, DHT11 sensor, and LCD I2C display on a breadboard.

5. Breadboard

plaque d'essai

A breadboard is used to assemble the circuit without soldering.

It serves as the platform for connecting the ESP8266 NodeMCU, DHT11 sensor, and I2C LCD display.

ESP8266 Assembly with I2C LCD Display and DHT11 sensor

Attaching the I2C LCD Display :

- connect the VCC pin of the display to VIN pin of the ESP8266

- connect the GND pin of the display to GND pin of the ESP8266

- connect the SDA pin of the display to D1 (GPIO5) pin of the ESP8266

- connect the SCL pin of the display to D2 (GPIO4) pin of the ESP8266

Mounting the DHT11 Sensor:

- connect the VCC(+) pin of the DHT11 Sensor to 3V pin of the ESP8266

- connect the GND(-) pin of the DHT11 to GND pin of the ESP8266

- connect the DATA pin of the DHT11 to D0 (GPIO16) of the ESP8266

 

Program ESP8266 NodeMCU with MicroPython

Here is a complete MicroPython program to read temperature and humidity using the DHT11 sensor connected to the ESP8266 NodeMCU board:

Ensure you have the necessary libraries installed: dht, 'i2c_lcd' and 'lcd_api'.

 

How the program works ?

1- Imports modules:

machine for GPIO and I2C control

time for delay handling

dht for the DHT11 sensor library

lcd_api and i2c_lcd for controlling the LCD screen

2- Initializes the I2C LCD:

Defines SDA and SCL pins, sets the LCD address, and prepares the display.

3- Sets up the DHT11 sensor:

The sensor is connected to D0 (GPIO16) (you can change this if needed).

4- Main loop:

Reads temperature and humidity values from the DHT11.

Displays the results both on the serial monitor and LCD I2C screen.

Updates the readings every 4 seconds.

0 commentaire

laisser un commentaire

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Passion de robotique

Atelier robotique

Construction des robots

Bras robotique

Maison intelligente

But de ce site web

La robotique éducative joue un rôle important dans l'éducation des enfants et des jeunes en les aidant à acquérir des compétences en science et technologie.
Dans ce cadre notre site web représente une excellente ressource pour les parents, les enseignants et les enfants qui souhaitent découvrir la robotique.

Coordonnées

Zaouiet Kontech-Jemmel-Monastir-Tunisie

+216 92 886 231

medaliprof@gmail.com

Photos des articles

Site robotique réalisé par Mohamed Ali-Prof Info