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

ESP32-Based Automated Irrigation and Motor Control System with Blynk App Integration

View and Edit Project In Cirkit DesignerImage of ESP32-Based Automated Irrigation and Motor Control System with Blynk App Integration

Circuit Documentation

Summary

The circuit in question is designed to interface an ESP32 microcontroller with multiple sensors and actuators, including IR sensors, DC motors, and mini water pumps. The ESP32 is programmed to interact with these components based on sensor inputs and can be controlled remotely via the Blynk platform. The circuit is powered by a 5V battery, and the ground connections are shared among all components.

Component List

ESP32

IR Sensors

DC Motors

5V Mini Water Pumps

5V Battery

MG90S

Wiring Details

ESP32

IR Sensors

DC Motors

5V Mini Water Pumps

5V Battery

MG90S

Documented Code

#define BLYNK_TEMPLATE_ID "YourTemplateID"
#define BLYNK_DEVICE_NAME "YourDeviceName"
#define BLYNK_AUTH_TOKEN "YourAuthToken"

#include <WiFi.h>
#include <BlynkSimpleEsp32.h>

#define IR1_PIN 23
#define IR2_PIN 2
#define IR3_PIN 25

#define PUMP1_PIN 26
#define PUMP2_PIN 4
#define MOTOR_PIN 22

char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "YourSSID";  // WiFi name
char pass[] = "YourPassword"; // WiFi password

BlynkTimer timer;

void checkSensors() {
  int ir1State = digitalRead(IR1_PIN);
  int ir2State = digitalRead(IR2_PIN);
  int ir3State = digitalRead(IR3_PIN);

  // Motor control according to ir1
  if (ir1State == LOW) {
    digitalWrite(MOTOR_PIN, HIGH); // Turn on motor
  } else {
    digitalWrite(MOTOR_PIN, LOW); // Turn off motor
  }

  // Pump 1 control according to ir3
  if (ir3State == LOW) {
    digitalWrite(PUMP1_PIN, HIGH); // Turn on pump1
  } else {
    digitalWrite(PUMP1_PIN, LOW); // Turn off pump1
  }

  // Pump 2 control according to ir2
  if (ir2State == LOW) {
    digitalWrite(PUMP2_PIN, HIGH); // Turn on pump2
  } else {
    digitalWrite(PUMP2_PIN, LOW); // Turn off pump2
  }
}

BLYNK_WRITE(V0) {
  int state = param.asInt();
  digitalWrite(MOTOR_PIN, state);
}

BLYNK_WRITE(V1) {
  int state = param.asInt();
  digitalWrite(PUMP1_PIN, state);
}

BLYNK_WRITE(V2) {
  int state = param.asInt();
  digitalWrite(PUMP2_PIN, state);
}

void setup() {
  Serial.begin(9600);
  pinMode(IR1_PIN, INPUT);
  pinMode(IR2_PIN, INPUT);
  pinMode(IR3_PIN, INPUT);

  pinMode(PUMP1_PIN, OUTPUT);
  pinMode(PUMP2_PIN, OUTPUT);
  pinMode(MOTOR_PIN, OUTPUT);

  Blynk.begin(auth, ssid, pass);

  timer.setInterval(1000L, checkSensors); // Check sensors every second
}

void loop() {
  Blynk.run();
  timer.run();
}

This code is designed to run on the ESP32 microcontroller. It sets up the device to connect to WiFi and the Blynk platform, reads the state of three IR sensors, and controls two water pumps and a motor based on the sensor inputs. It also defines virtual pins to control the motor and pumps through the Blynk app.