Last active
October 15, 2025 11:05
-
-
Save somebox/2a8a55e47b392197081c4685d56826c1 to your computer and use it in GitHub Desktop.
Example ESP32 Audio node for Home Assistant and Music Assistant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ESPHome configuration for a Music Assistant compatible audio-speaker | |
# using an ESP32-WROVER-KIT and I2S audio | |
# Includes sensors for ESP temperature, a reset switch and a mute button. | |
# SEE ALSO: https://github.com/somebox/i2s-audio-stream-test for more detailed examples to test and docs | |
esphome: | |
name: audio-speaker | |
friendly_name: Audio Speaker | |
# Platform-specific configuration | |
platformio_options: | |
board_build.f_cpu: 240000000L | |
board_build.f_flash: 80000000L | |
board_build.flash_mode: dio | |
board_build.partitions: huge_app.csv | |
esp32: | |
board: esp-wrover-kit | |
framework: | |
type: arduino | |
# Using ESPHome's recommended Arduino framework version | |
# Enable logging | |
logger: | |
level: DEBUG | |
# Enable Home Assistant API | |
api: | |
encryption: | |
key: !secret api_encryption_key | |
ota: | |
- platform: esphome | |
password: !secret ota_password | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_password | |
# Optional: manual IP configuration | |
# manual_ip: | |
# static_ip: 192.168.1.150 | |
# gateway: 192.168.1.1 | |
# subnet: 255.255.255.0 | |
# dns1: 192.168.1.1 | |
fast_connect: true | |
power_save_mode: none | |
# Enable fallback hotspot (captive portal) in case wifi connection fails | |
ap: | |
ssid: "Audio-Speaker Fallback" | |
password: !secret fallback_password | |
captive_portal: | |
# Status LED on GPIO 2 (common for ESP32 dev boards) | |
status_led: | |
pin: | |
number: GPIO2 | |
inverted: false | |
# Internal temperature sensor | |
sensor: | |
- platform: internal_temperature | |
name: "Audio Speaker Internal Temperature" | |
update_interval: 60s | |
# WiFi signal strength | |
- platform: wifi_signal | |
name: "Audio Speaker WiFi Signal" | |
update_interval: 60s | |
# Text sensors for diagnostics | |
text_sensor: | |
- platform: wifi_info | |
ip_address: | |
name: "Audio Speaker IP Address" | |
ssid: | |
name: "Audio Speaker SSID" | |
# Button on GPIO 0 (boot button on most ESP32 boards) | |
binary_sensor: | |
- platform: gpio | |
pin: | |
number: GPIO0 | |
inverted: true | |
mode: | |
input: true | |
pullup: true | |
name: "Audio Speaker Button" | |
on_press: | |
- media_player.toggle: | |
id: audio_out | |
# I2S Audio configuration | |
# Your hardware pins: | |
# I2S_DOUT: GPIO13, I2S_BCLK: GPIO14, I2S_LRC: GPIO12 | |
i2s_audio: | |
- id: i2s_out | |
i2s_lrclk_pin: GPIO12 # LRC (Word Select) | |
i2s_bclk_pin: GPIO14 # BCLK (Bit Clock) | |
# Media Player for Music Assistant and Home Assistant | |
media_player: | |
- platform: i2s_audio | |
name: "Audio Speaker" | |
id: audio_out | |
dac_type: external | |
i2s_audio_id: i2s_out | |
i2s_dout_pin: GPIO13 # DOUT (Data Out) | |
mode: mono # Set to stereo if your speaker setup supports it | |
on_state: | |
- logger.log: | |
format: "Media player state changed" | |
# Optional: Switch to control power or muting | |
switch: | |
- platform: restart | |
name: "Audio Speaker Restart" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see also: https://github.com/somebox/i2s-audio-stream-test