Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

Relay module with ESP32-C6-DevKitC-1 — wiring and code

Switch a 3.3 V-trigger relay from GPIO11 of an ESP32-C6-DevKitC-1, off during boot, with the RGB LED as a status light and clear load limits.

Arduino C++Verified — core esp32 3.3.12, 3 Nov 2026Compile-only

Community draft — report a mistake

The ESP32-C6 is a good base for a smart switch — it speaks Wi-Fi 6, and Zigbee/Thread for Matter. This guide wires the relay part: coil on 5V, trigger on GPIO11.

Type 1 or 0 in the Serial Monitor on the UART port. Keep the switched load within the relay’s rating and leave any mains wiring to an electrician.

Wiring

ESP32-C6-DevKitC-1Only the pins used are shown · 3.3 V logic1-channel relay module (5 V coil)11 · 115VGNDDC+DC−INCOM (not connected)NO (not connected)NC (not connected)
Every connection
ESP32-C6-DevKitC-11-channel relay module (5 V coil)WireNotes
5VDC+redCoil supply from USB 5 V.
GNDDC−black
11INyellow3.3 V-trigger, opto-isolated, active-LOW module.

5 V coil part, 3.3 V board. The coil runs on 5 V, but the IN pin only drives an optocoupler LED. Pick a module rated for a 3.3 V trigger when using ESP32 or Pico — some 5 V-only modules never fully release from a 3.3 V HIGH.

Board quirks

  • GPIO11 is boot-safe. Avoid the C6’s strapping pins (4, 5, 8, 9, 15), the UART pins TX/RX (GPIO16/17, boot messages) and GPIO12/13 (USB).
  • The relay pin is set HIGH (off) before it becomes an output, so the relay doesn’t pulse at power-up.
  • The on-board RGB LED turns red while the relay is on — handy when the relay is inside a box.
  • COM/NO/NC switch the load. Keep to low-voltage loads or a small lamp within the relay’s rating; motors and pumps go through a contactor, and 230 V wiring with MCB, RCCB and earth is for an electrician.

Code

relay-esp32c6.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// 1-channel relay module (3.3 V-trigger, active-LOW) on an ESP32-C6-DevKitC-1.
// DC+ → 5V, DC− → GND, IN → GPIO11. Type 1 / 0 in the Serial Monitor (UART port, 115200).
// Low-voltage or small resistive loads only; motors and pumps go through a contactor,
// and any 230 V wiring is for an electrician.
constexpr uint8_t RELAY_PIN = 11;
constexpr bool RELAY_ACTIVE_LOW = true;

void setRelay(bool on) {
  digitalWrite(RELAY_PIN, (on != RELAY_ACTIVE_LOW) ? HIGH : LOW);
  rgbLedWrite(RGB_BUILTIN, on ? 25 : 0, 0, 0);  // on-board LED red while the relay is on
  Serial.println(on ? "Relay ON" : "Relay OFF");
}

void setup() {
  digitalWrite(RELAY_PIN, RELAY_ACTIVE_LOW ? HIGH : LOW);  // off before the pin becomes an output
  pinMode(RELAY_PIN, OUTPUT);
  Serial.begin(115200);
  Serial.println("Send 1 = on, 0 = off");
}

void loop() {
  if (Serial.available()) {
    char c = Serial.read();
    if (c == '1') setRelay(true);
    if (c == '0') setRelay(false);
  }
}

Expected serial output

Serial Monitor · 115200Output
Send 1 = on, 0 = off
Relay ON
Relay OFF

Common errors

Relay clicks, load stays off

Load on NC. Full fix.

Relay never releases

The module needs a 5 V trigger. Use a 3.3 V-trigger module.

↑↓ to move · Enter to open