Guest User

xiaozhi ball simple esphome code with all entities (sound, mic, light and display)

a guest
May 26th, 2025
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. esphome:
  2. name: esphome-web-619cd4
  3. friendly_name: xiaozhi cube
  4. min_version: 2025.5.0
  5. name_add_mac_suffix: false
  6.  
  7. esp32:
  8. board: esp32-s3-devkitc-1
  9. flash_size: 16MB
  10. cpu_frequency: 240MHz
  11. framework:
  12. type: ESP-IDF
  13. sdkconfig_options:
  14. CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y"
  15. CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
  16. CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y"
  17.  
  18. psram:
  19. mode: octal
  20. speed: 80MHz
  21.  
  22. # Enable logging
  23. logger:
  24.  
  25. # Enable Home Assistant API
  26. api:
  27.  
  28. # Allow Over-The-Air updates
  29. ota:
  30. - platform: esphome
  31.  
  32. wifi:
  33. ap: {}
  34.  
  35. captive_portal:
  36.  
  37. #button on the back left
  38.  
  39. binary_sensor:
  40. - platform: gpio
  41. pin:
  42. number: GPIO0 # BOOT button
  43. inverted: true
  44. mode:
  45. input: true
  46. pullup: true
  47. name: Assist Button
  48. disabled_by_default: false
  49. id: button
  50.  
  51. #speaker and microphone
  52.  
  53. i2s_audio:
  54. - id: i2s # microphone
  55. i2s_lrclk_pin: GPIO4 #WS pin
  56. i2s_bclk_pin: GPIO5 #SCK pin
  57. - id: speaker_i2s # speaker
  58. i2s_lrclk_pin: GPIO16 # LRC pin
  59. i2s_bclk_pin: GPIO15 # BCLK pin
  60.  
  61. microphone:
  62. - platform: i2s_audio
  63. i2s_audio_id: i2s
  64. adc_type: external
  65. i2s_din_pin: GPIO6 #SD pin
  66. id: va_mic
  67.  
  68. speaker:
  69. platform: i2s_audio
  70. id: va_speaker
  71. i2s_audio_id: i2s
  72. dac_type: external
  73. i2s_dout_pin:
  74. number: GPIO7 # DIN Pin
  75.  
  76. media_player:
  77. - platform: speaker
  78. name: None
  79. announcement_pipeline:
  80. speaker: va_speaker
  81. format: WAV
  82. volume_min: 0.4
  83.  
  84. # onboard LED
  85.  
  86. light:
  87. - platform: esp32_rmt_led_strip
  88. id: led
  89. name: none
  90. disabled_by_default: false
  91. entity_category: config
  92. pin: GPIO48
  93. default_transition_length: 0s
  94. chipset: WS2812
  95. num_leds: 1
  96. rgb_order: grb
  97. effects:
  98. - pulse:
  99. name: "Slow Pulse"
  100. transition_length: 250ms
  101. update_interval: 250ms
  102. min_brightness: 50%
  103. max_brightness: 100%
  104. - pulse:
  105. name: "Fast Pulse"
  106. transition_length: 100ms
  107. update_interval: 100ms
  108. min_brightness: 50%
  109. max_brightness: 100%
  110.  
  111. # display
  112.  
  113. time:
  114. - platform: homeassistant
  115. id: homeassistant_time
  116.  
  117. spi:
  118. clk_pin: GPIO14 # SCL pin
  119. mosi_pin: GPIO17 # SDA pin
  120. interface: hardware
  121. id: spihwd
  122.  
  123. font:
  124. - file: "gfonts://Roboto"
  125. id: my_font
  126. size: 28
  127. - file: "gfonts://Roboto"
  128. id: roboto_52
  129. size: 52
  130.  
  131. image:
  132. - file: images/ow480x480.jpg
  133. id: my_image
  134. resize: 240x240
  135. type: RGB
  136.  
  137. display:
  138. - platform: ili9xxx
  139. invert_colors: true
  140. model: GC9A01A
  141. rotation: 0
  142. reset_pin: GPIO18 # RST pin
  143. cs_pin: GPIO13 # CS pin
  144. dc_pin: GPIO10 # DC pin
  145. lambda: |-
  146. auto red = Color(255,0,0), green = Color(0,255,0), blue = Color(0,0,255), yellow = Color(255,255,0), white = Color(255,255, 255), cyberlightgreen = Color(0,255,159), cyberlightblue = Color(0,184,255), cyberpink = Color(214,0,255);
  147. it.image(0, 0, id(my_image));
  148. it.strftime(120, 120, id(roboto_52), cyberlightgreen, TextAlign::CENTER, "%H:%M:%S", id(homeassistant_time).now());
Advertisement
Add Comment
Please, Sign In to add comment