Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Voltaat Arduino Ultimate Kit
60 min
Share

Detect noise levels using a sound sensor

A sound sensor is a device that can detect and measure sound waves. It is a part of many of the devices we use, including phones, laptops, and music players. as well as security and monitoring systems.

Project Video

Overview

In this tutorial we will use the Arduino and a sound sensor to detect sound levels in your environment and print this data directly on your computer.

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
Microphone Module
Get Item
Jumper Wires – Male to Female (40 Pack)
Get Item

Steps

Wiring it Up

Connect the wires between the sound sensor and the Arduino, as shown in the image below.


 Connections from the Arduino to the sound sensor:


      • Arduino A0 pin → sound sensor A0 pin


      • Arduino GND pin → sound sensor GND pin (- pin)


     • Arduino 5V pin → sound sensor VCC pin (+ pin)


      • Arduino pin 2 → sound sensor D0 pin


Coding


/*
 Voltaat learn (https://www.voltaat.com)
 Link for full tutorial:

 Tutorial: Detect noise levels using a sound sensor

 This sketch's purpose is to keep track of the noise levels in the surrounding area

 Connections from the Arduino to the sound sensor:
 • Arduino A0 pin → sound sensor A0 pin
 • Arduino GND pin → sound sensor GND pin (- pin)
 • Arduino 5V pin → sound sensor VCC pin (+ pin)
 • Arduino pin 2 → sound sensor D0 pin

*/

//Define the variable soundSensorRead to Analog Input Pin A0
const int soundSensorRead = A0;

//Define the variable soundSensorPin to Digital Input Pin 2
const int soundSensorPin = 2;

//Define variables
int sensorRead;
boolean sensorStatus;

//Commands inside void setup run once
void setup ()
{
 //Start the serial monitor at 9600 baud rate (9600 bits per second)
 Serial.begin(9600);
 //SoundSensorPin is defined as an input
 pinMode (soundSensorPin, INPUT);

}


//Commands inside void loop run forever
void loop ()
{
 //Read the value of analog input from soundSensorRead and assign it in the variable sensorRead
 sensorRead = analogRead(soundSensorRead);
 //Read the value of digital input from soundSensorPin and assign it in the variable sensorStatus
 sensorStatus = digitalRead(soundSensorPin);

 //Check noise status
 if (sensorStatus == HIGH)
 {
   //Print to serial monitor
   Serial.print("Alert, there is  high noise in the surroundings ");
   Serial.print("| Sound sensor value:  ");
   Serial.println(sensorRead);

 }
 else
 {
   //Print to serial monitor
   Serial.print("Everything around you is peaceful ");
   Serial.print("| Sound sensor value:  ");
   Serial.println(sensorRead);

 }

 //Delay for 3 seconds
 delay(3000);
}

Testing it Out

You should also check that you have selected the correct baud rate (9600) as specified in the code.
know when your plant needs watering

Now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.

know when your plant needs watering

Now, as we can see in the image below, the serial monitor prints the noise state and the read value from the sensor.

The value is updated and printed every three seconds. Because of the delay, we added to our code.

know when your plant needs watering

Resources

No items found.