Skip to content

All you need to know about Audio sensors

We are living in an era where almost everything is using tech. You will find tech gadgets being implemented to farm, guard places, serve clients, shopping, and so on. However, the most affected sectors include the education sector, the security sector, and the scientific sector. This article will focus on the security sector whereby advancements such as audio sensors are being implemented to take things up a notch. However, audio detectors have not just found their way into the security sector alone; they are also used for different purposes such as:

  • Security
  • Monitoring
  • Home automated tasks (for example, the famous house lighting using claps)

All these are just a taste of what’s to come; we shall get into these details later.


So, have you ever come into contact or used an audio detector? What did you think about this particular kind of tech? Well, audio detectors are indeed a wonder and a great tool to use in the 21st century; hence am pretty sure the experience was pretty fascinating, unless you were stealing, in which case the incident must not have been that good.

The tricky part about audio detectors is that most people do not know how they function. Ask most people how an audio sensor works and wait for some pretty weird answers, such as “the device hears sound and responds.” Well, in this article, we shall help you not fall victim to answering this question wrongly. We shall cover:

  1. How an audio detector works
  2. Applications of an audio sensor
  3. Audio sensor Arduino tutorial using raspberry pi
  4. Projects on audio sensors

After reading this article, you will not just have the answer to “what is an audio sensor?” but also the answers to why, when, and how to use an audio sensor. Hence let us get right into it.

What is an Audio Sensor?

sound sensors in robotics

 An audio sensor can be defined as a module that detects sound waves via the intensity of the sound wave. It then converts these sound waves into electrical signals. So no “hearing” sound stuff around audio sensors.

Audio sensors modules consist of a small board that combines processing circuitry and a microphone. These modules produce audio output, a binary indication of the Sound’s presence, and an analog representation of the wave’s amplitude.

How exactly does an Audio Sensor Work?

Well, you know how your ear works? Audio sensors work similarly. They have a diaphragm that changes vibrations into signals. The difference between your ear and an audio detector is that an audio sensor:

  1. Uses a capacitive microphone (in-built)
  2. A peak detector
  3. An amplifier ( one that is pretty sensitive to audio)

An audio detector using these components can work in the following way:

  1. First, the audio sensor receives sound waves propagated via air molecules using its in-built capacitive microphone.
  2. The sound waves then cause the diaphragm found in the audio detector’s microphone to vibrate, which leads to a change in capacitance.
  3. The change in capacitance is then amplified and digitized for sound intensity processing.

Applications of an Audio Sensor

Other than being used with Arduino boards for various projects over the years, audio sensors also have some other pretty fascinating applications, which include:

  1. Utilized in consumer electronics such as music systems, computers, phones et cetera
  2. Monitoring and security systems such as door alarms and burglar alarms.
  3. Home automation, for example, house lighting using claps/ whistle rather than having to work with a switch
  4. Audio level and ambient audio recognition

Sound Sensor Module

Before we advance on to the how part, let us first look at the sensor module we shall utilize in this article. Well, there are a lot of modules available in the market to date, some good, some not so good. However, we shall implement the LM386 audio sensor in this article. The LM386 is a low-powered, simple audio sensor with high compatibility.

The features of this module include:

  1. Compatibility interface
  2. Analog output signal
  3. A wide voltage supply that ranges in between 4V and 12V
  4. Minimal external parts
  5. 2.0cm x 2.0cm twig module

What’s more, this module is pretty affordable. Once you have purchased an audio sensor, you will require an Arduino to complete this article’s “HOW” part.

But what is an Arduino in the first place?

Well, have you ever heard of Arduino boards? Have you ever used one before? Well, if you have not heard of it nor used it, worry not because we have got you. This section will look at Arduino and its connection to audio sensors.

Arduino can be defined as an open-source platform utilized to build electronic projects. Arduino is composed of a micro-controller and an IDE (integrated development environment) that runs on a PC. The IDE is simply utilized to write and upload Arduino codes onto the physical board.

