A minimal ESP-IDF project for ESP32-S3-BOX-3 that demonstrates LED control via touchscreen and speech recognition.
This project provides a simple interface to control a single LED (on/off, latching) using:
- Touchscreen: Full-screen image button to toggle LED state
- Speech Recognition: Voice commands "turn on light" and "turn off light"
The LED state is persisted across reboots using NVS (Non-Volatile Storage).
- ESP32-S3-BOX-3 development board
- LED connected to GPIO40 (simple on/off, no PWM)
- Built-in LCD touchscreen (320x240)
- Built-in microphone array for speech recognition
- ✅ Boot Animation: ESP logo animation on startup
- ✅ Touch Control: Full-screen button with ON/OFF images (320x240)
- ✅ Speech Recognition: English voice commands
- "turn on light" → LED ON
- "turn off light" → LED OFF
- ✅ SR Visual Feedback: Listening screen with animation and text overlay
- ✅ Audio Feedback: Tones for wake word, command recognition, and timeout
- ✅ State Persistence: LED state saved to NVS and restored on boot
factory_demo/
├── main/
│ ├── app/
│ │ ├── app_led.c/h # Single LED GPIO control (GPIO40)
│ │ ├── app_sr.c/h # Speech recognition engine
│ │ └── app_sr_handler.c/h # SR command handler + audio feedback
│ ├── gui/
│ │ ├── ui_boot_animate.c/h # Boot animation
│ │ ├── ui_sr.c/h # SR listening screen overlay
│ │ └── image/
│ │ ├── switchOn.h # ON state image (BMP converted)
│ │ └── switchOff.h # OFF state image (BMP converted)
│ ├── light_ctrl.c/h # LED control abstraction layer
│ ├── light_state.c/h # NVS state persistence
│ ├── light_ui.c/h # LVGL touchscreen UI
│ └── main.c # Application entry point
├── spiffs/ # SPIFFS filesystem (audio files)
│ └── echo_en_*.wav # English audio feedback tones
└── CMakeLists.txt
-
ESP-IDF v5.5+ installed and configured
. $HOME/esp/esp-idf/export.sh
-
Python 3.12+ (required by ESP-IDF)
-
Navigate to project directory:
cd /Users/semiconmediapvtltd/Desktop/box3/factory_demo -
Set up ESP-IDF environment:
. $HOME/esp/esp-idf/export.sh
-
Configure (optional):
idf.py menuconfig
-
Build:
idf.py build
-
Flash and monitor:
idf.py flash monitor
Or flash and monitor separately:
idf.py flash idf.py monitor
- Tap anywhere on the screen to toggle the LED state
- The screen displays either the "ON" or "OFF" image based on current LED state
- Say the wake word (configured in ESP-SR)
- Wait for the listening animation
- Say one of the commands:
- "turn on light" → Turns LED ON
- "turn off light" → Turns LED OFF
- Audio feedback confirms command recognition
Connect your LED to GPIO40:
- Anode → GPIO40 (via current-limiting resistor, e.g., 220Ω)
- Cathode → GND
The LED is driven as a simple digital output (HIGH = ON, LOW = OFF).
To change the LED GPIO pin, edit main/app/app_led.c:
#define SINGLE_LED_GPIO GPIO_NUM_40 // Change to your desired GPIOSpeech commands are defined in main/app/app_sr.c:
static const sr_cmd_t g_default_cmd_info[] = {
{SR_CMD_LIGHT_ON, SR_LANG_EN, 0, "turn on light", "TkN nN LiT", {NULL}},
{SR_CMD_LIGHT_OFF, SR_LANG_EN, 0, "turn off light", "TkN eF LiT", {NULL}},
};Audio feedback tones are stored in spiffs/:
echo_en_wake.wav- Wake word detectedecho_en_ok.wav- Command recognizedecho_en_end.wav- Timeout/end of listening
- Check GPIO40 connection and wiring
- Verify LED polarity (common cathode)
- Check if GPIO40 conflicts with other peripherals
- Ensure microphone array is connected
- Check audio codec initialization in logs
- Verify SR model files are flashed correctly
- Check image conversion (BMP to RGB565)
- Verify LVGL display initialization
- Check display backlight settings
- Verify SPIFFS partition is mounted
- Check audio files exist in
spiffs/ - Verify I2S codec initialization
SPDX-License-Identifier: Unlicense OR CC0-1.0
Copyright (c) 2015-2024 Espressif Systems (Shanghai) CO LTD