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

ESP32-Based Rain-Responsive Motor Control System with Voltage Monitoring

View and Edit Project In Cirkit DesignerImage of ESP32-Based Rain-Responsive Motor Control System with Voltage Monitoring

Circuit Documentation

Summary

This circuit is designed to monitor environmental conditions such as voltage levels, rain presence, and object detection using an IR sensor. It includes a power management system that steps down voltage from a 12V battery to 5V, a set of sensors for voltage and rain detection, an ESP32 microcontroller for processing sensor data, and a relay module to control a DC motor based on sensor inputs. The system is also capable of being powered by a solar panel through a solar charge controller.

Component List

Power Components

Sensors

Actuators

Microcontroller

Passive Components

Wiring Details

Power Components

Sensors

Actuators

Microcontroller

Passive Components

Documented Code

#include <Arduino.h>

// Pin Definitions
const int voltageSensorPin = 34;    // Voltage sensor analog input
const int rainSensorPin = 35;       // Rain sensor analog input
const int irSensorPin = 32;         // IR sensor digital input
const int relay1Pin = 26;           // Relay channel 1 for DC motor
const int relay2Pin = 27;           // Relay channel 2 (for future use)
const int relay3Pin = 14;           // Relay channel 3 (for future use)
const int relay4Pin = 12;           // Relay channel 4 (for future use)

// Voltage sensor calibration constants
const float voltageReference = 3.3; // Reference voltage of ESP32 ADC
const int resolution = 4095;        // ADC resolution
const float voltageDividerRatio = 5.7; // Ratio of the voltage divider used in the sensor

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

  // Set pin modes
  pinMode(voltageSensorPin, INPUT);
  pinMode(rainSensorPin, INPUT);
  pinMode(irSensorPin, INPUT);
  pinMode(relay1Pin, OUTPUT);
  pinMode(relay2Pin, OUTPUT);
  pinMode(relay3Pin, OUTPUT);
  pinMode(relay4Pin, OUTPUT);

  // Initialize relays to be off
  digitalWrite(relay1Pin, LOW);
  digitalWrite(relay2Pin, LOW);
  digitalWrite(relay3Pin, LOW);
  digitalWrite(relay4Pin, LOW);
}

void loop() {
  // Voltage sensing
  int voltageSensorValue = analogRead(voltageSensorPin);
  float batteryVoltage = (