A nightstand noise generator based on M5Stack Atom Echo and integrating with Home Assistant
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Audio signal chain#

Why we chose an I2S amp#

The ESP32 on the Atom Echo outputs digital I2S — a three-wire serial protocol carrying PCM samples as ones and zeros. No raw speaker or analog amp can play I2S; it has to be decoded first.

Two architectures were on the table:

Path Chain Parts
I2S amp (chosen) ESP32 → I2S amp → speaker MAX98357A
Analog amp ESP32 → I2S DAC → analog amp → speaker PCM5102A + PAM8302

Both work. The I2S-amp path is shorter, uses one fewer board, has fewer wires, less noise surface, smaller enclosure footprint, and simpler ESPHome config. We're going with it.

The onboard NS4168 on the Atom Echo is itself an I2S amp — the MAX98357A is in the same category, just better-suited because we can put it outside the thermally-constrained Atom Echo case and drive a properly-sized speaker.

Full signal chain#

  Atom Echo (ESP32-PICO-D4)
          │
          │  digital I2S: BCLK + LRCK + DOUT
          │  (on unused GPIOs — G21, G26, G32)
          ▼
     MAX98357A
     (I2S in, Class D amp out)
          │
          │  bridge-tied speaker output (V+ / V−)
          │  no common ground to the speaker
          ▼
  GRS 3FR-4 (4Ω 25W max)

MAX98357A specs#

  • Input: I2S (BCLK + LRCK + DIN)
  • Output: bridge-tied load, 3.2 W into 4Ω at 5V supply (matches our driver exactly)
  • Gain: configurable via GAIN pin — 3 / 6 / 9 / 12 / 15 dB. Floating = 9 dB default, which is fine for our volumes.
  • Channel select (SD pin):
    • Float = both L+R channels summed (mono mix) — our default
    • Tied low = shutdown
    • Tied with specific voltage dividers = left-only or right-only
  • Supply: 2.5–5.5 V (we use 5 V)
  • Package: on a ~21×16 mm breakout board (Adafruit 3006 variant; generic Chinese boards are similar size)

Wiring detail#

Atom Echo → MAX98357A#

Atom Echo pin MAX98357A pin Notes
5V VIN side header or GROVE red
GND GND
G26 (GROVE yellow) BCLK bit clock
G32 (GROVE white) LRC word select (LRCK)
G25 (side header) DIN I2S serial data — only safely-available external GPIO (G19/G22/G23/G33 are reserved for the onboard NS4168, G27 is the RGB LED, G39 is the button)
SD leave floating = mono (L+R summed)
GAIN leave floating = 9 dB default

MAX98357A → speaker#

MAX98357A Speaker
OUT+ speaker +
OUT− speaker −

Bridge-tied load — don't ground either speaker terminal. Both speaker wires go to the amp, nowhere else.

Power#

  • Atom Echo powered via USB-C from a 5V 2A UL-listed wall adapter
  • MAX98357A taps 5V + GND from the Atom Echo's side header
  • Total estimated draw: Atom Echo ~0.3 A + MAX98357A at typical volume ~0.2 A ≈ 0.5 A. Well within a 2 A supply.

Volume control#

The MAX98357A has no onboard potentiometer — gain is fixed by the GAIN pin configuration. Volume comes from two places:

  1. GAIN pin — set once at build time. Floating (9 dB) is the default and fine. If we find it's too loud at full software volume, pull GAIN to ground through a 100 kΩ resistor for 3 dB, or to VIN for 15 dB. We'll tune if needed.
  2. ESPHome software volume (via HA) — fine-grained runtime control.

ESPHome config sketch#

i2s_audio:
  - id: i2sout
    i2s_lrclk_pin: GPIO32
    i2s_bclk_pin: GPIO26

speaker:
  - platform: i2s_audio
    id: echo_speaker
    i2s_dout_pin: GPIO21
    dac_type: external
    mode: mono

Critically, we do not configure the speaker: block against the onboard NS4168 pins (G19/G22/G33). That leaves the onboard amp receiving no I2S data — idle, silent, cool.

Pin availability recap#

Free GPIOs on the Atom Echo after accounting for mic / amp / LED / button:

  • G26 (GROVE yellow) → I2S BCLK
  • G32 (GROVE white) → I2S LRC
  • G25 (side header) → I2S DIN

Parts list for this chain (per unit)#

Part Source Notes
M5Stack Atom Echo owned
MAX98357A breakout Adafruit 3006 ($6) or generic Amazon/AliExpress ($3) need 2 total for both units
GRS 3FR-4 speaker owned see reference/speakers/grs-3fr-4.md
5V 2A USB wall adapter + USB-C cable off-the-shelf UL-listed brick
Dupont wires / hookup wire stock

Sources#