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

ESP32-Based Solar-Powered Water Flow Monitoring System with LCD Display

View and Edit Project In Cirkit DesignerImage of ESP32-Based Solar-Powered Water Flow Monitoring System with LCD Display

Circuit Documentation

Summary

This document provides a detailed overview of a water usage monitoring system. The system includes a water flow sensor, an LCD display, an ESP32 microcontroller, a solar charge controller, a battery management system (BMS), a solar panel, and a 18650 Li-ion battery. The system measures water flow, displays the data on an LCD, and sends the data to the cloud for real-time monitoring. The system is powered by a battery charged through solar panels, regulated by a solar charging module, and protected by a BMS.

Component List

  1. BMS

    • Description: Battery Management System
    • Pins: B+, B2, B1, B-, P-, P+
  2. Solar Panel

    • Description: Solar Panel
    • Pins: +, -
  3. LCD 20x4 I2C

    • Description: 20x4 LCD Display with I2C Interface
    • Pins: GND, 5V, SCA, SCL
  4. ESP32 (30 pin)

    • Description: ESP32 Microcontroller with 30 Pins
    • 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
  5. CN3065 Solar Charge

    • Description: Solar Charge Controller
    • Pins: SOLAR +, SOLAR -, BAT +, SYS -, SYS +, BAT -
  6. 18650 Li-ion Battery

    • Description: 18650 Li-ion Battery
    • Pins: +, -
  7. Water Flow Sensor

    • Description: Water Flow Sensor
    • Pins: Signal, Vcc, GND

Wiring Details

BMS

Solar Panel

LCD 20x4 I2C

ESP32 (30 pin)

CN3065 Solar Charge

18650 Li-ion Battery

Water Flow Sensor

Documented Code

ESP32 (30 pin)

/*
 * AquaTrack: An App-Based Water Usage Monitoring System
 * This Arduino sketch is designed for the water flow sensor in the digital
 * water meter system. The system measures water flow, displays the data on
 * an LCD, and sends the data to the cloud via ESP8266 NodeMCU for real-time
 * monitoring through a mobile application.
 */

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

// Pin definitions
const int flowSensorPin = 34; // Water flow sensor signal pin
const int lcdSdaPin = 21;     // LCD SDA pin
const int lcdSclPin = 22;     // LCD SCL pin

// Variables
volatile int flowPulseCount = 0;
float flowRate = 0.0;
unsigned long oldTime = 0;

// Initialize the LCD
LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
  // Set flow sensor pin as input
  pinMode(flowSensorPin, INPUT);
  // Attach interrupt to the flow sensor pin
  attachInterrupt(digitalPinToInterrupt(flowSensorPin), pulseCounter, RISING);
  // Initialize the LCD
  lcd.begin();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("AquaTrack System");
}

void loop() {
  // Calculate flow rate every second
  if (millis() - oldTime > 1000) {
    // Disable interrupt while calculating
    detachInterrupt(digitalPinToInterrupt(flowSensorPin));
    // Calculate flow rate in L/min
    flowRate = (flowPulseCount / 7.5);
    // Print flow rate to serial monitor
    Serial.print("Flow rate: ");
    Serial.print(flowRate);
    Serial.println(" L/min");
    // Display flow rate on LCD
    lcd.setCursor(0, 1);
    lcd.print("Flow rate: ");
    lcd.print(flowRate);
    lcd.print(" L/min");
    // Reset pulse count and old time
    flowPulseCount = 0;
    oldTime = millis();
    // Re-enable interrupt
    attachInterrupt(digitalPinToInterrupt(flowSensorPin), pulseCounter, RISING);
  }
}

// Interrupt service routine for counting pulses
void pulseCounter() {
  flowPulseCount++;
}

Water Flow Sensor

/*
 * Digital Water Meter System
 * This Arduino sketch is designed for the water flow sensor in the digital
 * water meter system. The system measures water flow and sends the data to
 * the cloud via ESP8266 NodeMCU for real-time monitoring through a mobile
 * application. The system is powered by a battery charged through solar
 * panels, regulated by a solar charging module, and protected by a BMS.
 */

// Pin definitions
const int flowSensorPin = 34; // Water flow sensor signal pin

// Variables
volatile int flowPulseCount = 0;
float flowRate = 0.0;
unsigned long oldTime = 0;

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
  // Set flow sensor pin as input
  pinMode(flowSensorPin, INPUT);
  // Attach interrupt to the flow sensor pin
  attachInterrupt(digitalPinToInterrupt(flowSensorPin), pulseCounter, RISING);
}

void loop() {
  // Calculate flow rate every second
  if (millis() - oldTime > 1000) {
    // Disable interrupt while calculating
    detachInterrupt(digitalPinToInterrupt(flowSensorPin));
    // Calculate flow rate in L/min
    flowRate = (flowPulseCount / 7.5);
    // Print flow rate to serial monitor
    Serial.print("Flow rate: ");
    Serial.print(flowRate);
    Serial.println(" L/min");
    // Reset pulse count and old time
    flowPulseCount = 0;
    oldTime = millis();
    // Re-enable interrupt
    attachInterrupt(digitalPinToInterrupt(flowSensorPin), pulseCounter, RISING);
  }
}

// Interrupt service routine for counting pulses
void pulseCounter() {
  flowPulseCount++;
}

BMS

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Solar Panel

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

LCD 20x4 I2C

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}