This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Microphone/Arduino Shield example for the nrf9160?

I'd like to build a prototype using the nrf9160DK that samples audio from a microphone and plays it back. Given that the dev board has Arduino compatible headers, I'm assuming the easiest thing to do is get a shield like this one

If so, I'm looking for any sample code that shows how best to interact with an Arduino shield using the nrf SDK. Obviously a microphone example would be preferred, but I'm looking fo any arduinio shield examples as they will likely show the way.

Thank you

  • Actually, doing further research indicates that that previous shield was a bit over kill. A much simpler microphone (there are many) just produces an analog out that can go into one of the Arduino pins. If I use that approach, I just need the nrf9160 code example to read the analog pin. It'll be my job to stash it away.

  • Hi,

     

    You could use the PDM peripheral as well, as there's many digital microphones that use this bus as well.

    In order to use the SAADC peripheral to perform ad conversions in nrf connect sdk, there's a process that needs to be performed first:

    1. Add the SAADC peripheral to the non-secure region:

    After this line: https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/samples/nrf9160/secure_boot/src/main.c#L336

    you must append:

    Fullscreen
    1
    2
    secure_boot_config_peripheral(
    NRFX_PERIPHERAL_ID_GET(NRF_SAADC_S), 0);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Then build and flash this onto the device.

    2a. Adding the SAADC to the project requires a nrf9160_pca10090.overlay file to hold:

    Fullscreen
    1
    2
    3
    4
    5
    &adc {
    · · status = "ok";
    };
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    2b. Then you need to add the ADC driver itself to the project in "prj.conf":

    Fullscreen
    1
    2
    3
    CONFIG_ADC=y
    CONFIG_ADC_0=y
    CONFIG_ADC_NRFX_SAADC=y
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

     

    Now, you can add the functions needed for using the ADC in your example. I made an example here to show what's needed:

    https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/adc/src/main.c

     

    Kind regards,

    Håkon

  • Love the sample!  Is it possible to see a sample that uses more of the SAADC facility of the nRF91?  If possible I'd like to see an example that uses the task feature to take a sample on a timer event and then easyDMA to publish the result to RAM.  It could be that the sample code is already doing some of that, but it's hidden in the enums or something.

  • Hi,

     

    I think this is the one you're looking for?

    https://github.com/NordicPlayground/fw-nrfconnect-zephyr/blob/master/include/adc.h#L188

    The ADC API in zephyr might not satisfy your requirements, and if that is the case, I'd recommend that you include nrf_saadc.h directly and communicate with that API to override or expose the deeper level functions as a workaround for now. We are looking into exposing all the functionality of our drivers/peripherals in the ncs code base, but it takes a bit of time until we know how to approaching this in the best possible way.

     

    Kind regards,

    Håkon

  • Thanks Hakon, we'll check this out! Much appreciated

1 2