ESP32 C3 Super Mini - Rocker Switch Module
Many power strips have a rocker switch that glows while the strip is on, so you can see its state from across the room. The DIYables ON/OFF Rocker Switch Module uses the same black KCD1 rocker, but without a lamp inside. In this tutorial the ESP32 C3 Super Mini adds the missing light: first it reads the switch and prints ON or OFF, then its small blue on-board LED becomes the pilot light that follows the rocker.
In this tutorial, you'll learn:
- What the "I" and "O" marks on the rocker mean, and what the SIG, VCC and GND pins do
- Why the module's VCC pin must go to 3.3V on the ESP32 C3 Super Mini
- How to connect the module to GPIO7 with three jumper wires
- How to print the switch position as ON or OFF, together with the raw pin level
- How to filter contact bounce with a 50 ms millis() timer instead of delay()
- How to turn the blue on-board LED (GPIO8) into a pilot light for the switch

Hardware Preparation
| 1 | × | ESP32 C3 Super Mini | |
| 1 | × | USB Cable Type-A to Type-C (for USB-A PC) | |
| 1 | × | USB Cable Type-C to Type-C (for USB-C PC) | |
| 1 | × | ON/OFF Rocker Switch Module | |
| 1 | × | Breadboard | |
| 1 | × | Jumper Wires |
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of the Rocker Switch Module
The module is a black KCD1 rocker switch soldered on a small blue board, about 24 x 24 mm, with a mounting hole in each corner and a 3-pin right-angle header on one side. Press the side of the rocker marked "I" and the switch is ON. Press the side marked "O" and it is OFF. The text printed on the board says the same thing in logic words: "ON (H)" and "OFF (L)".
The rocker does not spring back like a push button. It is a maintained (latching) switch: it stays on the side you pressed until you press the other side. So the code does not wait for a click. It asks which position the switch is in right now, and it reacts when that position changes.
There is a 10 kΩ pull-down resistor on the board (marked "103"). While the switch is OFF, the resistor holds SIG at 0V. When the switch is ON, the switch itself connects SIG to VCC. That is why the ESP32 C3 Super Mini reads HIGH for ON and LOW for OFF, and the pin never floats.
Key Features:
- SPST rocker switch that keeps its position by itself
- Two clear marks on the rocker: "I" = ON, "O" = OFF
- Works from 3.3V to 5V - use 3.3V with the ESP32 C3 Super Mini
- Pull-down resistor on the board, so INPUT is enough - no external resistor, no INPUT_PULLUP
- Not inverted: ON gives HIGH, OFF gives LOW
- Four mounting holes, so you can fix it behind a cut-out in a box lid
- Sold in a pack of 5
Why the Rocker Switch Module is Great for Beginners:
- You see the switch state with your eyes, even when the board is off
- Three labeled pins and three jumper wires - nothing to solder
- No resistor to choose and no upside-down logic to remember
- One sketch shape fits many uses: start/stop, enable/disable, mode A/mode B
| Item | Value |
|---|---|
| Switch type | KCD1 rocker, SPST, maintained (latching) |
| Positions | I = ON (SIG is HIGH), O = OFF (SIG is LOW) |
| Supply voltage (VCC) | 3.3V to 5V |
| Pull-down resistor | 10 kΩ, on the board |
| Header | 3 pins, 2.54 mm, right-angle |
| Size with the pins | about 24 x 29 x 22 mm |
Rocker Switch Module Pinout
Hold the module with the rocker facing you and the header on the right. From top to bottom, the pins are SIG, VCC and GND. The pin names are printed on the back of the board, so from that side you read GND, VCC, SIG. GND is the pin with the square pad.
- SIG pin: the output of the switch. It is HIGH (3.3V in this project) while the switch is ON and LOW (0V) while it is OFF. Connect it to GPIO7.
- VCC pin: the supply, 3.3V to 5V. On the ESP32 C3 Super Mini, connect it to the 3.3V pin only.
- GND pin: ground. Connect it to a GND pin of the board.

※ NOTE THAT:
Rocker module or bare ON/OFF switch? The ESP32 C3 Super Mini - Switch tutorial uses a bare switch with two legs. There, one leg goes to GND, the code turns on INPUT_PULLUP, and ON reads as LOW, which is easy to get backwards. The module removes those steps: its pins have labels, it has its own pull-down, and ON reads as HIGH. If you need a part that springs back after each press, look at the ESP32 C3 Super Mini - Button Module tutorial instead.
Wiring Diagram between Rocker Switch Module and ESP32 C3 Super Mini
In the drawing, the ESP32 C3 Super Mini sits on a breadboard. The rocker switch module does not go into the breadboard: it stays beside it, and three jumper wires join its own header to the board. SIG goes to GPIO7 (simply 7 in the code), VCC goes to 3.3V, and GND goes to GND.
Why GPIO7? It is not a strapping pin. You may leave the rocker on the "I" side while you plug in the USB cable: GPIO7 is then HIGH at power-up, and that does not change how the board starts. GPIO2, GPIO8 and GPIO9 are strapping pins, so it is better to keep switches away from them. GPIO8 has a job in the second example anyway: it drives the blue on-board LED.

