SparkFun gator:microphone Hookup Guide

Pages
Contributors: santaimpersonator, Englandsaurus
Favorited Favorite 2

Introduction

Do you have an audio based science experiment?

SparkFun gator:microphone - micro:bit Accessory Board

SEN-15289
Retired

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.

micro:bit Board

DEV-14208
10 Retired

micro:bit Go Bundle

DEV-14336
18 Retired

SparkFun Inventor's Kit for micro:bit

KIT-15228
2 Retired

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.

Alligator Test Leads - Multicolored (10 Pack)

Alligator Test Leads - Multicolored (10 Pack)

PRT-12978
$3.50
4
Banana to Banana Cable - Right Angle

Banana to Banana Cable - Right Angle

CAB-15368
$4.95 $4.46
1

SparkFun gator:bit v2.0 - micro:bit Carrier Board

DEV-15162
2 Retired

(*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.

Logic Levels

Learn the difference between 3.3V and 5V devices and logic levels.

I2C

An introduction to I2C, one of the main embedded communications protocols in use today.

Sound Detector Hookup Guide

The Sound Detector is a microphone with a binary output. This guide explains how it works and how you can use it in your projects.

Electret Mic Breakout Board Hookup Guide

An introduction to working with the Electret Mic Breakout Board.

Qwiic 12-Bit ADC Hookup Guide

Need to add more analog inputs for your project? Check out the Qwiic 12-bit ADC.

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

The BBC micro:bit is a compact, powerful programming tool that requires no software installation. Read on to learn how to use it YOUR way!

How to Load MicroPython on a Microcontroller Board

This tutorial will show you how to load the MicroPython interpreter onto a variety of development boards.

SparkFun gator:bit v2 Hookup Guide

The gator:bit v2 is a breakout board for the BBC micro:bit. The gator:bit exposes almost every pin on the micro:bit to clippable pad with circuit protection. It also has as built-in addressable LEDs and a built-in buzzer.

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.

Power Connections and LED
Power connection pads and power indication LED.

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).

Electret Microphone
Electret microphone.

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.

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.

LMV324
LMV324 operational amplifier.

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:

Signal Capture
Green- Amplified Audio Signal. Yellow- Envelope Signal. Red- Gate Signal.
Example of signal capture from the Sound Detector.

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.

Gain Switch
Gain switch with three levels: high, medium, and low.

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.

ADS1015
ADS1015 analog to digital converter.

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).

I2C Connection
I2C connection pads.

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.

Hardware Assembly
Hardware assembly of connections used in example. Click to enlarge.
Daisy Chain
Example of daisy chaining multiple I2C gator boards. Click to enlarge.
gator:microphone GND 3V3 SDA SCL
gator:bit (v2) GND 3.3V OUT P20 (SDA) P19 (SCL)

Adding the MakeCode Extension

Note: This tutorial assumes you are familiar with MakeCode, the gato:bit (v2), and the micro:bit board.

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!)

MakeCode Website
Click the New Project button to start a new project and open the Editor. Click on image to enlarge.

Once you have the editor up, click on the the Advanced block in the block library to reveal the drop down menu.

Editor
Click on the the Advanced block in the block library to reveal the drop down menu. Click on image to enlarge.

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.)

Advanced Block
Click on the the Extensions block to open the extensions page. Click on image to enlarge.

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.

Extensions Page
Use the search bar to find the extension you want to install. Click on image to enlarge.

Note: Unfortunately, it does take time to get an extension approved by the micro:bit Educational Foundation before it can be searchable by name. Part of the requirements for the approval process involves a live product page. Therefore, at the time of the launch of this product, the extension has not been approved yet and the only method of adding the extension is to use the link to the GitHub repository of the pxt-package. We will update this tutorial as soon as the extension has been approved.

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

Search for Extension
Search for Extension. Then, click on the box to add it to the block library. Click on image to enlarge.

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.

Extension in Block Library
Extension in the block library; click on the block to open menu options. Click on image to enlarge.

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.

Menu Options
Available blocks for the gator:microphone extension. Click on image to enlarge.

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.

USB Drive
The micro:bit showing up as a USB drive on a Windows computer. Click to enlarge.

To upload new code, this is where you will be copying the downloaded .hex file to later.

Block Functions

Check for sound block
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 to 2047- 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- Default
  • four
  • 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.

Sample Readings
Example of readings from the sensor.

Troubleshooting the Extension

To manually install this extension in makecode, go to the "Extensions" tab on the left side of the makecode site:

alt text

In the location you'd normally search for an extension, you'll notice an upload button on the right:

alt text

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.

alt text

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.

alt text

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:

Interested in the micro:bit? Check out some of these other micro:bit products:

micro:bit v2 Club Kit - Go Bundle 10-Pack

micro:bit v2 Club Kit - Go Bundle 10-Pack

KIT-17290
$175.00
6
SparkFun Educator Lab Pack for micro:bit v2

SparkFun Educator Lab Pack for micro:bit v2

LAB-17361
$320.95
SparkFun Inventor's Kit for micro:bit v2 Lab Pack

SparkFun Inventor's Kit for micro:bit v2 Lab Pack

LAB-17363
$460.00
SparkFun micro:climate kit for micro:bit - v3.0

SparkFun micro:climate kit for micro:bit - v3.0

KIT-16274
$119.95
1

Need some inspiration for your next project? Check out some of these other micro:bit product tutorials:

micro:climate Kit Experiment Guide

A weather station kit that is built on top of the inexpensive, easy-to-use micro:bit and Microsoft MakeCode.

How to Load MicroPython on a Microcontroller Board

This tutorial will show you how to load the MicroPython interpreter onto a variety of development boards.

Gator:starter ProtoSnap Hookup Guide

Get started clipping sensors and lights to the micro:bit with the gator:starter gator:board from SparkFun!