Atomic Audio-3.5 Base

The following products are supported:

Atomic Audio-3.5 Base

Below is the detailed support for Atomic Audio-3.5 Base on the host:

Controller

Atomic Audio-3.5 Base

Atom Echo

Atom Lite

Atom Matrix

AtomS3

AtomS3 Lite

AtomS3R

AtomS3R-CAM

AtomS3R-Ext

Note

Atomic Audio-3.5 Base uses the same Audio CODEC and pin connections as Atomic Echo Base. For detailed usage instructions, please refer to the Atomic Echo Base documentation.

UiFlow2 Example

Record and play WAV file

Open the atoms3r_aduio_record_play_example.m5f2 project in UiFlow2.

This example initializes Atomic Audio-3.5 Base, records stereo audio to /flash/res/audio/test.wav for 5 seconds after pressing BtnA, and then plays the recorded WAV file.

UiFlow2 Code Block:

atoms3r_aduio_record_play_example.png

Example output:

None

MicroPython Example

Record and play WAV file

This example initializes Atomic Audio-3.5 Base, records stereo audio to /flash/res/audio/test.wav for 5 seconds after pressing BtnA, and then plays the recorded WAV file.

MicroPython Code Block:

  1# SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
  2#
  3# SPDX-License-Identifier: MIT
  4
  5import os, sys, io
  6import M5
  7from M5 import *
  8from hardware import Pin
  9from hardware import I2C
 10from base import AtomicAudio35Base
 11import time
 12
 13
 14label_title = None
 15label_status = None
 16label_tip2 = None
 17label_tip1 = None
 18label_remaining = None
 19i2c0 = None
 20base_audio35 = None
 21record = None
 22playing = None
 23reaming = None
 24RECORD_TIME_MS = None
 25play_start_time = None
 26
 27
 28def btna_was_click_event(state):
 29    global label_title, label_status, label_tip2, label_tip1, label_remaining, i2c0, base_audio35, record, playing, reaming, RECORD_TIME_MS, play_start_time
 30    record = True
 31
 32
 33def setup():
 34    global label_title, label_status, label_tip2, label_tip1, label_remaining, i2c0, base_audio35, record, playing, reaming, RECORD_TIME_MS, play_start_time
 35
 36    M5.begin()
 37    Widgets.fillScreen(0x000000)
 38    label_title = Widgets.Label("Audio", 36, 4, 1.0, 0x18c3df, 0x000000, Widgets.FONTS.DejaVu18)
 39    label_status = Widgets.Label("--", 57, 30, 1.0, 0xffffff, 0x000000, Widgets.FONTS.DejaVu18)
 40    label_tip2 = Widgets.Label("start record", 8, 104, 1.0, 0xffffff, 0x000000, Widgets.FONTS.DejaVu18)
 41    label_tip1 = Widgets.Label("press screen", 5, 82, 1.0, 0xffffff, 0x000000, Widgets.FONTS.DejaVu18)
 42    label_remaining = Widgets.Label("-", 59, 54, 1.0, 0xffffff, 0x000000, Widgets.FONTS.DejaVu24)
 43
 44    BtnA.setCallback(type=BtnA.CB_TYPE.WAS_CLICKED, cb=btna_was_click_event)
 45
 46    i2c0 = I2C(0, scl=Pin(39), sda=Pin(38), freq=400000)
 47    base_audio35 = AtomicAudio35Base(i2c0, 0x18, 1, 16000, 8, 6, 7, 5)
 48    base_audio35.set_volume(60)
 49    base_audio35.tone(888, 100)
 50    record = False
 51    RECORD_TIME_MS = 5000
 52    label_status.setVisible(False)
 53    label_remaining.setVisible(False)
 54
 55
 56def loop():
 57    global label_title, label_status, label_tip2, label_tip1, label_remaining, i2c0, base_audio35, record, playing, reaming, RECORD_TIME_MS, play_start_time
 58    M5.update()
 59    if record:
 60        record = False
 61        time.sleep_ms(200)
 62        label_status.setVisible(True)
 63        label_tip1.setVisible(False)
 64        label_tip2.setVisible(False)
 65        label_status.setText(str('Recording...'))
 66        label_status.setColor(0xcc0000, 0x000000)
 67        label_status.setCursor(x=3, y=45)
 68        base_audio35.record_wav_file('/flash/res/audio/test.wav', rate=16000, bits=16, channel=AtomicAudio35Base.STEREO, duration=RECORD_TIME_MS)
 69        label_status.setText(str('Playing...'))
 70        label_status.setColor(0x009900, 0x000000)
 71        label_status.setCursor(x=16, y=27)
 72        play_start_time = time.ticks_ms()
 73        playing = True
 74        label_remaining.setCursor(x=52, y=70)
 75        label_remaining.setVisible(True)
 76        base_audio35.play_wav_file('/flash/res/audio/test.wav')
 77    if playing:
 78        reaming = RECORD_TIME_MS - (time.ticks_diff((time.ticks_ms()), play_start_time))
 79        label_remaining.setText(str(int(reaming / 1000)))
 80        if (time.ticks_diff((time.ticks_ms()), play_start_time)) >= RECORD_TIME_MS:
 81            playing = False
 82            label_remaining.setVisible(False)
 83            label_status.setVisible(False)
 84            label_tip1.setVisible(True)
 85            label_tip2.setVisible(True)
 86
 87
 88if __name__ == "__main__":
 89    try:
 90        setup()
 91        while True:
 92            loop()
 93    except (Exception, KeyboardInterrupt) as e:
 94        try:
 95            from utility import print_error_msg
 96
 97            print_error_msg(e)
 98        except ImportError:
 99            print("please update to latest firmware")
100

Example output:

None

API

class AtomicAudio35Base

base.audio35.AtomicAudio35Base

alias of AtomicEchoBase

AtomicAudio35Base is an alias for AtomicEchoBase. Please refer to the AtomicEchoBase class for detailed documentation.