Build a Low-Voltage Smart Power Strip Simulator
The Story
A smart power strip sounds like a mains project, but this safe Golden version teaches the control pattern without touching dangerous wiring. You build a low-voltage simulator that behaves like four controllable outlets while switching only DC demo loads.
Explain Like I'm 12
Each GPIO pin tells a MOSFET gate to allow or block current through one small DC load. The ESP32 web page flips those gates, and the code starts with everything OFF so a reset does not surprise you.
Learning Support
- Recommended ageAges 12+
- Adult supervisionRequired to confirm the build remains low-voltage DC only.
- Classroom useUse battery or bench-supply DC loads; do not bring mains wiring into the activity.
- Parent promptAsk why the simulator uses MOSFETs and low-voltage loads instead of a modified power strip.
- Screen-free activitySketch four independent DC channels with a shared ground and a master-off button.
- Next challengeAdd current sensing on the low-voltage side after the four base channels are stable.
- Skills practiced
- MOSFET low-side switching
- Fail-safe startup
- Local web controls
- Shared-ground wiring
- Learning outcomes
- Switch four low-voltage DC loads with GPIO25, GPIO26, GPIO27, and GPIO33.
- Start every channel OFF before Wi-Fi or the web page begins.
- Use a master-off route.
- Explain why mains power strips are out of scope.
- Mini experiments
- Toggle one channel at a time.
- Reset the ESP32 and confirm all channels start OFF.
- Add a flyback diode before testing any coil load.
Safety Standards
- Unplug USB before changing jumper wires. Recheck 3.3 V, 5 V, and GND before reconnecting power.
- Do not power motors, pumps, LED strips, or servos from the ESP32 3.3 V pin. Use a suitable external supply and common ground.
- Breadboards are for low-current prototypes. Move high-current or unattended builds to proper terminals, enclosure, strain relief, and fusing.
- Relay and mains-voltage projects require isolation, correct relay ratings, enclosed wiring, and qualified adult supervision.
What You Will Build
A web-controlled four-channel low-voltage DC switching simulator with fail-safe OFF startup and a master-off control.
Components List
- ESP32 DevKit boardLow-voltage control board for the web interface.
- Four logic-level N-channel MOSFETsSwitch low-voltage DC loads from GPIO25/GPIO26/GPIO27/GPIO33.
- Four low-voltage DC loadsLED strips, small lamps, or other safe DC demo loads within their rated supply.
- Separate low-voltage load supplyMatches the demo loads; share ground with the ESP32.
- Flyback diodes for inductive loadsRequired across motors, relays, solenoids, or coils.
Bill of Materials
| Part | Qty | Estimated Cost | Notes |
|---|---|---|---|
| ESP32 DevKit board | 1 | Varies | Low-voltage control board for the web interface. |
| Four logic-level N-channel MOSFETs | 1 | Varies | Switch low-voltage DC loads from GPIO25/GPIO26/GPIO27/GPIO33. |
| Four low-voltage DC loads | 1 | Varies | LED strips, small lamps, or other safe DC demo loads within their rated supply. |
| Separate low-voltage load supply | 1 | Varies | Matches the demo loads; share ground with the ESP32. |
| Flyback diodes for inductive loads | 1 | Varies | Required across motors, relays, solenoids, or coils. |
Wiring
Use GPIO25/GPIO26/GPIO27/GPIO33 as active-HIGH MOSFET gate signals. The ESP32 ground and low-voltage load-supply ground must be common.
-
1
Unplug USB and the low-voltage load supply before wiring.
-
2
Connect ESP32 GND to the load-supply GND.
-
3
Connect GPIO25, GPIO26, GPIO27, and GPIO33 to the four MOSFET gates through suitable gate resistors.
-
4
Wire each low-voltage load through its MOSFET on the DC side only.
-
5
Add a flyback diode across every inductive load before applying power.
-
6
Power the ESP32, upload the sketch, and confirm all channels are OFF before opening the web page.
GPIO Mapping
| Signal | ESP32 Pin | Direction | Notes |
|---|---|---|---|
| Channel 1 MOSFET gate | GPIO25 | Output | Active HIGH low-voltage control. |
| Channel 2 MOSFET gate | GPIO26 | Output | Active HIGH low-voltage control. |
| Channel 3 MOSFET gate | GPIO27 | Output | Active HIGH low-voltage control. |
| Channel 4 MOSFET gate | GPIO33 | Output | Active HIGH low-voltage control. |
Circuit Explanation
Each MOSFET acts as a low-side switch for one DC load. The ESP32 drives only the gate signal; the load current comes from the separate low-voltage supply.
Engineering Explanation
The selected GPIOs avoid common ESP32 boot-strap pins used in the previous staged relay design. The sketch drives all outputs LOW before Wi-Fi starts and includes a master-off route for a fail-safe default.
Libraries
- Arduino ESP32 WiFi and WebServerBuilt into the Arduino ESP32 core.
Code
Copy into Arduino IDE. Install any libraries noted in the component guides first.
// ESP32 low-voltage smart power strip simulator
// Switch only low-voltage DC loads. Do not connect this circuit to mains power.
#include <WiFi.h>
#include <WebServer.h>
const char* WIFI_SSID = "YOUR_WIFI_NAME";
const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD";
const int CHANNEL_PINS[4] = {25, 26, 27, 33};
bool channelOn[4] = {false, false, false, false};
WebServer server(80);
void applyOutputs() {
for (int i = 0; i < 4; i++) {
digitalWrite(CHANNEL_PINS[i], channelOn[i] ? HIGH : LOW);
}
}
void allOff() {
for (int i = 0; i < 4; i++) channelOn[i] = false;
applyOutputs();
}
void servePanel() {
String html = "<!doctype html><html><body><h1>Low-Voltage Smart Power Strip Simulator</h1>";
html += "<p>DC demo loads only - no mains wiring.</p><p><a href='/alloff'>Master OFF</a></p>";
for (int i = 0; i < 4; i++) {
html += "<p>Channel " + String(i + 1) + ": ";
html += channelOn[i] ? "ON" : "OFF";
html += " <a href='/toggle?ch=" + String(i) + "'>Toggle</a></p>";
}
html += "</body></html>";
server.send(200, "text/html", html);
}
void handleToggle() {
int ch = server.arg("ch").toInt();
if (ch >= 0 && ch < 4) {
channelOn[ch] = !channelOn[ch];
applyOutputs();
}
server.sendHeader("Location", "/");
server.send(302, "text/plain", "");
}
void handleAllOff() {
allOff();
server.sendHeader("Location", "/");
server.send(302, "text/plain", "");
}
void setup() {
Serial.begin(115200);
for (int i = 0; i < 4; i++) {
pinMode(CHANNEL_PINS[i], OUTPUT);
digitalWrite(CHANNEL_PINS[i], LOW);
}
allOff();
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) delay(500);
server.on("/", servePanel);
server.on("/toggle", handleToggle);
server.on("/alloff", handleAllOff);
server.begin();
Serial.print("Open local control page: http://");
Serial.println(WiFi.localIP());
}
void loop() {
server.handleClient();
}
Code Explanation
The sketch configures GPIO25/GPIO26/GPIO27/GPIO33 as outputs, immediately turns every channel OFF, then starts a local web panel with per-channel toggles and a master-off route.
Expected Output
After reset all channels are OFF. Serial Monitor prints the local web address; the page shows four low-voltage channels and a Master OFF link. No channel turns on until a user toggles it.
Troubleshooting
- A channel turns on during reset Confirm the sketch uses GPIO25/GPIO26/GPIO27/GPIO33 and that all outputs are driven LOW before Wi-Fi starts.
- Load does not switch Check the shared ground, MOSFET orientation, gate wiring, and load supply voltage.
- ESP32 resets when a load switches Separate the load supply from USB power, add flyback diodes for coils, and keep load current out of the ESP32 board.
Common Mistakes
- Connecting the project to mains wiring.
- Using relay modules and boot pins from the old staged version.
- Forgetting the shared ground between ESP32 and the DC load supply.
- Testing a motor or solenoid without a flyback diode.
Testing Checklist
- Power with no loads first.
- Confirm all channels start OFF.
- Test one DC load at a time.
- Use flyback diodes before coil testing.
Engineering Tips
- Keep mains out of the enclosure.
- Use logic-level MOSFETs.
- Name channels by load voltage, not household socket labels.
Upgrade Ideas
- Add per-channel low-voltage current sensing.
- Add MQTT control for the same DC simulator.
- Add saved schedules that still default OFF after firmware upload.
Real-World Applications
- Low-voltage automation trainer
- Classroom web-control demo
- MOSFET switching practice
FAQs
Can I modify a real power strip?
No. This tutorial is only a low-voltage DC simulator.
Why use MOSFETs instead of relays?
MOSFETs keep the project focused on safe DC switching and avoid mains relay claims.
Review, Testing, and References
Author: Abdul Mubeen and the ESP32 Engine editorial team. Last updated: 2026-07-10. Reviewed: wiring logic, Arduino code structure, beginner safety, and learning sequence.
Educational level: Intermediate. Estimated completion time: 60-75 min. This project is for learning and prototyping; production or unattended hardware needs additional engineering review.
Project Complete!
You built a safer smart-strip learning model: four low-voltage DC channels, safe GPIO choices, fail-safe OFF startup, and a master-off route. The project teaches automation control without touching mains wiring.
- Low-voltage MOSFET switching
- Fail-safe output initialization
- Local web control
- Inductive-load protection
