Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. kmeyer
    K
    • Continue chat with kmeyer
    • Start new chat with kmeyer
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    kmeyer

    @kmeyer

    0
    Reputation
    1
    Posts
    151
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    kmeyer Follow

    Posts made by kmeyer

    • RE: How do I access the mic on the m5stickc?

      I was successful in recording something like a wave form with the following code:

      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)
      

      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

      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
      ...
      
      posted in M5 Stick/StickC
      K
      kmeyer