Over the years, Arduino has become pretty popular, and for good reasons. See, earlier programmable circuit boards required a separate piece of hardware to work correctly, which is not the case with Arduino. Using Arduino, all you need is a cable to load a program onto the physical board, and you are good to go. What’s more, Arduino utilizes the C++ language for programming purposes, a pretty simple language to learn and master. All these reasons make Arduino great, but how is it connected with the topic at hand? Well, to answer this question, let us first see what this device entails.

See, an Arduino is designed for newbies, hackers, designers, artists, and basically anyone interested in creating an interactive environment or objects. Arduino can interact with GPS units, speakers, LEDs, buttons, the internet, TV, and even your smartphone. However, here is the part we have been waiting for; they also interact with audio detectors. That means we can utilize this device to develop responsive projects that respond to Sound.

Arduino Components

Arduino boards come in different varieties; however, most of them have the following components:

  1. Power (USB/barrel jack) – used to power the Arduino board
  2. Pins (3.3V, 5V, AREF, PWM, Digital, Analog) – These are the places whereby you connect cables to create a circuit
  3. Reset button – once you press this button, the Arduino board temporarily connects the reset pin to the ground, which restarts any code loaded onto the board.
  4. Power LED indicators – the power LED indicator found on most Arduino boards lights up when you connect the board onto a power source.
  5. TX RX LEDs – TX represents transmit, and RX represents receive. These LEDs provide visual indication every time your Arduino sends or receives data.
  6. Main IC – IC is short for integrated circuit. It acts as the board’s brain
  7. Voltage regulator – just as the name dictates, a volt regulator controls how much voltage gets into the Arduino.

The Arduino Family

types of sound sensors

As stated earlier, Arduino boards come in different varieties, each bearing unique but excellent capabilities. What’s more, these boards have open-source hardware, which means that you can modify them to suit your needs. So, if you are not sure about the project to tackle well, worry not because, at the end of this article, we shall provide a list of projects you can tackle. In the meantime, let us first look at the great Arduino family.

Arduino Uno (R3)

First on our list is the Arduino Uno which we shall also be using for the tutorial that we shall cover. The Arduino Uno board is an incredible choice for beginners. It has everything you require to get started, plus it eliminates everything that you don’t need. It has six analog inputs, a power jack, a USB connection, a reset button, and more.

LilyPad Arduino

a lilypad Arduino board is an e-textile wearable tech. It is specially designed to be sewn into clothing using conductive threads.


The redBoard can be easily programmed via a USB cable using the IDE. In addition, it is more stable because of the FTDI/USB chip. Plus, this board is also completely flat on the back, which makes it easier to embed onto your project.

Arduino Mega (R3)

The Arduino Mega is like a bigger brother to the Arduino Uno. It bears a lot (up to 54) of digital output/input pins. Having these many pins makes it pretty great for projects, as for other properties, the mega functions just like the Uno.

Arduino Leonardo

The Arduino Leonardo bears one feature that sets it apart from other boards. It can use one microcontroller via an in-built USB. By handling USB directly, the board has to have code libraries readily available, which allows it to emulate a computer mouse, keyboard, and so on.

Now that we know what an Arduino entails let us see how it works with an audio sensor.

Arduino Sound Sensor

By combining Arduino boards and sound sensors, you can achieve a lot. For instance, you can generate a device that controls house lighting via Sound. In this tutorial, we shall help you merge these two devices and develop an incredible project, hence follow along.

Wiring Audio Sensor with Arduino

Connecting an audio sensor onto an Arduino board is pretty simple. You begin by connecting the VCC pin found on your audio sensor to the 5V found on the Arduino board, then connect the GND pin onto the ground.

When you are done, connect your OUT pin onto the digital one on the Arduino board, and you are done.

Calibrating your Sound Sensor

When you need to gain accurate reading off of your audio sensor, you should calibrate it first before utilizing it for your project.

The module we are utilizing has an in-built potentiometer used to calibrate digital output (OUT).

