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

ESP32 Wi-Fi Controlled Relay Switch

View and Edit Project In Cirkit DesignerImage of ESP32 Wi-Fi Controlled Relay Switch

Circuit Documentation

Summary

This circuit consists of an ESP32 microcontroller and a 1 Channel Relay module. The ESP32 is used to control the relay, which can be used to switch higher power devices on and off. The relay is connected to the ESP32 through specific pins, and the ESP32 is programmed to toggle the relay state every 5 seconds.

Component List

ESP32 - 38 pins Expansion Board

1 Channel Relay 5V

Wiring Details

ESP32 - 38 pins Expansion Board

1 Channel Relay 5V

Code Documentation

ESP32 - 38 pins Expansion Board

#include <Arduino.h>

// Relay Pin
#define RELAY_PIN 23 // Pin untuk mengontrol relay

void setup() {
    Serial.begin(115200);

    // Konfigurasi pin relay sebagai output
    pinMode(RELAY_PIN, OUTPUT);
    digitalWrite(RELAY_PIN, LOW); // Relay mati secara default
}

void loop() {
    // Nyalakan relay
    digitalWrite(RELAY_PIN, HIGH);
    Serial.println("Relay ON");
    
    // Tunggu selama 5 detik
    delay(5000);

    // Matikan relay
    digitalWrite(RELAY_PIN, LOW);
    Serial.println("Relay OFF");

    // Tunggu selama 5 detik
    delay(5000);
}

1 Channel Relay 5V

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

}

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

}

This documentation provides a comprehensive overview of the circuit, including a summary, detailed component list, wiring details, and the code used to control the relay via the ESP32 microcontroller.