Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

ESP32-Powered Voice-Controlled LED Lighting System

Image of ESP32-Powered Voice-Controlled LED Lighting System

Circuit Documentation

Summary

The circuit in question appears to be a multi-functional device that incorporates various LEDs, a microphone module (INMP441), a voltage regulator (7805), a toggle switch, and two ESP32 Wroom Dev Kits for processing and control. The circuit is powered by a 12V battery, and the 7805 voltage regulator steps down the voltage to 5V for certain components. The ESP32 microcontrollers are used to control the LEDs and handle audio input from the INMP441 microphone module. The toggle switch seems to be used for controlling the power supply to some parts of the circuit.

Component List

Microphone Module (INMP441)

  • A digital I2S output microphone module.
  • Pins: GND, VDD, SD, L/R, WS, SCK.

Toggle Switch

  • A simple on-off switch to control the power flow.
  • Pins: Vcc, Sig, Gnd.

LEDs

  • Three single-color LEDs (green, yellow, red) with two pins each (anode, cathode).
  • One RGB LED with four pins (common anode, red cathode, green cathode, blue cathode).

Battery (12V)

  • A 12V power source for the circuit.
  • Pins: + (positive), - (negative).

Voltage Regulator (7805)

  • A voltage regulator that outputs 5V.
  • Pins: Vin (input voltage), Gnd (ground), Vout (output voltage).

ESP32 Wroom Dev Kit

  • A microcontroller development board with Wi-Fi and Bluetooth capabilities.
  • Pins: Multiple GPIOs, 3V3, EN, VP, VN, GND, SD2, SD3, CMD, V5, TXD, RXD, CLK, etc.

Wiring Details

Microphone Module (INMP441)

  • VDD connected to 3V3 of ESP32.
  • SD connected to GPIO 33 of ESP32.
  • GND connected to the ground plane.

Toggle Switch

  • Vcc connected to VDD of INMP441 and 3V3 of ESP32.
  • Sig connected to GPIO 32 of ESP32.
  • Gnd connected to the ground plane.

LEDs (Single Color)

  • Red LED: Anode connected to GPIO 19 of ESP32, cathode connected to the ground plane.
  • Yellow LED: Anode connected to GPIO 2 of ESP32, cathode connected to the ground plane.
  • Green LED: Anode connected to GPIO 22 of ESP32, cathode connected to the ground plane.

RGB LED (Four Pin)

  • Common anode connected to V5 of ESP32 and Vout of 7805.
  • Red cathode connected to GPIO 4 of ESP32.
  • Green cathode connected to GPIO 15 of ESP32.
  • Blue cathode connected to GPIO 2 of ESP32.

Battery (12V)

  • Positive (+) connected to Vin of 7805.
  • Negative (-) connected to the ground plane.

Voltage Regulator (7805)

  • Vin connected to the positive terminal of the battery.
  • Gnd connected to the ground plane.
  • Vout connected to the common anode of the RGB LED and V5 of ESP32.

ESP32 Wroom Dev Kit

  • Various GPIOs connected to LEDs and microphone module as described above.
  • GND pins connected to the ground plane.
  • 3V3 pins connected to VDD of INMP441 and Vcc of Toggle Switch.
  • V5 pins connected to the common anode of the RGB LED and Vout of 7805.
  • TXD and RXD pins are cross-connected between the two ESP32s for serial communication.

Documented Code

ESP32 Wroom Dev Kit (Primary Controller)

//////Running code with board manager version 1.0.6
#define led_1 15
#define led_2 4
#define button 32 // Button_Sensor
#define led_3 2
#define RXp2 16
#define TXp2 17
#include "Audio.h"
#include "CloudSpeechClient.h"
int i=0;
void setup() {
  pinMode(button, INPUT);
  pinMode(led_1, OUTPUT);
  pinMode(led_2, OUTPUT);
  pinMode(led_3, OUTPUT);
  Serial.begin(115200);
  Serial2.begin(115200, SERIAL_8N1, RXp2, TXp2);
  //  Serial.println(My_Data);
}

