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

Battery-Powered ESP32-C3 LED Driver with Deep Sleep Mode

View and Edit Project In Cirkit DesignerImage of Battery-Powered ESP32-C3 LED Driver with Deep Sleep Mode

Circuit Documentation

Summary

This circuit consists of an ESP32-C3 microcontroller, a resistor, and a yellow LED. The microcontroller is programmed to control the LED, turning it on and off at specified intervals while conserving power by entering deep sleep mode when not in use.

Component List

Resistor

LED: Two Pin (yellow)

XIAO ESP32C3

Wiring Details

Resistor

LED: Two Pin (yellow)

XIAO ESP32C3

Code Documentation

/*
 * This Arduino Sketch is for an ESP32-C3 microcontroller that drives one or
 * more LED lights. The microcontroller is powered by a 18650 Li-Ion battery,
 * which is charged by a solar panel through a CN3065 Solar Charge controller.
 * The microcontroller will use deep sleep mode during the day and when not in
 * use to conserve power.
 */

#define LED_PIN GPIO2 // Define the GPIO pin connected to the LED

void setup() {
  pinMode(LED_PIN, OUTPUT); // Set the LED pin as an output
  digitalWrite(LED_PIN, LOW); // Ensure the LED is off initially
  esp_sleep_enable_timer_wakeup(10 * 60 * 1000000); // Wake up every 10 minutes
  esp_deep_sleep_start(); // Enter deep sleep mode
}

void loop() {
  // This code will run after waking up from deep sleep
  digitalWrite(LED_PIN, HIGH); // Turn on the LED
  delay(1000); // Keep the LED on for 1 second
  digitalWrite(LED_PIN, LOW); // Turn off the LED
  esp_deep_sleep_start(); // Enter deep sleep mode again
}

This code sets up the ESP32-C3 microcontroller to control the LED. The LED is connected to GPIO2, which is defined as LED_PIN. The setup function initializes the LED pin as an output and ensures the LED is off initially. The microcontroller is set to wake up every 10 minutes and enter deep sleep mode to conserve power. The loop function runs after the microcontroller wakes up from deep sleep, turning the LED on for 1 second before turning it off and re-entering deep sleep mode.