Sound Sensor

A thin MEMS microphone can be used to detect audio levels and even perform basic FFT functions. You can read the analog voltage corresponding to the audio on analog pin #A4. Note that this is the raw analog audio waveform! When it's silent there will be a reading of ~330 and when loud the audio will read between 0 and 800 or so. Averaging and smoothing must be done to convert this to sound-pressure-level.

The microphone is sensitive to 100 Hz - 10,000 Hz audio frequencies. See the datasheet for more details.

Library Reference

You can read the raw analog value from the amplified microphone with CircuitPlayground.soundSensor() this will give you just a value from between -1023 and 1023 where the default 'quiet' reading is 0. However, we don't really recommend using this, because its slow and gives you only a single point.

Chances are you want to measure overall volume. In which case, call CircuitPlayground.mic.SoundPressureLevel(time) to get a "Sound Pressure Level" in dB. This will range from maybe ~50 dB (quiet) to 100dB (loud!) The time argument should be number of milliseconds to listen before performing the calculations, 10 is a good place to start.

If you do need a lot of audio values, you can call CircuitPlayground.mic.capture(int16_t *buf, uint16_t nSamples) with a pre-allocated array of int16_t's and the number of samples to capture, this is if you want to get raw values only. On AVR Circuit Classic you'll sample at 10KHz, on Express its 22KHz

Last updated on 2018-01-21 at 07.26.06 PM Published on 2016-07-19 at 08.31.23 PM