Water level detection using ESP8266 NodeMCU and HC-SR04

ESP8266 24-05-26
13 0

Tutorial plan

1- Objective of the project

2- Required Components

3- Circuit Connections of system

4- MicroPython code for ESP8266 NodeMCU

 

 

Objective of the project

The objective of the water level detection system using ESP8266 NodeMCU, HC-SR04 ultrasonic sensor, and LCD display is to measure and monitor the level of water inside a glass (or container) in real time.

This system is designed to:

- detect the distance between the sensor and the water surface.

- calculate the water level based on this distance.

- display the water level on an LCD screen for easy reading.

- provide a simple and low-cost smart monitoring solution for liquid level measurement.

Functioning of the Project

1- Ultrasonic Measurement (HC-SR04)

The HC-SR04 sensor is placed above the glass. It sends ultrasonic waves toward the water surface and measures the time taken for the echo to return. This time is used to calculate the distance between the sensor and the water surface.

2- Processing (ESP8266 NodeMCU)

The ESP8266 receives the distance data from the sensor. It processes this information and converts it into a water level value based on the height of the glass.

3- Display (LCD Screen)

The calculated water level is shown on the LCD display. It can be displayed as:Water level percentage and graphical bars

4- Working Principle in Real Life

When water is poured into the glass, the distance between the sensor and the water surface decreases. The ESP8266 detects this change and updates the LCD display in real time. When water is removed, the level decreases accordingly.

 

Required Components

1. ESP826 NodeMCU

The ESP8266 NodeMCU is the main controller of the system. It is a low-cost Wi-Fi microcontroller used to:

- read data from the HC-SR04 sensor

- process the distance values

- calculate the water level

- send results to the LCD display

It acts as the “brain” of the project.

2. HC-SR04 sensor

HC-SR04

The HC-SR04 sensor is used to measure the distance between the sensor and the water surface. It works by transmitting ultrasonic waves and receiving the reflected waves from the water.

3. LCD Display with I2C Module

The LCD I2C display is used to show the water level information in real time. It can display percentage values and graphical bars representing the water level.

4. Jumper Wires

Jumper wires

Jumper wires are used to establish electrical connections between the ESP8266 NodeMCU, the sensor, and the LCD display.

5. Breadboard

The breadboard is used to connect the electronic components without soldering. It simplifies circuit assembly and testing.

 

Circuit Connections of system

 

1- Connection of HC-SR04 sensor to ESP8266 NodeMCU

HC-SR04 sensor ESP8266 NodeMCU
VCC 5V
GND GND
Trig D5
Echo D6

 

2- Connection of LCD I2C display to ESP8266 NodeMCU

LCD I2C display ESP8266 NodeMCU
VCC 5V
GND GND
SDA D2
SCL D1

 

MicroPython code for ESP8266 NodeMCU

This MicroPython program is designed to implement a smart water level monitoring system using an Espressif Systems, an HC-SR04, and an LCD I2C display.

You need to install this two libraries : i2c_lcd et lcd_api for I2C LCD screen.

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

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

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

Pictures of the articles

Robotic site created by Mohamed Ali Haj Salah - Teacher info