<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How do I access the mic on the m5stickc?]]></title><description><![CDATA[<p dir="auto">The posts are very confusing! Half say that it is i2s, and the Arduino code seems to support that. But the other half say that it is just an adc on port 34, and the micropython examples seem to support that!<br />
I'm interested in using micropython.</p>
]]></description><link>https://community.m5stack.com/topic/3668/how-do-i-access-the-mic-on-the-m5stickc</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 21:00:11 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/3668.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 22 Oct 2021 03:23:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How do I access the mic on the m5stickc? on Sat, 31 Dec 2022 10:26:53 GMT]]></title><description><![CDATA[<p dir="auto">I was successful in recording something like a wave form with the following code:</p>
<pre><code class="language-python">from machine import I2S, Pin
import array

mic = I2S(I2S.NUM0, ws=Pin(0), sdin=Pin(34), mode=I2S.MASTER_PDM, dataformat=I2S.B16, channelformat=I2S.ONLY_RIGHT, samplerate=16000, dmacount=16, dmalen=256)

b2 = array.array("h", 4096 * [0])
mic.readinto(b2)
</code></pre>
<p dir="auto">However, there seems to be a systematic offset around ~+1000. Not sure what is going on here. Could it be related to PDM encoding and the I2S clock? Also, I experience values that are larger than the 12bit precision documented somewere</p>
<pre><code>def eval():
    mic.readinto(b2)
    print(min(b2), max(b2), sum(b2)/len(b2))

for i in range(1000): eval()
... 
48 1963 1017.062
811 1237 1027.727
927 1122 1021.952
849 1286 1023.281
763 1719 1029.73
102 1966 1015.185
-903 2878 1012.832
-788 2683 984.9133
-1524 2761 982.3828
-815 3075 986.0596
-864 3044 980.6567
-713 2904 993.0678
-669 2615 1014.595
-138 2182 1022.794
-73 1954 1018.482
...
</code></pre>
]]></description><link>https://community.m5stack.com/post/19722</link><guid isPermaLink="true">https://community.m5stack.com/post/19722</guid><dc:creator><![CDATA[kmeyer]]></dc:creator><pubDate>Sat, 31 Dec 2022 10:26:53 GMT</pubDate></item><item><title><![CDATA[Reply to How do I access the mic on the m5stickc? on Sat, 23 Oct 2021 16:36:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/robalstona" aria-label="Profile: robalstona">@<bdi>robalstona</bdi></a> pin 0 is the clock, not ws, according to the sticker on the back. Don't know if that helps.</p>
]]></description><link>https://community.m5stack.com/post/15220</link><guid isPermaLink="true">https://community.m5stack.com/post/15220</guid><dc:creator><![CDATA[dclaar]]></dc:creator><pubDate>Sat, 23 Oct 2021 16:36:17 GMT</pubDate></item><item><title><![CDATA[Reply to How do I access the mic on the m5stickc? on Sat, 23 Oct 2021 09:22:00 GMT]]></title><description><![CDATA[<p dir="auto">Hi is spent a long time to find how use PDM microphone in m5stickC and finally i pass. I find some code thats should work, but its not working.</p>
<pre><code>from machine import I2S, Pin

mic = I2S(I2S.NUM0, ws=Pin(0), sdin=Pin(34), mode=I2S.MASTER_PDW, dataformat=I2S.B16, channelformat=I2S.ONLY_RIGHT, samplerate=16000, dmacount=16, dmalen=256)

buffer = bytearray(7168)

while True:
    # read data into buffer
    mic.readinto(buffer)
    # do something with data stored in buffer
    #
