UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

Microphone Class

Module: mic

This module defines the Analog Microphone sensor
mic.jpg

Methods

Microphone

(
  • micPin
)
Number

Instantiates a Microphone object

Parameters:

  • micPin Number

    Pin where the microphone is connected

Returns:

Number:

getSampledWindow

(
  • freqMS
  • numberOfSamples
  • buffer
)
Number

Gets samples from the microphone according to the provided window and number of samples

Parameters:

  • freqMS Number

    Time between each sample (in microseconds)

  • numberOfSamples Number

    Number of sample to sample for this window

  • buffer Uint16_t *

    Buffer with sampled data

Returns:

Number:

findThreshold

(
  • ctx
  • threshold
  • buffer
  • len
)
Number

Given the sampled buffer, this method returns TRUE/FALSE if threshold is reached

Parameters:

  • ctx ThresholdContext *

    Threshold context

  • threshold Number

    Sample threshold

  • buffer Uint16_t *

    Buffer with samples

  • len Number

    Buffer length

Returns:

Number:

printGraph

(
  • ctx
)

Prints a running average of the threshold context

Parameters:

  • ctx ThresholdContext *

    Threshold context