Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

ESP32-C6 Feather Controlled Smart Relay for AC Bulb Automation

Image 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

  • Description: A microcontroller board with WiFi and Bluetooth capabilities, and in this case, Zigbee protocol for wireless communication.
  • Pins: IO9/BOOT/NEOPIX, TX, RX, MISO, MOSI, SCK, A5, A4, A3/IO5, A2/IO6, A1, A0, GND, 3.3V, RESET, VBAT, EN, VBUS, IO15, IO14, IO0, IO8, IO7, SCL, SDA, VSENSOR.

KY-019 Relay module 1 channel

  • Description: A 5V single-channel relay module capable of controlling high power devices like an AC bulb.
  • Pins: S, 5V, GND, NC, COM, NO.

AC Bulb

  • Description: A standard AC-powered light bulb.
  • Pins: P (Phase), N (Neutral).

AC Supply

  • Description: A source of alternating current to power the AC Bulb.
  • Pins: +ve (Live), -ve (Neutral).

DC Power Source

  • Description: A source of direct current to power the microcontroller and relay module.
  • Pins: Ground, Positive.

Wiring Details

ESP32-C6 Feather

  • GND: Connected to the ground of the DC Power Source and GND of the KY-019 Relay module.
  • VBAT: Connected to the Positive of the DC Power Source and 5V of the KY-019 Relay module.
  • IO15: Connected to the S pin of the KY-019 Relay module to control the relay.

KY-019 Relay module 1 channel

  • GND: Connected to the ground of the DC Power Source and GND of the ESP32-C6 Feather.
  • 5V: Connected to the Positive of the DC Power Source and VBAT of the ESP32-C6 Feather.
  • S: Connected to IO15 of the ESP32-C6 Feather to receive control signals.
  • NC: Normally closed contact connected to the P pin of the AC Bulb.
  • COM: Common contact connected to the -ve pin of the AC Supply.

AC Bulb

  • P: Connected to the NC pin of the KY-019 Relay module.
  • N: Connected to the +ve pin of the AC Supply.

AC Supply

  • +ve: Connected to the N pin of the AC Bulb.
  • -ve: Connected to the COM pin of the KY-019 Relay module.

DC Power Source

  • Ground: Connected to the GND of the ESP32-C6 Feather and GND of the KY-019 Relay module.
  • Positive: Connected to the VBAT of the ESP32-C6 Feather and 5V of the KY-019 Relay module.

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.