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

ESP32-C6 Feather Controlled Smart Relay for AC Bulb Automation

View and Edit Project In Cirkit DesignerImage of ESP32-C6 Feather Controlled Smart Relay for AC Bulb Automation

Circuit Documentation

Summary of the Circuit

This circuit is designed to control an AC bulb using an ESP32-C6 Feather microcontroller in conjunction with a KY-019 Relay module. The ESP32-C6 Feather is programmed to communicate via Zigbee protocol, allowing wireless control of the relay, which in turn switches the AC bulb on or off. The DC Power Source provides the necessary 5V to power both the ESP32-C6 Feather and the relay module. The AC Supply is connected to the relay to switch the AC Bulb.

Component List

ESP32-C6 Feather

KY-019 Relay module 1 channel

AC Bulb

AC Supply

DC Power Source

Wiring Details

ESP32-C6 Feather

KY-019 Relay module 1 channel

AC Bulb

AC Supply

DC Power Source

Documented Code

/*
 * This Arduino Sketch is for an ESP32-C6 Feather microcontroller that uses
 * its inbuilt Zigbee protocol to control a 5V relay module. The relay is
 * connected to an AC bulb, allowing the ESP32 to turn the bulb on and off.
 */

// Define the pin connected to the relay module
#define RELAY_PIN 15

void setup() {
  // Initialize the relay pin as an output
  pinMode(RELAY_PIN, OUTPUT);
  // Ensure the relay is off at startup
  digitalWrite(RELAY_PIN, LOW);
  // Initialize Zigbee communication (placeholder, actual implementation needed)
  // zigbeeInit();
}

void loop() {
  // Placeholder for Zigbee message handling
  // if (zigbeeMessageReceived()) {
  //   String command = getZigbeeCommand();
  //   if (command == "ON") {
  //     digitalWrite(RELAY_PIN, HIGH); // Turn relay on
  //   } else if (command == "OFF") {
  //     digitalWrite(RELAY_PIN, LOW); // Turn relay off
  //   }
  // }
  delay(100); // Small delay to prevent overwhelming the loop
}

Filename: sketch.ino

This code initializes the ESP32-C6 Feather microcontroller and sets up the relay pin. The main loop contains a placeholder for Zigbee communication, which would handle incoming messages to control the state of the relay and, consequently, the AC bulb.