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.
/*
* 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.