Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based Wi-Fi Controlled Smart Lighting System with Nextion Touch LCD

View and Edit Project In Cirkit DesignerImage of ESP32-Based Wi-Fi Controlled Smart Lighting System with Nextion Touch LCD

Circuit Documentation

Summary

This circuit is designed to control multiple AC bulbs using an ESP32 microcontroller and an 8-channel relay module. The system also includes a Nextion Touch LCD for user interaction. The ESP32 is powered by a 3.3V battery, and the AC bulbs are powered by an AC source.

Component List

  1. ESP32 (30 pin)

    • Description: A powerful microcontroller with built-in Wi-Fi and Bluetooth capabilities.
    • Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3
  2. 8 Channel Relay JD-VCC

    • Description: A relay module that allows control of high voltage devices.
    • Pins: JD-VCC, VCC, GND, In8, In7, In6, In5, In4, In3, In2, In1, In1_NC, IN1_COM, IN1_NO, IN2_NC, IN2_COM, IN2_NO, IN3_NC, IN3_COM, IN3_NO, IN4_NC, IN4_COM, IN4_NO, IN5_NC, IN5_COM, IN5_NO, IN6_NC, IN6_COM, IN6_NO, IN7_NC, IN7_COM, IN7_NO, IN8_NC, IN8_COM, IN8_NO
  3. 3.3V Battery

    • Description: A battery providing 3.3V power supply.
    • Pins: +, -
  4. AC Bulb

    • Description: Standard AC bulbs used for lighting.
    • Pins: P, N
  5. Nextion Touch LCD 2.4"

    • Description: A touch-sensitive LCD display for user interaction.
    • Pins: VCC, GND, RX, TX
  6. AC Source

    • Description: Provides AC power to the bulbs.
    • Pins: +, -

Wiring Details

ESP32 (30 pin)

8 Channel Relay JD-VCC

3.3V Battery

AC Bulb

Nextion Touch LCD 2.4"

AC Source

Code Documentation

#include <INextionBooleanValued.h>
#include <INextionCallback.h>
#include <INextionColourable.h>
#include <INextionFontStyleable.h>
#include <INextionNumericalValued.h>
#include <INextionStringValued.h>
#include <INextionTouchable.h>
#include <INextionWidget.h>
#include <Nextion.h>
#include <NextionButton.h>
#include <NextionCallbackFunctionHandler.h>
#include <NextionCheckbox.h>
#include <NextionCrop.h>
#include <NextionDualStateButton.h>
#include <NextionGauge.h>
#include <NextionHotspot.h>
#include <NextionNumber.h>
#include <NextionPage.h>
#include <NextionPicture.h>
#include <NextionProgressBar.h>
#include <NextionRadioButton.h>
#include <NextionSlider.h>
#include <NextionSlidingText.h>
#include <NextionText.h>
#include <NextionTimer.h>
#include <NextionTypes.h>
#include <NextionVariableNumeric.h>
#include <NextionVariableString.h>
#include <NextionWaveform.h>
#include <esp32_azureiotkit_sensors.h>

// Relay Pins
#define RELAY1 12
#define RELAY2 13
#define RELAY3 14
#define RELAY4 25
#define RELAY5 26
#define RELAY6 27
#define RELAY7 32
#define RELAY8 33

// Relay State
bool relayState[8] = {false, false, false, false, false, false, false, false};

// Nextion Display Setup
#define RX_PIN 16
#define TX_PIN 17
Nextion myNextion(RX_PIN, TX_PIN);

// Function to Update Relays
void updateRelay(int relay, bool state) {
  digitalWrite(relay, state ? LOW : HIGH);  // Active LOW
}

// Function to Sync with Nextion Display
void updateNextion(int button