A relay lets the SuperMini switch a separate circuit — a 12 V pump through a contactor, a fan, a small lamp. This guide covers the low-voltage side: coil power from 5V, the trigger on GPIO7, and a relay that stays off while the C3 boots.
Type 1 or 0 in the Serial Monitor to switch it. What you connect to COM/NO is the part that can hurt: keep to low-voltage loads, use a contactor for motors, and leave mains wiring to an electrician.
Wiring
| ESP32-C3 SuperMini | 1-channel relay module (5 V coil) | Wire | Notes |
|---|---|---|---|
| 5V | DC+ | red | Coil supply from USB 5 V (~70 mA per relay). Not from 3V3. |
| GND | DC− | black | |
| 7 | IN | yellow | Use a module sold as “3.3 V trigger” (opto-isolated, active-LOW). |
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
- GPIO7 is quiet during boot. Avoid GPIO2/8/9 (strapping pins), and GPIO21, which carries the ROM’s boot messages and makes a relay chatter at reset.
- The sketch writes the pin HIGH (relay off) before making it an output, so the relay never clicks on while the board starts.
- Feed the coil from 5V, not 3V3: the SuperMini’s 3.3 V regulator is small and a relay coil plus Wi-Fi bursts can brown it out.
- Many 5 V modules need more than 3.3 V on IN to switch fully off. Buy one marked “3.3 V trigger”, or one with a JD-VCC jumper.
- COM/NO/NC are the switched side. Use the relay for low-voltage loads or a small lamp within its rating; pumps and motors go through a contactor, and any 230 V wiring (with MCB, RCCB and earth) is for an electrician.
Code
// 1-channel relay module (3.3 V-trigger, active-LOW) on an ESP32-C3 SuperMini.
// DC+ → 5V (USB 5 V), DC− → GND, IN → GPIO7.
// GPIO7 is not a strapping pin (2/8/9) and is quiet during boot, unlike GPIO21 (UART0 TX),
// so the relay doesn't chatter at power-up.
// Type 1 / 0 in the Serial Monitor. 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 = 7;
constexpr bool RELAY_ACTIVE_LOW = true;
void setRelay(bool on) {
digitalWrite(RELAY_PIN, (on != RELAY_ACTIVE_LOW) ? HIGH : LOW);
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);
delay(1500); // let the native USB serial port enumerate
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);
}
}// 1-channel relay module (3.3 V-trigger, active-LOW) on an ESP32-C3 SuperMini.
// DC+ → 5V (USB 5 V), DC− → GND, IN → GPIO7.
// GPIO7 is not a strapping pin (2/8/9) and is quiet during boot, unlike GPIO21 (UART0 TX),
// so the relay doesn't chatter at power-up.
// Type 1 / 0 in the Serial Monitor. 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 = 7;
constexpr bool RELAY_ACTIVE_LOW = true;
void setRelay(bool on) {
digitalWrite(RELAY_PIN, (on != RELAY_ACTIVE_LOW) ? HIGH : LOW);
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);
delay(1500); // let the native USB serial port enumerate
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
Send 1 = on, 0 = off
Relay ON
Relay OFFSend 1 = on, 0 = off Relay ON Relay OFF
Common errors
Relay clicks but the load doesn’t switch
The load is on NC instead of NO, or not through COM at all. Full fix.
Relay never turns off
The module needs a 5 V trigger. Use a 3.3 V-trigger module.
Board resets when the relay clicks
Coil current on a weak USB port. Use a better cable/adapter, or power the module separately with a common GND. Brownout fix.