While adjusting the potentiometer knob, it is easy to set a specific threshold. Once any sound wave level goes beyond set threshold figure, Status LED lights up, and digital output displays or outputs LOW.

To accurately adjust your sensor to detect claps, start clapping your hands near the sensor’s microphone while adjusting the potentiometer up until the moment Status LED is blinking in response to the claps you make.

That is it; you have a well-calibrated sensor to use.

Sound Detector Sensor using Arduino

Now that we have the audio sensor connected to our Arduino board, time to actualize its working.

The example that follows once coded onto an Arduino IDE simply detects snaps or claps and then prints a message on to a serial monitor. Let us try it out:

Sound sensor Arduino code

#define sensorPin 7

//the variable that store time when the last event occurred

Unsigned long lastEvent = 0;

Void setup() {

  pinMode (sensorPin, INPUT);



Void loop(){

//reads sound sensor

Int sensorData = digitalRead (sensorPin);

// once sound goes LOW, sound is sensed

If (sensorData == LOW){

// after 25 milliseconds have gone since the last state of LOW, it implies that the detected clap is not due to any other spurious sound

// if (millis() – lastEvent > 25){

Serial.println (“clap has been detected!”);


//Recall when the last event occurred

LastEvent = millis();



Once you are done with this program, load it up to your Arduino using a USB cable and then clap your hands close to the sound sensor. If everything is running fine, you should see a “clap has been detected” output on your serial monitor.

Now that we are sure that our Arduino sound sensor is working properly, how about we work on an actual project.

Clap Controlled Device using an Audio Sound Sensor and an Arduino Board

This project will create a sound sensor that turns an AC-powered device, might be a bulb, on and off using claps. We shall use a relay module (one-channel) to control an AC-powered device efficiently.


First, you should supply power onto the relay module and audio sensor. Connect the VCC pins onto the 5V pin present on your Arduino board then connect the GND to the ground.

Next up, connect the audio sensor’s OUT pin (used for output) onto digital pin #7 found on the Arduino board. Finally, connect relay module IN pin (or the control pin) onto the #8 digital pin.

You will also have to position relay module to be in line with your AC-powered device you are attempting to manipulate using Sound. First, cut off the live AC track and then connect one of the two ends (the one end emanating from the wall section) to COM, then connect the other end onto NO.

Arduino code to Control an AC Powered Device

#define sensorPin 7

#define relayPin 8

//variable that stores the time when last event occurred

Unsigned long lastEvent = 0;

Boolean relayState = false; // variable that stores relay state

Void setup() {

pinMode(relayPin, OUTPUT); // set the relay pin as an OUTPUT pin

pinMode( sensorPin, INPUT); // set sensor pin to be an INPUT


Void loop(){

//reads sound sensor

Int sensorData = digitalRead (sensorPin);

//If pin outputs LOW, sound is detected

If (sensorData == LOW) {

// if 25 milliseconds have passed since the last LOW state, then it means that the detected clap

//was valid

If (millis() – lastEvent > 25) {

//toggle relay then set output

relayState = !relayState;

digitalWrite( relayPin, relayState ? HIGH : LOW);


// Remember last event occurrence

LastEvent = millis();



Once you load and run this program with the hardware hooked up, the sensor should switch the device on or off each time you clap your hands.


If your sound sensors tend to misbehave, try out these tricks to fix it:

  1. First, double-check the power supply to ensure that it is clean. That is because audio sensors are analog circuits; hence they are prone to power supply noise.
  2. The electret mic used in sound sensors is also pretty sensitive to wind noise and mechanical vibrations. Hence mounting it with some resilient material can help absorb vibration.
  3. Clap your hands closer to the sound sensor to gain a better response. Most sound sensors have low-range sound sensing, probably ten inches or so. Hence the closer, the better.

And that is how you tackle a basic sound-sensing Arduino project. You can play around with this project making adjustments to familiarize yourself with sound sensors and Arduino.

Now that we have that “how to use audio sensors” section out of the way. How about we take things up a notch by bringing raspberry pi into the equation. If you do not know what a raspberry pi is, hold on to your seat because this will amaze you.

Raspberry pi

sound sensor arduino

The Raspberry Pi can be defined as a credit-card-sized, low-cost computer which is plugged onto a TV or computer monitor and utilizes a standard mouse and keyboard. Using this device, you can explore the world of computing in a cost-friendly manner and learn languages such as python and scratch. In addition, the raspberry pi can do everything that you would expect from a desktop, from browsing to playing games and word processing.

However, here is why this device has made it into this article, the Raspberry Pi can interact with the real world via detectors such as, you guessed it, audio detectors. But how can you use a raspberry pi with an audio sensor? Well, let us see how:

Raspberry pi Sound Sensor

Materials required for this project

  1. Raspberry Pi (with keyboard and screen)
  2. LED
  3. Sound sensor
  4. Jumper wires
  5. Breadboard

Circuit connection

Connect your sound sensor according to this table, where each column cell is connected to the adjacent column cell.

 Raspberry Pi connection to the:   Sound sensor 
 +5V  +5V, VCC 
 GPIO 4 Pin   DO  
 Raspberry Pi connection to the:  16 * 2 LCD 
 +5 volts  VCC  
 GPIO 3 (SCL)  SCL Pin 
 GPIO 2 (SDA)  SDA Pin 
 Raspberry pi connection to the:  LED 220-ohms Resistor
 GND    Terminal 1
 GPIO 7 Pin   Anode Terminal ( + ) 
    Cathode Terminal Terminal 2

Code and Explanation

To get things up and running, we must first save some modules into the Raspberry Pi python directory or in the location at which you have saved your main program. The program utilized to save the required modules can be found online, once you find this program, save it as in the above specified location. You are now set to move on to the main raspberry pi code which configures your raspberry pi to work with a sound sensor.

Main raspberry pi code:

import LiquidCrystal_I2C  

 from time import sleep  

 import RPi.GPIO as gp  





 lcd.display(“Initiating Mic…”,1,0)  




 while True:  







   except KeyboardInterrupt:  



The main code performs the following functions

In the code, we, first of all, include some crucial modules such as the liquidCrytal_12C RPi.GPIO module and the sleeping function.

We then set up the gpio pin numbering board as the board convections dictate, with pin seven as the IN pin for the audio sensor.

We then initialize the LCD and generate an LCD object bearing a variable name “LCD,” We then provide a command to delete any previous information contained in the LCD’s memory. After that command, we move on to insert starting strings onto the LCD screen.

The while loop has a code that prints onto the LCD each time an input goes high on pin 7.

And that is how you can use a raspberry pi with an audio sensor to detect sound waves.

Audio Sensor Project suggestions

Here are some projects that you can tackle to boost your knowledge of audio sensors:

  1. A baby monitor using audio sensors – using this project baby sitter can have less work watching over toddlers and mothers can sleep better knowing that their child is being monitored at night in case they cry. The best part about this project is that you only require pretty basic components such as a raspberry pi and a sound sensor.
  2. A dog barking tracker with audio sensors – You know how dogs escape their leash and run away. Well, using this dog barking tracker, you can easily find your dog whenever they bark. It is a fun project to venture into and the product is just as good.
  3. USB device control using Sound – Having to manually switch songs or adjust the volume of a device can be exhausting. But what if you could carry out this tasks totally hands free. Well, that is what you get when you venture into this project. Try it out and bring in some futuristic functionalities to your home.


We live in a technological era that is making our lives pretty easy and fun. In terms of making our lives easier, sound sensors are one of the most commonly used devices for this job. Now you do not have to type on your phone. All you need to do is say something onto your smartphone’s sound sensor, and your phone does it. Also, you do not have to switch off the light manually; you can just clap your hands to turn the light on or off. All these are great examples describing just how awesome sound sensors are and why you should make use of them. We hope this article has answered all the questions you had on sound sensors and provided more to help you execute your project efficiently.