YLW5Qklw

Magic Button

 
Overview
The hardware consists of
an ESP32-D0WDQ6 microcontroller, a MAX98357AETE microcontroller, and an LGS4056HDA microcontroller.
Functionality
and implementation include

audio playback
button detection, short and long presses of
the SPIFFS key to store MP3 audio files
, manual network configuration (default SSID = "DAP" password = "12345678")
, TCP communication, and sending a power-on message to the server after five button presses within one minute. A long press sends a restart message to the server.

Upon completion of

the network configuration interface, a web-based configuration of the operating mode (power card, network player, Bluetooth speaker, etc.) is initiated. Resetting five times consecutively enters the network configuration interface, as does a 20-second long press.
The network configuration interface requires an SSID, password, mode selection


, low battery, and charging completion voice prompts.
OTA upgrades

are implemented to
establish a local area network TCP connection between the host and slave devices
. After power-on, the device will attempt to connect to the pre-configured network. The device checks its WiFi connection status every 5 seconds. If no network is found, the device will scan for nearby WiFi hotspots. In the scanned hotspot list, if a known, pre-configured hotspot exists, the device will attempt to connect to it. Once connected to the WiFi network, the device will start a TCP server, listening on port 8080 for TCP communication.
Key detection
performs single-click and long-press detection, with a 1-second long-press judgment time.
Audio playback
currently uses existing audio files in SPIFFS, but network audio streaming can also be used (to be developed) (for the subsequent Bluetooth speaker section).
Remote power-on
is triggered by pressing the button 6 times consecutively, while a long press triggers a restart command.
The host computer performs physical power-on and restart.
The software
development environment uses
PlatformIO + Arduino. The PIO board
configuration was modified
, and an ESP32 was chosen. The default ESP32 FLASH size is 4MB, but this is too small, causing insufficient space before many functions are added to the program.
Modify the partition table
by creating a new partition table in the project directory folder. Refer to the official documentation for instructions. Here, I've changed it to 8MB of FLASH, so the new partition table is named default_8MB.csv, with the following content:
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000,
0x5000, otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x330000,
app1, app, ota_1, 0x340000,0x330000,
spiffs, data, spiffs, 0x670000,0x180000,
coredump, data, coredump,0x7F0000,0x10000.
Similarly, you can also use 16MB of FLASH.
The partition table is named default_16MB.csv
. The table contains the following data: Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x480000,
app1, app, ota_1, 0x490000,0x480000,
spiffs, data, spiffs, 0x910000,0x6E0000,
coredump, data, coredump,0xFF0000,0x10000.
The configuration
file is typically located in {userProfile}.platformioplatformsespressif32 oards. The content to be modified is as follows; you can directly modify the original file or create a new one.
An 8MB configuration file and
a 16MB configuration file are
needed to modify the project configuration file, 
including platformio.ini. 
[env:esp32dev]
platform = espressif32
board = esp32dev_8m
framework = arduino
board_build.partitions = default_8MB.csv
Upload files
to the SPIFFS partition. Create a data folder in the project. Clicking the download option will synchronously upload the files in the data folder to the ESP32. Deleting or removing data files will also update the SPIFFS partition.
Note:
Due to the limitations of the I2S library, audio materials must be prepared according to the corresponding chip.




Codec
ESP32
ESP32 PSRAM
ESP32-S3 PSRAM





mp3
y
y
y



aac
n
y
y



aacp
n
y (mono)
y (+SBR, +PS)



wav
y
y
y



flac
n
y
y
blocksize max 8192 bytes


vorbis
n
y
y


参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-26 18:49:53

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号