This project is a custom firmware for ESP32-based audio boards, originally designed for the ESP32-LyraT v4.3 and ported to the Ai-Thinker ESP32-A1S-AudioKit.
- Ai-Thinker ESP32-A1S-AudioKit (ES8388 Codec Version) - Default Configuration
- ESP32-LyraT v4.3
The project is currently configured by default for the Ai-Thinker board using a custom component in components/audio_board.
- ESP-IDF v4.3+ (v4.3.2 is verified)
- ESP-ADF
- Navigate to the project directory.
- Clean the build (optional but recommended):
idf.py fullclean
- Build the project:
idf.py build
- Flash and Monitor:
idf.py -p <PORT> flash monitor
- MCLK Generation: MCLK is force-enabled on GPIO 0 within
board.cinitializtion to support the ES8388 codec. - SD Card: Configured for 1-Line mode (
SD_MODE_1_LINE) to match the hardware connections. - LEDs: The standard display service for LEDs is stubbed out as this board uses simple GPIOs.
To target the original LyraT board, you must disable the custom board component and revert to the standard ADF definition.
- Disable Custom Component: Rename or remove the local
components/audio_boarddirectory so the build system doesn't find it.mv components/audio_board components/audio_board_disabled
- Configure Menuconfig:
- Run
idf.py menuconfig - Go to Audio HAL > Audio Board
- Select ESP32-LyraT V4.3
- Save and Exit.
- Run
- Clean and Build:
idf.py fullclean idf.py build
- No Audio (Ai-Thinker): Ensure GPIO 0 is not being used by other peripherals, as it is required for the MCLK signal to the codec.
- SD Card Mount Failed: Ensure the card is formatted FAT32. The A1S board only supports 1-Line mode securely on most revisions.
The buttons on the Ai-Thinker AudioKit are mapped as follows:
| Button | Label on Board | Function |
|---|---|---|
| REC | KEY1 (GPIO 36) | Select Side A (Switch pipeline to use Side A tape file) |
| MODE | KEY2 (GPIO 13) | Select Side B (Switch pipeline to use Side B tape file) |
| PLAY | KEY3 (GPIO 19) | Play / Passthrough Toggle - In Decode/Play mode: Switch to Passthrough (Live Input) - In Passthrough: Switch back to Playback - In Encode mode: Start/Stop Recording |
| SET | KEY4 (GPIO 23) | EQ Toggle (Cycle Equalizer presets) |
| VOL+ | KEY5 (GPIO 18) | Volume Up |
| VOL- | KEY6 (GPIO 5) | Volume Down |
The device connects to WiFi using credentials loaded from the SD card.
- Create a file named
wifi_config.txtin the root of your SD card. - Add your SSID and Password separated by a tab character.
YourSSID YourPassword - If this file is missing, the firmware uses fallback credentials.
To set your own default credentials (if you prefer not to use the SD card), edit main/config.h and recompile:
#define CONFIG_WIFI_SSID "YourSSID"
#define CONFIG_WIFI_PASSWORD "YourPassword"To access the web interface or API, find the IP address via the serial monitor (idf.py monitor).
The board runs an HTTP server on port 80.
| URI | Method | Description | Parameters |
|---|---|---|---|
/ |
GET | Set operation mode | mode: encode, decode, or pass |
/play |
GET | Start playback | side: a or b |
/stop |
GET | Stop pipeline | None |
/vol |
GET | Set volume | value: 0-100 |
/output |
GET | Set audio output | device: SP (Speaker) or BT (Bluetooth)Optional btdevice: Name of BT device |
/eq |
GET | Set Equalizer | band: comma-separated list of 10 integer values |
/mp3db |
GET | List MP3 database | None |
/tapedb |
GET | List Tape database | None |
/info |
GET | Get status info | None |
/raw |
GET | Stream raw data | None |
/dct |
GET | Enable DCT mapping | Optional offset: integer seconds |
/create |
GET | Create tape config | side (a/b), tape (length), mute, data |
/start |
GET | Start encoding | side: a or b |
General Control
- Set Mode to Encode:
http://<IP>/?mode=encode - Set Mode to Decode (Play):
http://<IP>/?mode=decode - Set Mode to Passthrough:
http://<IP>/?mode=pass - Stop All Operations:
http://<IP>/stop - Get System Info:
http://<IP>/info - Set Volume to 80%:
http://<IP>/vol?value=80
Playback
- Play Side A:
http://<IP>/play?side=a - Play Side B:
http://<IP>/play?side=b - Switch Output to Bluetooth:
http://<IP>/output?device=BT&btdevice=MySpeaker - Switch Output to Speaker:
http://<IP>/output?device=SP - Set Equalizer:
http://<IP>/eq?band=-2,0,2,4,2,0,-2,-4,-2,0(10 bands)
Tape & Database
- List MP3 Database:
http://<IP>/mp3db - List Tape Database:
http://<IP>/tapedb - Create Tape Config:
http://<IP>/create?side=a&tape=60&mute=5&data=0001,mp3_1,mp3_2... - Start Encoding Side A:
http://<IP>/start?side=a
Data Streaming
- Stream Raw Line Data:
http://<IP>/raw - Enable DCT Mapping:
http://<IP>/dct - Enable DCT Mapping with Offset:
http://<IP>/dct?offset=1800(Shift mapping by 30 mins)
To view real-time CPU usage statistics per task on the serial monitor:
- Run
idf.py menuconfig. - Navigate to Component config -> FreeRTOS.
- Enable Enable FreeRTOS to collect run time stats.
- Save and Exit.
- Rebuild and flash:
idf.py build flash monitor.
The console will output a table every second showing task runtimes and CPU percentage.