Close
0%
0%

Simple Home Switchboard into a Smart Touch Control

Touchscreen smart switchboard with ESP32-S3: control 4 lights locally, clear ON/OFF UI, no app, no cloud, instant response.

Similar projects worth following

Introduction

Home automation projects usually look impressive in videos, but when you try building one yourself, things quickly become messy — loose wires, random modules on the desk, and half-finished enclosures.

In this tutorial, we build a clean, touch-based controller using the ESP32 S3 Box 3 that can control four lights locally, without any app or cloud dependency. This project is beginner-friendly, works offline, and is perfect as a practical home automation demo or hackathon prototype.

The Idea

Most homes still rely on traditional mechanical switchboards. They work fine, but they don’t provide visual feedback or flexibility for future automation.

Instead of replacing every switch with expensive smart switches, this project replaces the control logic behind the switchboard with a single touchscreen panel.

 The goal is simple: big buttons, clear ON/OFF feedback, instant response, and no internet dependency.

Watch the Full Build Video

I’ve also documented the complete build process in a step-by-step video, including wiring, UI design, and live testing.
If you prefer learning by watching, this will help you follow along and build the same project easily.

👉 Watch the full video here: [VIDEO LINK: Paste your YouTube link here]

  • 1
    Wiring Overview

    Each light is controlled by one relay channel, and each relay channel is driven by one GPIO pin on the ESP32-S3:

    • GPIO 10 → Light 1
    • GPIO 14 → Light 2
    • GPIO 13 → Light 3
    • GPIO 21 → Light 4

    Power the relay module using 5V and GND.

     Note: Many relay boards are active-low, so ON/OFF logic may appear inverted.

  • 2
    Building the Touch UI with LovyanGFX

    LovyanGFX is used to handle the display and touch input.

     The UI is kept intentionally minimal:

    • Four large buttons
    • Green = ON
    • Grey = OFF

    This makes the system easy to use for anyone, even without technical knowledge.

  • 3
    Code Overview
    #include <Arduino.h>
    
    #define LGFX_ESP32_S3_BOX_V3
    #include <LGFX_AUTODETECT.hpp>
    #include <LovyanGFX.hpp>
    
    static LGFX lcd;
    
    // ===== PINS =====
    #define PIN_L1 10
    #define PIN_L2 14
    #define PIN_L3 13
    #define PIN_L4 21
    
    bool l1=false, l2=false, l3=false, l4=false;
    
    struct Btn { int x,y,w,h; const char* label; bool* state; int pin; };
    Btn buttons[] = {
      {20, 60, 130, 60, "Light 1", &l1, PIN_L1},
      {170,60, 130, 60, "Light 2", &l2, PIN_L2},
      {20, 140,130, 60, "Light 3", &l3, PIN_L3},
      {170,140,130,60, "Light 4", &l4, PIN_L4},
    };
    
    void drawButton(Btn &b){
      lcd.fillRoundRect(b.x, b.y, b.w, b.h, 14, *b.state ? TFT_GREEN : TFT_DARKGREY);
      lcd.drawRoundRect(b.x, b.y, b.w, b.h, 14, TFT_WHITE);
      lcd.setFont(&fonts::FreeSansBold9pt7b);
      lcd.setTextColor(TFT_WHITE);
      lcd.setTextDatum(middle_center);
      lcd.drawString(b.label, b.x + b.w/2, b.y + b.h/2);
    }
    
    void drawUI(){
      lcd.fillScreen(TFT_BLACK);
    
      lcd.setFont(&fonts::FreeSansBold12pt7b);
      lcd.setTextColor(TFT_GREEN);
      lcd.setTextDatum(middle_center);
      lcd.drawString("ESP32-S3 Smart Lights", 160, 25);
    
      for(auto &b : buttons) drawButton(b);
    }
    
    void toggle(int i){
      *buttons[i].state = !*buttons[i].state;
      digitalWrite(buttons[i].pin, *buttons[i].state ? HIGH : LOW);
      drawButton(buttons[i]);
    }
    
    void setup(){
      Serial.begin(115200);
    
      pinMode(PIN_L1, OUTPUT);
      pinMode(PIN_L2, OUTPUT);
      pinMode(PIN_L3, OUTPUT);
      pinMode(PIN_L4, OUTPUT);
    
      digitalWrite(PIN_L1, LOW);
      digitalWrite(PIN_L2, LOW);
      digitalWrite(PIN_L3, LOW);
      digitalWrite(PIN_L4, LOW);
    
      lcd.init();
      lcd.setBrightness(255);
      drawUI();
    
      Serial.println("✅ ESP32-S3 4 Lights Touch UI Ready");
    }
    
    void loop(){
      uint16_t x, y;
    
      if(lcd.getTouch(&x, &y)){
        for(int i=0;i<4;i++){
          Btn &b = buttons[i];
          if(x > b.x && x < b.x + b.w && y > b.y && y < b.y + b.h){
            toggle(i);
            delay(250); // debounce
            break;
          }
        }
      }
    }

    The code has three main responsibilities:

    1. Initialize the display using LovyanGFX
    2. Draw four touch buttons on the screen
    3. Toggle GPIO pins when a button is touched

    Each button maps to one GPIO pin. When a button is pressed, the ESP32 toggles the corresponding relay.

View all 4 instructions

Enjoy this project?

Share

Discussions

Does this project spark your interest?

Become a member to follow this project and never miss any updates