mic.deinit()
</code></pre>
]]></description><link>https://community.m5stack.com/post/15215</link><guid isPermaLink="true">https://community.m5stack.com/post/15215</guid><dc:creator><![CDATA[robalstona]]></dc:creator><pubDate>Sat, 23 Oct 2021 09:22:00 GMT</pubDate></item><item><title><![CDATA[Reply to How do I access the mic on the m5stickc? on Fri, 22 Oct 2021 18:54:29 GMT]]></title><description><![CDATA[<p dir="auto">Thinking about how to test it: the M5StickC has no speaker.<br />
OK, I have the Core Gray: It has a speaker! But no mic.<br />
Maybe I could hook both of them together...<br />
This is getting way too complicated for the idea I had in mind, which was some responsive blinky lights for Halloween. (Yes, it's next week. Your point?) :) I think I'll use the accelerometer instead.</p>
]]></description><link>https://community.m5stack.com/post/15209</link><guid isPermaLink="true">https://community.m5stack.com/post/15209</guid><dc:creator><![CDATA[dclaar]]></dc:creator><pubDate>Fri, 22 Oct 2021 18:54:29 GMT</pubDate></item><item><title><![CDATA[Reply to How do I access the mic on the m5stickc? on Fri, 22 Oct 2021 15:54:53 GMT]]></title><description><![CDATA[<p dir="auto">Thanks! Going off that, I found <a href="https://community.m5stack.com/topic/991/knock-detector-with-microphone-m5stickc/7">this post</a>, which points to the <a href="https://github.com/m5stack/M5GO/blob/master/M5GO.py" target="_blank" rel="noopener noreferrer nofollow ugc">M5GO blob</a>, which has</p>
<pre><code>from machine import I2S
</code></pre>
<p dir="auto">Going into REPL:</p>
<pre><code> from machine import I2S
&gt;&gt;&gt; dir(I2S)
['__class__', '__name__', 'read', 'start', 'stop', 'write', '__bases__', '__dict__', 'CHANNEL_ALL_LEFT', 'CHANNEL_ALL_RIGHT', 'CHANNEL_ONLY_LEFT', 'CHANNEL_ONLY_RIGHT', 'CHANNEL_RIGHT_LEFT', 'DAC_BOTH_EN', 'DAC_DISABLE', 'DAC_LEFT_EN', 'DAC_RIGHT_EN', 'FORMAT_I2S', 'FORMAT_I2S_LSB', 'FORMAT_I2S_MSB', 'FORMAT_PCM', 'FORMAT_PCM_LONG', 'FORMAT_PCM_SHORT', 'I2S_NUM_0', 'I2S_NUM_1', 'MODE_ADC_BUILT_IN', 'MODE_DAC_BUILT_IN', 'MODE_MASTER', 'MODE_PDM', 'MODE_RX', 'MODE_SLAVE', 'MODE_TX', 'adc_enable', 'bits', 'deinit', 'init', 'nchannels', 'sample_rate', 'set_adc_pin', 'set_dac_mode', 'set_pin', 'volume']
&gt;&gt;&gt; import wave
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
ImportError: no module named 'wave'
</code></pre>
<p dir="auto">So at least part of it is there! I found a listing of the <a href="https://lang-ship.com/reference/unofficial/M5StickC_UIFlow/all/#class-machinei2s" target="_blank" rel="noopener noreferrer nofollow ugc">class</a>, but no documentation.</p>
<p dir="auto">Then I found <a href="https://github.com/miketeachman/micropython-i2s-examples" target="_blank" rel="noopener noreferrer nofollow ugc">some examples</a>, but they say Micropython after June 2021, so may not apply??</p>
<p dir="auto">That talks about a "WS" pin, which I found described <a href="https://www.sparkfun.com/datasheets/BreakoutBoards/I2SBUS.pdf" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>.</p>
<p dir="auto">The <a href="https://docs.m5stack.com/en/core/m5stickc" target="_blank" rel="noopener noreferrer nofollow ugc">schematic</a> shows only 2 pins however: SCL &amp; SDA. The <a href="https://docs.m5stack.com/en/unit/pdm" target="_blank" rel="noopener noreferrer nofollow ugc">Unit unit :)</a> appears to have WS tied to ground. <a href="https://www.mouser.com/datasheet/2/218/SPM1423HM4H-B-876897.pdf" target="_blank" rel="noopener noreferrer nofollow ugc">Mouser</a> indicates that the pin is tied low internally, and that is the left channel, but the <a href="https://github.com/m5stack/M5StickC/blob/master/examples/Basics/Micophone/Micophone.ino" target="_blank" rel="noopener noreferrer nofollow ugc">arduino code</a> sets it to I2S_CHANNEL_FMT_ALL_RIGHT.<br />
Here's an <a href="https://diyi0t.com/i2s-sound-tutorial-for-esp32/" target="_blank" rel="noopener noreferrer nofollow ugc">I2S tutorial</a>.<br />
So, time to play I guess!</p>
]]></description><link>https://community.m5stack.com/post/15208</link><guid isPermaLink="true">https://community.m5stack.com/post/15208</guid><dc:creator><![CDATA[dclaar]]></dc:creator><pubDate>Fri, 22 Oct 2021 15:54:53 GMT</pubDate></item><item><title><![CDATA[Reply to How do I access the mic on the m5stickc? on Fri, 22 Oct 2021 06:09:23 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/dclaar" aria-label="Profile: dclaar">@<bdi>dclaar</bdi></a></p>
<p dir="auto">looking at the <a href="https://docs.m5stack.com/en/core/m5stickc" target="_blank" rel="noopener noreferrer nofollow ugc">specifications</a> for M5StickC the microphone is listed as SPM1423. Search results for SPM1423 indicate that it is has a PDM encoding output (CLK/DAT) which seems to be a special I2S case.</p>
<p dir="auto">I have found this <a href="https://github.com/lemariva/micropython-i2s-driver" target="_blank" rel="noopener noreferrer nofollow ugc">github project</a>, which add the I2S-PDM mode to micropython.</p>
<p dir="auto"><a href="https://tomverbeure.github.io/2020/10/04/PDM-Microphones-and-Sigma-Delta-Conversion.html" target="_blank" rel="noopener noreferrer nofollow ugc">Here</a> you can find a description of the differences between I2S and PDM.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/15198</link><guid isPermaLink="true">https://community.m5stack.com/post/15198</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Fri, 22 Oct 2021 06:09:23 GMT</pubDate></item></channel></rss>