I2S input - what boards support it

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
erlendf
 
Posts: 6
Joined: Tue Dec 17, 2013 3:05 am

I2S input - what boards support it

Post by erlendf »

I want to connect an I2S audio source to the microcontroller. With Feather S2 ESP32 I have got I2S output working, but the Feather does not seem to have support for either hardware I2S input, nor a driver. To test I have the Mems I2S microphone break-out. I prefer using Circuitpython. If required, I would like to buy a more suited microcontroller, but it should also have wi-fi and Circuitpython. I just do not know which board to buy - or if I have to?

User avatar
mikeysklar
 
Posts: 14165
Joined: Mon Aug 01, 2016 8:10 pm

Re: I2S input - what boards support it

Post by mikeysklar »

@erlendf,

Have you tried running the "Where's my PDMIn?" code example on your Feather S2?

https://learn.adafruit.com/adafruit-pdm ... 3038798-11

Code: Select all

import board
import audiobusio
from microcontroller import Pin


def is_hardware_PDM(clock, data):
    try:
        p = audiobusio.PDMIn(clock, data)
        p.deinit()
        return True
    except ValueError:
        return False
    except RuntimeError:
        return True


def get_unique_pins():
    exclude = ['NEOPIXEL', 'APA102_MOSI', 'APA102_SCK']
    pins = [pin for pin in [
        getattr(board, p) for p in dir(board) if p not in exclude]
            if isinstance(pin, Pin)]
    unique = []
    for p in pins:
        if p not in unique:
            unique.append(p)
    return unique


for clock_pin in get_unique_pins():
    for data_pin in get_unique_pins():
        if clock_pin is data_pin:
            continue
        if is_hardware_PDM(clock_pin, data_pin):
            print("Clock pin:", clock_pin, "\t Data pin:", data_pin)
        else:
            pass

User avatar
erlendf
 
Posts: 6
Joined: Tue Dec 17, 2013 3:05 am

Re: I2S input - what boards support it

Post by erlendf »

PDM or I2S - Adafruit says two opposite things:
About the PDM microphone board you say: It's digital but its not PWM and it's not I2S. Then in an other place you say: It's easy to use the Adafruit PDM microphone breakout with CircuitPython, using the built-in audiobusio module and PDMIn class. It allows you to record an input audio signal from the microphone using I2S. Then, about the I2S microphone board you say: , you will often find an I2S peripheral, that can take digital audio data in! That's where this I2S Microphone Breakout comes in.
I am confused; I thought PDM was a raw pulse coded format, whereas I2S is a digital protocol - and that the two have nothing to do with each other. With the I2S microphone breakout do I not simply need the microcontroller to read the I2S protocol as an input? Does anybody know of a microcontroller that does this?

User avatar
erlendf
 
Posts: 6
Joined: Tue Dec 17, 2013 3:05 am

Re: I2S input - what boards support it

Post by erlendf »

@mikeysklar, thank you for your reply, but as I am describing in my latest post it is not PDM I want, but I2S.

User avatar
mikeysklar
 
Posts: 14165
Joined: Mon Aug 01, 2016 8:10 pm

Re: I2S input - what boards support it

Post by mikeysklar »

@erlendf,

At this time with CircuitPython the only support I see is for I2SOut and PDMIn. This is why I suggested running the PDMIn code. In our docs we still consider PDMIn to be recording over I2S.

https://circuitpython.readthedocs.io/en ... hlight=i2s

There is some example code to discover usable I2S output pins, but nothing for I2S input.

https://learn.adafruit.com/adafruit-max ... iring-test

Code: Select all

import board
import audiobusio
from microcontroller import Pin


def is_hardware_i2s(bit_clock, word_select, data):
    try:
        p = audiobusio.I2SOut(bit_clock, word_select, data)
        p.deinit()
        return True
    except ValueError:
        return False


def get_unique_pins():
    exclude = ['NEOPIXEL', 'APA102_MOSI', 'APA102_SCK']
    pins = [pin for pin in [
        getattr(board, p) for p in dir(board) if p not in exclude]
            if isinstance(pin, Pin)]
    unique = []
    for p in pins:
        if p not in unique:
            unique.append(p)
    return unique


for bit_clock_pin in get_unique_pins():
    for word_select_pin in get_unique_pins():
        for data_pin in get_unique_pins():
            if bit_clock_pin is word_select_pin or bit_clock_pin is data_pin or word_select_pin\
                    is data_pin:
                continue
            if is_hardware_i2s(bit_clock_pin, word_select_pin, data_pin):
                print("Bit clock pin:", bit_clock_pin, "\t Word select pin:", word_select_pin,
                      "\t Data pin:", data_pin)
            else:
                pass

User avatar
erlendf
 
Posts: 6
Joined: Tue Dec 17, 2013 3:05 am

Re: I2S input - what boards support it

Post by erlendf »

Thanks, but it makes me wonder what the Adafruit I2S MEMS Mic breakout is for? It specifically says that it is not PDM, but I2S.

Regards,
Erlend

User avatar
mikeysklar
 
Posts: 14165
Joined: Mon Aug 01, 2016 8:10 pm

Re: I2S input - what boards support it

Post by mikeysklar »


User avatar
erlendf
 
Posts: 6
Joined: Tue Dec 17, 2013 3:05 am

Re: I2S input - what boards support it

Post by erlendf »

@mikeysklar, thank you for your reply. I will put the I2S ambition to rest for now, then - until someday there will be CircuitPython support for it. Instead I will connect my Feather M4 to a separate audio recorder/player with it's own Flash, codec, and uC. The benefit is also that the audio work will not bog down the M4. I intend to test out a board callled SOMO II for this purpose, because the codec from Ada would unfortunately need the M4 to do the processing.

My application needs to play audio from a range of short soundbites, as well as be able to record 1 soundbite of max 15sec, that can be replayed later.

Thanks for clarifying the I2S stuff,
Erlend

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”