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

Wi-Fi Controlled Solenoid Valve and Servo Motor System

View and Edit Project In Cirkit DesignerImage of Wi-Fi Controlled Solenoid Valve and Servo Motor System

Circuit Documentation

Summary

This circuit is designed to control a solenoid irrigation valve and a servo motor using an ESP32-S3 microcontroller. The solenoid valve is operated through a relay module, which is controlled by the ESP32-S3. The servo motor is also controlled via PWM signals from the ESP32-S3. The circuit is powered by a 12V DC power supply, and the ESP32-S3 is powered through a 5V connection.


Component List

1. ESP32-S3 (beta)

2. Solenoid Irrigation Valve

3. 1 Channel 5V Relay Module

4. Diode

5. 12V DC Power Supply

6. Servo


Wiring Details

ESP32-S3 (beta)


Solenoid Irrigation Valve


1 Channel 5V Relay Module


Diode


12V DC Power Supply


Servo


Documented Code

ESP32-S3 Code for Solenoid Control

/*
 * Arduino Sketch for controlling a solenoid valve using an ESP32-S3 and a relay.
 * The solenoid valve is opened and closed every 5 seconds. The ESP32-S3 controls
 * the relay module, which in turn controls the solenoid valve. The relay is 
 * connected to GPIO 21 of the ESP32-S3.
 */

const int relayPin = 21; // GPIO pin connected to the relay module

void setup() {
  // Initialize the relay pin as an output
  pinMode(relayPin, OUTPUT);
  // Start with the relay off
  digitalWrite(relayPin, LOW);
}

void loop() {
  // Turn the relay on (close the solenoid valve)
  digitalWrite(relayPin, HIGH);
  delay(5000); // Wait for 5 seconds

  // Turn the relay off (open the solenoid valve)
  digitalWrite(relayPin, LOW);
  delay(5000); // Wait for 5 seconds
}

ESP32-S3 Code for Servo Control

/*
 * Arduino Sketch for controlling a servo motor using an ESP32-S3.
 * The servo motor is smoothly rotated from 0 to 180 degrees every 5 seconds.
 * The ESP32-S3 controls the servo motor via PWM on GPIO 21.
 */

#include <ESP32Servo.h>

const int servoPin = 21; // GPIO pin connected to the servo PWM
Servo myServo;           // Create a Servo object

void setup() {
  // Attach the servo on the specified pin
  myServo.attach(servoPin);
}

void loop() {
  // Rotate the servo from 0 to 180 degrees
  for (int pos = 0; pos <= 180; pos++) {
    myServo.write(pos);  // Set the servo position
    delay(28);           // Delay for smooth movement
  }
  
  // Rotate the servo from 180 to 0 degrees
  for (int pos = 180; pos >= 0; pos--) {
    myServo.write(pos);  // Set the servo position
    delay(28);           // Delay for smooth movement
  }
}

This documentation provides a comprehensive overview of the circuit, detailing each component, its purpose, wiring connections, and the code used for operation.