void loop() {
  digitalWrite(led_1, 0);
  digitalWrite(led_2, 0);
  digitalWrite(led_3, 0);

  if(i==0){
    Serial.println("Press button");
    i=1;
  }
  delay(500);
  if(digitalRead(button)==0){
    Serial2.println("\nPlease Ask!\n");
    digitalWrite(led_1, 1);
    digitalWrite(led_2, 0);
    digitalWrite(led_3, 0);
    delay(2100);

    Serial.println("\r\nRecord start!\r\n");
    Audio* audio = new Audio(ADMP441);
    audio->Record();
    Serial.println("Recording Completed Processing");
    digitalWrite(led_1,0);
    digitalWrite(led_3,0);
    digitalWrite(led_2,1);
    CloudSpeechClient* cloudSpeechClient = new CloudSpeechClient(USE_APIKEY);
    cloudSpeechClient->Transcribe(audio);
    delete cloudSpeechClient;
    delete audio;
    i=0;
  }
  if(digitalRead(button)==1){
    delay(1000); 
  }
}

ESP32 Wroom Dev Kit (Secondary Controller)

#define pin_1 2  // Pin for light one control
#define pin_2 22  // Pin for light two control
#define pin_3 19  // Pin for light three control

void setup() {
    pinMode(pin_1, OUTPUT);
    pinMode(pin_2, OUTPUT);
    pinMode(pin_3, OUTPUT);
    Serial.begin(115200);
    Serial2.begin(115200);
}

void loop() {
    if (Serial2.available()) {
        String receivedText = Serial2.readString();
        Serial.println("Received text: " + receivedText);
        processCommand(receivedText);
    }
    delay(100);
}

void processCommand(String command) {
    command.toLowerCase(); // Convert to lowercase for easier matching

    // Light one control
    if (command.indexOf("turn on light one") >= 0) {
        digitalWrite(pin_1, HIGH);  // Set pin_1 HIGH (1)
        Serial.println("Pin 1 set HIGH");
    } else if (command.indexOf("turn off light one") >= 0) {
        digitalWrite(pin_1, LOW);   // Set pin_1 LOW (0)
        Serial.println("Pin 1 set LOW");
    }
    
    // Light two control
    else if (command.indexOf("turn on light two") >= 0) {
        digitalWrite(pin_2, HIGH);  // Set pin_2 HIGH (1)
        Serial.println("Pin 2 set HIGH");
    } else if (command.indexOf("turn off light two") >= 0) {
        digitalWrite(pin_2, LOW);   // Set pin_2 LOW (0)
        Serial.println("Pin 2 set LOW");
    }
    
    // Light three control
    else if (command.indexOf("turn on light three") >= 0) {
        digitalWrite(pin_3, HIGH);  // Set pin_3 HIGH (1)
        Serial.println("Pin 3 set HIGH");
    } else if (command.indexOf("turn off light three") >= 0) {
        digitalWrite(pin_3, LOW);   // Set pin_3 LOW (0)
        Serial.println("Pin 3 set LOW");
    }
    
    // All lights control
    else if (command.indexOf("turn on all lights") >= 0) {
        digitalWrite(pin_1, HIGH);
        digitalWrite(pin_2, HIGH);
        digitalWrite(pin_3, HIGH);
        Serial.println("All pins set HIGH");
    } else if (command.indexOf("turn off all lights") >= 0) {
        digitalWrite(pin_1, LOW);
        digitalWrite(pin_2, LOW);
        digitalWrite(pin_3, LOW);
        Serial.println("All pins set LOW");
    } 
    
    else {
        Serial.println("Command not recognized");
    }
}

(Note: The code for the 7805 microcontroller instance is empty and thus not included in the documentation.)