SparkFun gator:microphone Hookup Guide
Introduction
Do you have an audio based science experiment?
The gator:microphone is a small board that combines a microphone and some processing circuitry. It provides not only an audio output, but also a binary indication of the presence of sound, and an analog representation of it's amplitude.
Required Materials
To get started, you'll need a micro:bit to control everything. Each of the products below includes a micro:bit, but the kit and bundle also include some additional accessories that you may want as well.
To easily use the gator board ecosystem, a gator:bit (v2) will help breakout the necessary pins and you will also need alligator and/or banana cables to connect the gator:bit to the gator:microphone.
(*These banana cables have a special diameter on the attachment points designed specifically for use with the micro:bit ecosystem. They may or may not be compatible with the banana cables used on your test equipment.)
You may already have some of these materials, so feel free to modify your cart as necessary.
Suggested Reading
The gator:microphone is pretty straight forward to use in application. However, you may find the following concepts useful along the way.
Sound Detector Hookup Guide
Electret Mic Breakout Board Hookup Guide
Qwiic 12-Bit ADC Hookup Guide
If you aren't familiar with the micro:bit, we recommend reading here for an overview.
We would also recommend taking a look at the following tutorials if you aren't familiar with them.
Getting Started with the micro:bit
Getting Started with MicroPython and the SparkFun Inventor's Kit for micro:bit
How to Load MicroPython on a Microcontroller Board
SparkFun gator:bit v2 Hookup Guide
Hardware Overview
The gator:microphone consists of 4 pads for power and data. Additionally, there is a switch switch on the board to select different audio amplification levels; however, we will cover that in later.
Contacts | Direction | Description |
---|---|---|
GND | N/A | Ground: Reference voltage and ground loop. |
3.3V | In | Power: Provides 3.3V to sensor. |
SDA | Bi-directional | Data: Data and commands are transmitted between the sensor and microcontroller. |
SCL | In | Clock: The microcontroller provides the timing needed to communicate on the data line. |
Power
The specified operating voltage for the VEML6070 is between 2.7V - 5.5V. For use with the gator:bit (v2) and micro:bit, you should provide 3.3V through the 3V3 and GND pads to keep the logic levels consistent.
Electret Microphone
An electret microphone is a capacitor based microphone similar to the ones found in phones or headsets. For the most part, users will only need to know that this is used to convert sound into an electrical signal (audio signal).
Here are some of the characteristics of the electret microphone from the datasheet:
Characteristic | Range |
---|---|
Operating Voltage | 1.5V (Max 10V) |
Supply Current | 0.3 mA (Max) |
Directivity | Omnidirectional |
Frequency Response | 20 to 16,000 Hz |
What is Sound?
Sound is pretty self explanatory if you can sense it. Physically, sound is most commonly described as a wave of pressure that propagates through a medium (solid, liquid, or gas... sound can't move through a vacuum). The field of science involving the generation, propagation and reception of these waves (and vibrations) is acoustics. There are many characteristics and factors to sound waves along with various applications and methods of manipulation.
Sound frequency and intensity range for the the threshold of human hearing. Click to enlarge. [Source: Elementary Physics I - PY105 Notes: Sound; Boston University]
A graph correlating sound intensity and perceived loudness. Click to enlarge. [Source: The Scientist and Engineer's Guide to Digital Signal Processing]
Humans perceive sound through their ears. The frequency range of human hearing is approximately 20 to 20,000 Hz. Humans can detect sound intensities from 10-12 W/m2 to 1 W/m2; scaled to 0 - 120 in decibels (dB)1. The human threshold for hearing or the smallest discernible sound we can detect, is around 0 phon on the equal-loudness contours (~20 µPa)2.
2. Source: The Scientist and Engineer's Guide to Digital Signal Processing↩
LMV324
The LMV324 is an operational amplifier (op-amp) configured to process the audio signals from the microphone. Op-amps are versatile and among the most widely used electronic components. For the most part, users will only need to know that the LMV324 is configured to provide for three different outputs: the amplified audio signal, the envelope of the audio signal, and a noise gate indicator.
Here are some of the characteristics of the LMV324 op-amp from the datasheet:
Characteristic | Range |
---|---|
Operating Voltage | 2.7V to 5.5V |
Supply Current | approx. 300 to 720 µA |
Below, is an signal capture of the three different outputs from the Sound Detector to illustrate their relation:
What is an Envelope Signal?
An envelope is a curve that essentially outlines the peaks or amplitude of a signal. There are various applications of an envelope in sound engineering. Most commonly this signal is used for preventing audio feedback, synthesizing a sound, or noise reduction in recordings. In the image below, an example of an envelope (yellow trace) of an audio signal as recorded from the Sound Detector, which is operates similarly to the gator:microphone.
Below are some additional resources on the applications of an envelope:
What is a Gate?
A gate is a comparative signal used to detect when the envelope signal passes a certain threshold. A common application is a noise gate, which is used to reduce the static noise of an recording by only passing music if a threshold is exceeded. Additionally, sound effects like the gated reverb, popularized in the 1980s, can also be created using special techniques.
Below are some additional resources on the applications for the gate:
Selectable Gain Switch
This switch is used to select different gains value to amplify the audio signal from the microphone; high, medium, and low. For the most part, users will only need to know that high the higher the amplification (or gain), the more sensitive the gator:microphone will be to audio inputs.
Switch Location | Resistor Value | Gain (Arithmetic) | Gain (Decibel) |
---|---|---|---|
High | 1 MΩ | 1000 | 60 dB |
Medium | 100 kΩ | 100 | 40 dB |
Low | 10 kΩ | 10 | 20 dB |
What is Gain?
Gain is the amplification of an electronic signal. In this instance, this is a voltage gain of the preamplifier from the original microphone electrical signal. In Low, the amplification is 10 times the original microphone voltage. In High, it is 1000 times the original microphone voltage or 100 times the voltage of the Low amplification.
Just like humans, sound can be too loud or soft for the electronics to discern any differences. When the electrical signal is too high, clipping can occur. To fix this the amplification should be lowered to bring the signal under the maximum range that can be measures. A signal is too soft, when the characteristics of the signal are below the resolution that you can measure. To fix this the amplification should be raised to detect those changes.
ADS1015
The ADS1015 is an analog to digital converter (ADC) used for converting analog voltages into a digital values that can be read by a microcontroller. The ADS1015 is used to measure the amplified audio signal, the envelope, and the gate. For the most part, users will only need to know I2C addresses to prevent address conflicts with other devices or sensors.
Here are some of the characteristics of the ADS1015 from the datasheet:
Characteristic | Description |
---|---|
Operating Voltage (VDD) | 2.0V to 5.5V |
Operating Temperature | -40°C to 125°C |
Operation Modes | Single-Shot, Continuous-Conversion (Default), and Duty Cycling |
Analog Inputs |
Measurement Type: Single-Ended (Default) or Differential Input Voltage Range: GND to VDD Full Scale Range (FSR): ±.256V to ±6.114V (Default: 2.048V) |
Resolution |
12-bit (Differential) or 11-bit (Single-Ended) LSB size: 0.125mV - 3mV (Default: 1 mV) |
Sample Rate | 128 Hz to 3.3 kHz (Default: 1600SPS) |
Current Consumption (Typical) | 150μA to 200μA |
I2C Address | 0x48 |
I2C Connection
I2C is a communication protocol used to transfer data between controller and peripheral devices. It is a 2-wire connection consisting of SDA (data) and SCL (clock). The protocol is pretty well defined so it can be shared with multiple devices. This is beneficial for daisy chaining multiple devices together on a single bus. The primary thing users will need to watch out for is address conflicts (you can't have devices with the same address).
Hardware Assembly
Connecting your gator:microphone to the gator:bit (v2) is simple. The board can also be daisy-chained with other I2C boards. This can easily be done with alligator cables or these special banana cables.
gator:microphone | GND | 3V3 | SDA | SCL |
---|---|---|---|---|
gator:bit (v2) | GND | 3.3V OUT | P20 (SDA) | P19 (SCL) |
Adding the MakeCode Extension
- If you have not previously used MakeCode, please check out the Quick Start Guide fro micro:bit.
- If this is your first time using a micro:bit, please review our Getting Started with the micro:bit guide.
- If this is your first time using the gato:bit (v2), please review our SparkFun gator:bit v2 Hookup Guide.
The easiest way to get started using the gator:microphone is to use Microsoft MakeCode, a web-based block editor. This tutorial assumes you are familiar with the with MakeCode, the gato:bit (v2), and the micro:bit development board. If this is your first time check out this guides linked in the suggested reading section (above).
Installing Extensions
To get started with using MakeCode with the miccro:bit, head over to the MakeCode for micro:bit website by Microsoft. Then, click the New Project button to start a new project and open the Editor. (*Yes, all you only need to get start coding is a computer with internet access, an up-to-date web browser, and an available USB port!)
Once you have the editor up, click on the the Advanced
block in the block library to reveal the drop down menu.
Finally, click on the Extensions
block. This should bring up the extensions page. (*Alternatively, you could also click on the extensions link from the settings menu.)
There are two methods for finding the gator:microphone extension:
- Search for the name used on the extension3.
- Use the link to the GitHub repository for the pxt-package as the search term.
Search for the PXT-Package
Search for the gator:microphone extension using the GitHub repository link to the pxt-package:
https://github.com/sparkfun/pxt-gator-microphone
Then, click on the box for the extension to add it to the block library. The gator:microphone extension should now appear in the block library.
To verify that you have added the extension, click on the gator:microphone
block to make sure that your drop down menu options match the image below.
MakeCode Examples
Now that you have added the gator:microphone extension to the Editor, lets start with some example code. Plug the micro:bit into your computer using an USB micro-B cable after you have assembled your hardware with the instructions from the previous section. The micro:bit should appear on your computer as a removable storage device.
To upload new code, this is where you will be copying the downloaded .hex
file to later.
Block Functions
This is a logic block as indicated by the block's shape. The output is either a 1
or 0
to indicate if the gate threshold has been exceeded.
0
- Indicates the threshold has yet to be exceeded.1
- Indicates the threshold has been exceeded.
Get sound intensity
This is a value block as indicated by the block's shape. The output of the block is the envelope of the audio signal.
0
to2047
- An 11-bit value for the envelope of the audio signal from the ADS1015 ADC.
change gain to _____
This block allows users to customize the gain of the ADC (ADS1015), which affects the full-scale range (FSR) for the ADC. There is a drop down menu with selectable options to change the gain value. Below is a list of the available menu options; the table is a description for what the options represent:
two thirds
one
two
- Defaultfour
eight
sixteen
Gain Options: | 16 | 8 | 4 | 2 | 1 | 2/3 |
---|---|---|---|---|---|---|
Resolution (LSB): | 0.125 mV | 0.25 mV | 0.5 mV | 1 mV | 2 mV | 3 mV |
FSR (12-bit): | ±256 mV | ±512 mV | ±1.024 V | ±2.048 V | ±4.048 V | ±6.144 V |
For more details on the gain functionality of ADS1015 ADC, check out the Hardware Overview section of the Qwiic 12-bit ADC Hookup Guide.
Basic Read
Below, is a simple example of how to take simple measurements from the sensor. To use this example, there are multiple options for accessing the .hex
file:
- Replicate the block functions from the display below to copy the example project. Then download the
.hex
file. - Expand the display widow to pull up the example project. Then download the
.hex
file. - Use this link to pull up the example project. Then download the
.hex
file. Download the
.hex
file from the button below or the link on the bottom of the display.
The output is redirected over the serial port to avoid conflicts on pins P0
and P1
, which are also used for serial communication. To read the sensor values, pull up your favorite serial terminal emulator. Then, connect to the serial port that the micro:bit is on; the default baud rate is 115200 bps. Below, is an example of the sensor output for the example code.
Troubleshooting the Extension
This product's extension has a dependency on Microsoft's build process. If the usual method of installing the MakeCode extension gives an error, you will need to manually install the MakeCode extension. We have provided a local build of this extension that can be uploaded to MakeCode:
To manually install this extension in makecode, go to the "Extensions" tab on the left side of the makecode site:
In the location you'd normally search for an extension, you'll notice an upload button on the right:
Click on this, and you'll get a window allowing you to upload your own built extension. Navigate to where you saved the above extension hex, and upload it to your project.
You should be able to see the extension and its functions now. In addition, you'll be able to build and download your project to your variant of micro:bit.
Other Troubleshooting Tips
Here are a few tips for troubleshooting this device.
Noise from Power Supply
If you are experiencing relatively erratic measurements from the gator:microphone, it could be due to noise from your power supply. Double check that the power supply is clean, preferably with an oscilloscope; irregularities on the supply can be passed on to the outputs.
- Switch-mode power supplies often introduce oscillations in the power rails.
If you still have questions or issues with this product, please create a post on our forum under the Gator Products topic.
Additionally, if you are an educator and you have class or application based questions, please create a post on our forum under the Educational Products topic.
Resources and Going Further
For more product information, check out the resources below:
- Schematic (PDF)
- Eagle Files (ZIP)
- Electret Microphone Datasheet (PDF)
- LVM324 Datasheet (PDF)
- ADS1015 Datasheet (PDF)
- gator:microphone PXT Package
- GitHub Product Repo
- micro:bit Landing Page
- SFE Product Showcase
Interested in the micro:bit? Check out some of these other micro:bit products:
Need some inspiration for your next project? Check out some of these other micro:bit product tutorials: