Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based Water Level Monitoring System with I2C LCD and Buzzer

View and Edit Project In Cirkit DesignerImage of ESP32-Based Water Level Monitoring System with I2C LCD and Buzzer

Water Level Monitoring System Documentation

Summary

This document provides a detailed overview of a water level monitoring system. The system uses an ESP32 microcontroller to read data from a water level sensor, display the water level on a 16x2 I2C LCD, and activate a buzzer when the water level is low.

Component List

  1. ESP32 (30 pin)

    • Description: A powerful microcontroller with built-in Wi-Fi and Bluetooth capabilities.
    • Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3
  2. Buzzer

    • Description: An audio signaling device that emits sound when activated.
    • Pins: GND, IN
  3. 16x2 I2C LCD

    • Description: A 16x2 character LCD display with I2C interface.
    • Pins: GND, VCC, SDA, SCL
  4. Water Level Sensor

    • Description: A sensor that measures the water level and outputs an analog signal.
    • Pins: SIG, VCC, GND

Wiring Details

ESP32 (30 pin)

Buzzer

16x2 I2C LCD

Water Level Sensor

Code Documentation

ESP32 Microcontroller Code

/*
 * This Arduino sketch is designed to control a water level monitoring system.
 * The system uses an ESP32 microcontroller to read data from a water level
 * sensor, display the water level on a 16x2 I2C LCD, and activate a buzzer
 * when the water level is low.
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Pin definitions
#define WATER_LEVEL_PIN 32
#define BUZZER_PIN 25
#define LCD_ADDRESS 0x27
#define LCD_COLUMNS 16
#define LCD_ROWS 2

// Create LCD object
LiquidCrystal_I2C lcd(LCD_ADDRESS, LCD_COLUMNS, LCD_ROWS);

void setup() {
  // Initialize serial communication
  Serial.begin(115200);

  // Initialize LCD
  lcd.begin(LCD_COLUMNS, LCD_ROWS);
  lcd.backlight();

  // Initialize pins
  pinMode(WATER_LEVEL_PIN, INPUT);
  pinMode(BUZZER_PIN, OUTPUT);

  // Display initial message
  lcd.setCursor(0, 0);
  lcd.print("Water Level:");
}

void loop() {
  // Read water level sensor
  int waterLevel = analogRead(WATER_LEVEL_PIN);

  // Display water level on LCD
  lcd.setCursor(0, 1);
  lcd.print(waterLevel);
  lcd.print(" "); // Clear any extra characters

  // Check if water level is low
  if (waterLevel < 500) { // Adjust threshold as needed
    digitalWrite(BUZZER_PIN, HIGH); // Activate buzzer
  } else {
    digitalWrite(BUZZER_PIN, LOW); // Deactivate buzzer
  }

  // Delay for a short period
  delay(1000);
}

This code initializes the ESP32 microcontroller, sets up the pins, and continuously reads the water level from the sensor. The water level is displayed on the 16x2 I2C LCD, and the buzzer is activated if the water level falls below a specified threshold.