π§ Xiao ESP32C6 LED Controller - Hardware Guide
Complete wiring and connection instructions for the LED control system
π Xiao ESP32C6 Overview
The Xiao ESP32C6 is a compact WiFi-enabled microcontroller with improved capabilities:
| Specification |
Details |
| Processor |
ESP32-C6 (Dual Core, 160MHz) |
| RAM |
400KB |
| Flash |
4MB |
| WiFi |
802.11 b/g/n (2.4GHz) |
| USB |
USB-C |
| GPIO Pins |
11 total (we use 4 for LEDs) |
| Power Supply |
5V USB or 3.3V external |
π Pinout Diagram
βββββββββββββββββββββββββββββββββββββββ
β Xiao ESP32C3 Pinout β
β β
β USB-C Port (Top) β
β ββββββββββββββββ β
β β
β 5V GND GPIO0 GPIO1 β Left Side
β β β β β β
β β
β GPIO4 GPIO5 GPIO6 GPIO7 β Right Side
β β β β β β
β β
β GND 3.3V GPIO2 GPIO3 β Bottom
β β β β β β
β β
βββββββββββββββββββββββββββββββββββββββ
Note: Exact pinout may vary. Verify with official Seeed documentation for your specific board revision.
π‘ LED Pin Configuration
In this project, 4 LEDs are controlled using the following GPIO pins:
GPIO 0
LED 1 (Red)
Pin 6 on physical board
GPIO 1
LED 2 (Cyan)
Pin 7 on physical board
GPIO 2
LED 3 (Blue)
Pin 11 on physical board
GPIO 3
LED 4 (Orange)
Pin 12 on physical board
β οΈ Important: If these GPIO pins are already in use or conflict with your setup, modify the LED_PINS array in the Arduino code:
const int LED_PINS[4] = {0, 1, 2, 3}; // Change these numbers
π LED Wiring Guide
Components Needed (per LED)
- 1x LED (any color)
- 1x 220Ξ© resistor (ΒΌW)
- Connecting wires
- Breadboard (optional but recommended)
Wiring for Each LED
GPIO Pin (from ESP32C3)
β
ββββ [220Ξ© Resistor]
β
ββββ (+) LED Anode (Long Leg)
β
ββββ (-) LED Cathode (Short Leg)
β
ββββ GND (Ground from ESP32C3)
Full Connection Schematic
Xiao ESP32C3 Breadboard
ββββββββββββββββ
β β
β GPIO 0 βββββΌβββββ[220Ξ©]βββββββ(+)LED1(-)ββ
β GPIO 1 βββββΌβββββ[220Ξ©]βββββββ(+)LED2(-)ββ€
β GPIO 2 βββββΌβββββ[220Ξ©]βββββββ(+)LED3(-)ββ€
β GPIO 3 βββββΌβββββ[220Ξ©]βββββββ(+)LED4(-)ββ€
β β β β
β GND ββββββββΌββββββββββββββββββββββββββββββ
β β
ββββββββββββββββ
π‘ Tip: Use a breadboard to organize connections neatly. This makes troubleshooting easier and prevents accidental short circuits.
π£ Step-by-Step Connection Instructions
Step 1: Prepare the LEDs
β Identify the long leg (anode/+) and short leg (cathode/-) of each LED
β Bend the legs if needed for easier breadboard insertion
Step 2: Connect Power and Ground Rails
β Connect Xiao's GND pin to the ground rail on the breadboard
β This creates a common ground for all LEDs
Step 3: Install Resistors
β Insert a 220Ξ© resistor into the breadboard for each LED
β One end connects to the GPIO pin, other end to LED anode
Step 4: Connect LEDs
β Connect LED anode (+) to the resistor output
β Connect LED cathode (-) to the ground rail
Step 5: Verify Connections
β Double-check each LED cathode is connected to ground
β Verify resistors are in series between GPIO and LED
β No loose wires should touch each other
Step 6: Power Up
β Connect Xiao ESP32C3 to computer via USB-C
β LEDs should not light up initially (GPIO pins are LOW)
π¬ Resistor Selection
The 220Ξ© resistor limits current to safe levels for the GPIO pins and LEDs.
| LED Color |
Typical Forward Voltage |
Recommended Resistor |
| Red |
2.0V |
220Ξ© - 470Ξ© |
| Green |
2.2V |
220Ξ© - 470Ξ© |
| Blue/Cyan |
3.2V |
150Ξ© - 220Ξ© |
| Yellow |
2.1V |
220Ξ© - 470Ξ© |
Calculation for Red LED:
- ESP32 GPIO Output: 3.3V
- LED Forward Voltage: 2.0V
- Voltage Drop Across Resistor: 3.3V - 2.0V = 1.3V
- Desired LED Current: ~20mA
- Resistor Value: R = V/I = 1.3V / 0.02A = 65Ξ©
Practical values (use nearest standard resistor):
- 220Ξ© for safety (brighter = less resistor, dimmer = more resistor)
- 470Ξ© for dimmer LEDs
- 150Ξ© for maximum brightness (not recommended for safety)
β‘ Power Consumption
| Component |
Current Draw |
| Xiao ESP32C3 (Idle) |
~20mA |
| Xiao ESP32C3 (WiFi Active) |
~100-200mA |
| Single LED (with 220Ξ© resistor) |
~15mA |
| All 4 LEDs ON |
~60mA |
| Total (WiFi + 4 LEDs) |
~260mA Maximum |
π‘ Note: A standard USB port provides 500mA at 5V. Your setup will work fine with USB power. For battery operation, use at least 1000mAh capacity.
π§ Troubleshooting
β LED doesn't light up
- Verify LED polarity (long leg to resistor, short leg to ground)
- Check resistor is properly installed
- Test LED with battery to confirm it's not burned out
- Verify GPIO pin number matches the code
- Use Serial Monitor to check if GPIO pin is set HIGH
β LED always on (won't turn off)
- GPIO pin may be pulled up to 3.3V by default
- Check code logic - is digitalWrite correct?
- Try inverting the logic (HIGH to LOW)
β LED is dim
- Try smaller resistor (220Ξ© instead of 470Ξ©)
- Check WiFi interference (try near router)
- Verify power supply voltage (should be 5V or 3.3V)
β Multiple LEDs interfere with each other
- Ensure all LEDs share the same GND connection
- Use separate ground path for each resistor (not daisy-chained)
- Add decoupling capacitor (0.1Β΅F) between 3.3V and GND near the chip
β οΈ Safety Precautions
DO NOT:
- Connect GPIO pins directly to 5V without a resistor
- Reverse LED polarity (can damage the LED and GPIO pin)
- Use resistors smaller than 150Ξ© (excessive current can damage GPIO)
- Allow bare wires to touch each other (short circuit)
- Connect high-current devices (motors, relays) directly to GPIO
DO:
- Always use appropriate resistors in series with LEDs
- Connect a common ground between ESP32 and all circuits
- Use a breadboard to organize connections neatly
- Test connections before powering on
- Keep WiFi antenna away from high-current wiring
π§ͺ Testing Your Setup
Test 1: Hardware Test with Arduino IDE
Upload this simple test sketch to verify GPIO pins work:
void setup() {
Serial.begin(115200);
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
}
void loop() {
digitalWrite(0, HIGH);
delay(500);
digitalWrite(0, LOW);
delay(500);
// Repeat for pins 1, 2, 3
}
Test 2: Check WiFi Connection
Ensure ESP32 connects to your WiFi network and verify the IP address via Serial Monitor
Test 3: Test API Endpoints
Use curl or web browser to test endpoints:
# Check device is reachable
ping 192.168.1.100
# Test API
curl http://192.168.1.100/status
curl http://192.168.1.100/led1/on
curl http://192.168.1.100/info
Test 4: Full System Test
Open page 1.html in browser and test all LED buttons
π Advanced Modifications
Add More LEDs
The Xiao ESP32C3 has enough GPIO pins for up to 8 LEDs. Modify the code:
// In esp32_led_controller.ino
const int LED_PINS[8] = {0, 1, 2, 3, 5, 6, 7, 21}; // Up to 8 LEDs
Use PWM for Brightness Control
Replace digitalWrite with analogWrite for brightness control:
// Brightness 0-255
analogWrite(LED_PINS[0], 128); // 50% brightness
Add Button Control
Connect a physical button to GPIO pin 4 for manual LED control
Temperature Monitoring
Add temperature sensor (DHT11/BME280) to monitor environment
Version: 1.0 | Device: Xiao ESP32C6 | Last Updated: 2026-05-04