Skip to content

wryandginger/mini-squeezebox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Note: This is older and out of date. I mostly use these directly with Squeezelite ESP32.

mini-squeezebox

This takes an ESP32-A1S Audio Kit and makes a mini-squeezebox player.

modelL modelR modelB

How To

  1. Get an ESP32-A1S Audio Kit ( Amazon Link or AliExpress Link )

  2. Buy some 8 ohm 1W speakers with JST connectors

  3. Pick up a 3.7V 3700mAh Battery

  4. Grab an SSD1306 124x64 I2C OLED Display

  5. Get some DuPont cables, electrical tape, and foam mounting tape.

  6. Use the STL file here and print your case using a 3D printer. (Here's an alternative case that you might want instead: EdwardKrayer's github)

  7. Be sure you have a running Logitech Media Server, Home Assistant with either the: SlimProto integration, Music Assistant 2.0 Addon, Logitech Media Server Addon, or ESPHome.

  8. Flash your device using ESP32 Squeezelite or ESPHome

  9. Assemble the device: Clip speakers in first, add DuPont cables and attach the speakers to the board.

  10. Connect the battery and or an extension cable for the battery. Place mounting foam or double-sided tape inside the battery cavity to keep the battery still. -- IMPORTANT: Do NOT puncture, press, or dent the battery.

  11. Connect DuPont Cables to GPIO18, GPIO23, 3V3, and GND and connect to your display. Verify dipswitches on the board are set to:

      OFF-OFF-OFF-ON-ON

  12. Slide the board into the case slowly, and carefully. Don't snag the speakers -- They're extremely fragile.

  13. Slide the display into the slot, and attach with electrical tape.

  14. Attach the lid (not yet available)

(Note: You can also use the blender model to make adjustments and changes. There's a ready-to-print GCODE file available if you have a Voxelab Aquila X3 or an Ender 3 V2.)

The Code

Be careful as you follow these instructions A1S Audio Kit boards I have are marked V2.2 with A210 on one board and 3895 on the other. On both the A1S module has B238 printed on the back. From what I can tell, there are older boards that use a different codec and older revisions have different GPIO assignments, but this appears to be the current version and matches up with AI Thinker's (current) [spec sheets](https://docs.ai-thinker.com/en/esp32-a1s) and documentation.

Install Squeezelite-ESP32

  1. Go here: sle118's Squeezelite-ESP32 Installer

  2. Then set up the wifi on the Squeezelite box and reboot

  3. Go to "Hardware" and under "Known Board Name" select "ESP32A1S V2.2+ Variant 1 (ES8388)", Save, Apply, Reboot.

  4. Go to "Credits" then "Show NVS Editor" and go to the "NVS Editor" under actlrs_config: type buttons

  5. Scroll to the bottom. in the "new key" box type buttons and under "new value" type:

[{"gpio": 18,"type": "BUTTON_LOW","pull": true,"long_press": 600,"debounce": 0,"normal": {"pressed": "BCTRLS_PS5"},"longpress":{"pressed":"BCTRLS_UP"}},{"gpio": 5,"type": "BUTTON_LOW","pull": true,"long_press": 600,"debounce": 0,"normal": {"pressed": "BCTRLS_PS6"},"longpress":{"pressed":"BCTRLS_DOWN"}},{"gpio": 36,"type": "BUTTON_LOW","pull": true,"long_press": 600,"debounce": 0,"normal": {"pressed": "BCTRLS_PS1"},"longpress":{"pressed":"BCTRLS_LEFT"}},{"gpio": 13,"type": "BUTTON_LOW","pull": true,"long_press": 600,"debounce": 0,"normal": {"pressed": "BCTRLS_PS2"},"longpress":{"pressed":"BCTRLS_RIGHT"}},{"gpio": 19,"type": "BUTTON_LOW","pull": true,"long_press": 600,"debounce": 0,"normal": {"pressed": "BCTRLS_PS3"},"longpress":{"pressed":"KNOB_LEFT"}},{"gpio": 23,"type": "BUTTON_LOW","pull": true,"long_press": 600,"debounce": 0,"normal": {"pressed": "BCTRLS_PS4"},"longpress":{"pressed":"KNOB_RIGHT"}}]

You can put different assignments to these as you'd like. I did it like this so every short press and every long press sends a different event to Home Assistant.

  1. At the bottom of the screen press "Commit" then press "Exit Recovery" and reboot your board.

  2. Then go to Home Assistant and add the "SlimProto Player" OR the Music Assistant 2.0 addon. Give it some time and then it will automagically detect and treat the board like a media_player.

  3. Key presses are (not on MA 2.0) passed to Home Assistant as a slimproto_event. You can use this to set up automations for key presses like so:

alias: Button 1 Short Press
description: ""
trigger:
  - platform: event
    event_type: slimproto_event
    event_data:
      args:
        - button
        - preset_1.single
      entity_id: media_player.squeezelite_00000
condition: []
action:
  - service: media_player.volume_down
    data: {}
    target:
      device_id: 00000000000000
mode: single

ESPHome Variation

The ESP32-A1S Audio kit can function as a media player in ESPhome, **but only using the internal speakers**. Headphone jacks don't seem to output audio. If you've got some little speakers to attach to the JST connectors, this config will work (Thanks to @egwent @ra.jeevan and @hareeshmu for the help with this):
esphome:
  name: esp32-audio-kit
 
esp32:
  board: esp-wrover-kit
  framework:
    type: arduino
 
logger:
api:

ota:
 

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "ssid"
    password: "pass"
 
captive_portal:
i2c:
  sda: GPIO33
  scl: GPIO32
 
external_components:
  - source: github://pr#3552
    components: [es8388]
    refresh: 0s
 
es8388:
media_player:
  - platform: i2s_audio
    name: "ESP32 Audio Kit"
    i2s_lrclk_pin: GPIO25
    i2s_dout_pin: GPIO26
    i2s_bclk_pin: GPIO27
    dac_type: external
    mode: stereo

 
switch:
  - platform: gpio
    pin: GPIO21
    name: "AMP Switch"
    restore_mode: ALWAYS_ON

    
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO39
      inverted: true
      mode:
        input: true
    name: "Jack Status"

  - platform: gpio
    pin:
      number: GPIO036
      inverted: true
    name: "Key 1"
    filters:
      - delayed_off: 10ms

  - platform: gpio
    pin:
      number: GPIO013
      inverted: true
    name: "Key 2"
    filters:
      - delayed_off: 10ms

  - platform: gpio
    pin:
      number: GPIO019
      inverted: true
    name: "Key 3"
    filters:
      - delayed_off: 10ms
      
  - platform: gpio
    pin:
      number: GPIO023
      inverted: true
      mode:
        input: true
        pullup: true
    name: "Key 4"
    filters:
      - delayed_off: 10ms
      
  - platform: gpio
    pin:
      number: GPIO018
      inverted: true
      mode:
        input: true
        pullup: true
    name: "Key 5"
    filters:
      - delayed_off: 10ms
      
  - platform: gpio
    pin:
      number: GPIO005
      inverted: true
      mode:
        input: true
        pullup: true
    name: "Key 6"
    filters:
      - delayed_off: 10ms

light:
  - platform: binary
    name: "Test LED 1"
    output: light_output_1
  - platform: binary
    name: "Test LED 2"
    output: light_output_2
 
output:
  - id: light_output_1
    platform: gpio
    pin: GPIO22
    inverted: true
  - id: light_output_2
    platform: gpio
    pin: GPIO19
    inverted: true

About

This takes an ESP32-A1S Audio Kit and makes a mini-squeezebox player

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors