Skip to content

Feature/cores3 mic#1552

Closed
meganetaaan wants to merge 4 commits intoModdable-OpenSource:publicfrom
meganetaaan:feature/cores3-mic
Closed

Feature/cores3 mic#1552
meganetaaan wants to merge 4 commits intoModdable-OpenSource:publicfrom
meganetaaan:feature/cores3-mic

Conversation

@meganetaaan
Copy link
Contributor

This is a draft PR to add microphone support for M5Stack CoreS3

  • Add microphone (ES7210 audio ADC) configuration for M5Stack CoreS3 setup-target sequence
  • Extend AudioIn class to support stereo input, I2S Philips format, and MCK pin configuration required by ES7210
    • All new settings have default values, ensuring backward compatibility with other targets
  • ES7210 initialization and I2S settings for M5Stack CoreS3 are based on the https://github.com/m5stack/M5Unified

Changes

M5Stack CoreS3 Target

  • Update manifest.json audio input settings:
    • Change from PDM to I2S standard format
    • Set sample rate to 16000 Hz
    • Enable stereo (2 channels) with I2S_STD_SLOT_BOTH
    • Add MCK pin configuration (pin 0)

ES7210 Driver (setup-target.js)

  • Add ES7210 class for microphone initialization
  • Configure microphone gain, HPF, and power settings
  • Enable AXP2101 ADC for voltage measurement

Audio Input Module (modules/io/audioin/esp32/audioin.c and modules/pins/audioin/esp32/audioin.c)

  • Add MODDEF_AUDIOIN_I2S_MCK_PIN for master clock pin support (default: I2S_GPIO_UNUSED)
  • Add MODDEF_AUDIOIN_I2S_FORMAT_I2S for I2S Philips format selection (default: 0)
  • Add MODDEF_AUDIOIN_NUMCHANNELS for mono/stereo configuration (default: 1)
  • Add MODDEF_AUDIOIN_I2S_SLOT for flexible slot selection (default: I2S_STD_SLOT_RIGHT)

@phoddie
Copy link
Collaborator

phoddie commented Jan 5, 2026

The changes look good.

One suggestion. It is relatively expensive to convert from stereo to mono in JavaScript. An alternative would be for the audio input class to accept the channels argument on its constructor so that it could perform the conversion before passing the samples to the JavaScript callback. We can merge this PR without that support. But if you'd like to add it to this PR, please let us know.

@meganetaaan meganetaaan marked this pull request as ready for review January 5, 2026 14:05
@meganetaaan
Copy link
Contributor Author

Thanks for the suggestion.

I found that simply using channels: 1 is sufficient in our case. AudioIn already implements stereo→mono conversion (it takes the L channel), so there’s no need for JS-side mixing. When I want stereo, channels: 2 already gives me stereo samples, which is good enough so far.
Based on this, I reverted the JS conversion in capture-sync and just set channels: 1.

@phoddie
Copy link
Collaborator

phoddie commented Jan 5, 2026

@meganetaaan – thank you for making the change. Setting channels in the invocation of the constructor clearly expresses the requirement of the app for the samples to be a single channel.

@mkellner
Copy link
Collaborator

mkellner commented Jan 5, 2026

This change has been merged and will be available in the next release.

@mkellner mkellner closed this Jan 5, 2026
mkellner pushed a commit that referenced this pull request Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants