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

ESP32-Based Wi-Fi Controlled Water Pump with LCD Interface

View and Edit Project In Cirkit DesignerImage of ESP32-Based Wi-Fi Controlled Water Pump with LCD Interface

Circuit Documentation

Summary

The circuit is designed to control a water pump using an ESP32 Devkit V1 microcontroller. The system can be operated remotely via a web server hosted on the ESP32, which allows the user to turn the water pump on and off. The status of the pump is displayed on a 16x2 LCD. The circuit includes a 12V single-channel relay to control the high-power circuit of the water pump, and it is powered by a 5V battery. Additionally, the ESP32 is powered by a separate 3.3V battery.

Component List

Water Pump

16X2 LCD

12V Single Channel Relay

3.3V Battery

ESP32 Devkit V1

5V Battery

Wiring Details

Water Pump

16X2 LCD

12V Single Channel Relay

3.3V Battery

ESP32 Devkit V1

5V Battery

Documented Code

#include <WiFi.h>
#include <WebServer.h>
#include <LiquidCrystal.h>

// Define constants
const char* ssid = "your_wifi_ssid";
const char* password = "your_wifi_password";

// Define pins
const int relayPin = 25;
const int lcdRS = 26;
const int lcdEN = 27;
const int lcdD4 = 14;
const int lcdD5 = 12;
const int lcdD6 = 13;
const int lcdD7 = 15;

// Initialize LCD
LiquidCrystal lcd(lcdRS, lcdEN, lcdD4, lcdD5, lcdD6, lcdD7);

// Create a web server on port 80
WebServer server(80);

bool pumpStatus = false;

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

  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }

  // Initialize relay pin as output
  pinMode(relayPin, OUTPUT);

  // Initialize LCD
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.print("Water Pump Control");

  // Define web server routes
  server.on("/", []() {
    server.send(200, "text/html", "<a href=\"/on\">Turn On</a> <a href=\"/off\">Turn Off</a>");
  });

  server.on("/on", []() {
    pumpStatus = true;
    digitalWrite(relayPin, HIGH);
    lcd.setCursor(0, 1);
    lcd.print("Pump ON");
    server.send(200, "text/html", "Pump turned ON");
  });

  server.on("/off", []() {
    pumpStatus = false;
    digitalWrite(relayPin, LOW);
    lcd.setCursor(0, 1);
    lcd.print("Pump OFF");
    server.send(200, "text/html", "Pump turned OFF");
  });

  // Start the web server
  server.begin();
}

void loop() {
  // Handle web server requests
  server.handleClient();

  // Keep the motor on if pumpStatus is true
  if (pumpStatus) {
    digitalWrite(relayPin, HIGH);
  } else {
    digitalWrite(relayPin, LOW);
  }
}

This code is designed to run on the ESP32 Devkit V1 microcontroller. It sets up a Wi-Fi connection and a web server that allows remote control of the water pump. The LCD displays the current status of the pump, and the relay is used to switch the pump on and off based on web server requests.