This image is created using Fritzing. Click to enlarge image
| Rocker Switch Module Pin | ESP32 C3 Super Mini Pin |
|---|---|
| SIG | GPIO7 |
| VCC | 3.3V |
| GND | GND |
※ NOTE THAT:
Keep VCC on 3.3V. With the rocker on the "I" side, the SIG pin passes the VCC voltage straight to GPIO7. The ESP32-C3 is a 3.3V chip, so 5V on VCC could damage the pin. Never use the 5V pin for this module.
The rating on the switch body is not for the header. The "6A 250VAC / 10A 125VAC" print is the rating of the bare switch. This module only sends a small logic signal to a GPIO pin. Never run mains power or motor current through its pins.
ESP32 C3 Super Mini Code - Read the Rocker Switch Position
The first sketch checks the wiring. About three times per second it reads GPIO7 and prints the level, the word ON or OFF, and which side of the rocker is pressed. It has no debounce: a bounce lasts only a few milliseconds, and with readings 300 ms apart it does no harm.
What the code does:
- Sets GPIO7 as a plain INPUT - the module's pull-down keeps it LOW while the switch is OFF
- Reads SIG with digitalRead(), which gives 1 (HIGH) or 0 (LOW)
- Prints [ ON] or [OFF] at the start of each line, then the raw level and the pressed side
- Waits 300 milliseconds and reads again
Detailed Instructions
- First time with this board? Follow the Getting Started with ESP32 C3 Super Mini tutorial, so the ESP32 board package is ready in the Arduino IDE.
- Wire it up: Put the ESP32 C3 Super Mini on the breadboard, keep the rocker module next to it, and add the three jumper wires from the table: SIG to GPIO7, VCC to 3.3V, GND to GND.
- Connect the board: Plug it into your computer with a USB Type-C cable.
- Open Arduino IDE: Then pick the ESP32 C3 Super Mini board and the COM port it uses.
- Add the code: Copy the sketch above into a new sketch. No library is needed.
- Upload: Click the Upload button and wait for "Done uploading".

- Open Serial Monitor: Set it to 115200 baud.
- Test it: Start with the "O" side pressed. Press the "I" side, wait about two seconds, then press "O" again. The lines change from [OFF] to [ ON] and back:
- Pro Tip: Every line says [OFF], whatever side you press? Check the VCC wire first: without power, the switch has nothing to pass on to SIG. Every line says [ ON]? SIG may touch the 3.3V wire. Nothing appears at all? In the Tools menu, set USB CDC On Boot to Enabled and upload once more.
Line-by-line Code Explanation
The above ESP32 C3 Super Mini code contains line-by-line explanation. Please read the comments in the code!
ESP32 C3 Super Mini Code - Blue On-board LED as a Pilot Light
Now the switch gets its light. The ESP32 C3 Super Mini has a small blue LED on GPIO8. It is active LOW: writing LOW turns it on, and writing HIGH turns it off. This sketch makes the LED copy the rocker, so it is lit while the switch is ON and dark while it is OFF. It also prints one line each time the position changes.
Because this sketch reacts to changes, a bounce must not count as a flip. A small millis() timer takes care of that: a new level is accepted only after it has stayed the same for 50 ms. A timer, unlike delay(), never stops the loop, so you can add WiFi or a sensor to this sketch later.
What the code does:
- Sets GPIO7 as an input for the switch and GPIO8 as an output for the blue LED
- Reads the switch once in setup(), sets the LED to match, and prints the start-up position
- In loop(), restarts a 50 ms timer each time the raw level of GPIO7 moves
- Accepts the new level only when 50 ms pass with no more movement
- Writes LOW to GPIO8 for ON (LED lit) and HIGH for OFF (LED dark)
- Prints the new state and the time since start-up, in seconds
Detailed Instructions
- Same wiring: Nothing moves. The module stays on GPIO7, and the LED is already on the board.
- Add the code: Paste the pilot-light sketch into a new sketch.
- Upload: Click the Upload button.
- Open Serial Monitor: Keep 115200 baud.
- Test it: Flip the rocker a few times and watch the small blue LED on the board. Each flip gives exactly one line, even when the contacts bounce:
- Pro Tip: Press the "I" side first, then press the reset button (or plug in the USB cable). The LED lights at once and the first line says ON, because setup() reads the switch before loop() starts. GPIO7 is not a strapping pin, so the board still starts normally.
Line-by-line Code Explanation
The above ESP32 C3 Super Mini code contains line-by-line explanation. Please read the comments in the code!
Applications and Project Ideas
A rocker switch suits settings that should stay put and be easy to see. Some ideas for the ESP32 C3 Super Mini:
- Do not disturb: mute the buzzer and the notification light of a small gadget while the switch is ON
- Holiday mode: stop the alarms of a plant or room monitor while you are away
- Thermostat enable: let a temperature sketch switch its relay only while the rocker is ON
- Maintenance lock: while the switch is ON, a machine controller ignores its start button
- Two light shows: pick between a calm and a party pattern for an LED strip
- Remote status: show the rocker position on a web page hosted by the ESP32 C3 Super Mini
Video Tutorial
Challenge Yourself
Try these tasks to go one step further:
- Easy: Turn the pilot light around: light the blue LED while the switch is OFF, like a "standby" lamp
- Easy: Count how many times the switch went ON and print the total with each change
- Medium: While the switch is ON, blink the LED once per second with millis() instead of keeping it lit - the ESP32 C3 Super Mini - LED - Blink Without Delay tutorial shows how
- Medium: Every 10 seconds, print a short summary: the current position and the number of flips so far
- Advanced: Read the rocker in setup() and join your WiFi network only when it is ON; light the LED once the connection is made
- Advanced: Add the button module on GPIO6 and count its clicks only while the rocker is ON