Monitoring noise levels in your environment using sound sensor 

A sound sensor is a device that can detect and measure sound waves. These devices are used in a variety of applications, including acoustic testing, noise-level monitoring, and speaker recognition.


There are two main types of sound sensors: microphone-based sensors and vibration-based sensors. Microphone-based sensors convert sound waves into electrical signals that can be measured and analyzed. Vibration-based sensors measure the vibrations caused by sound waves.


Overview


This is a simple project that uses an Arduino and a sound sensor to detect sound levels and print data to serial monitor when the sound level goes high, it also will print the analog value.

The project is ideal for monitoring noise levels in your surroundings or as a security system.


You will learn how to use the sensor so that you may include it in more complex projects, such as creating a graph of sound level over time or simply triggering an LED or buzzer when the sound level exceeds a given threshold.


Getting the items


For this project you will need the following components: 

Sale Off
Voltaat Arduino Uno R3 (Voltaat Version)
45 QAR
Sale Off
Voltaat Microphone Module
13 QAR
Sale Off
Voltaat Jumper Wires - Male to Female (40 Pack)
10 QAR

Wiring it up


To obtain the correct readings from the sensor, follow the instructions below as well as the image that demonstrates how to connect the sensor to the Arduino.



Connections from the Arduino to the sound sensor:

• Arduino A0 pin → sound sensor A0 pin

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

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

• Arduino pin 2 → sound sensor D0 pin


Coding


This sketch's purpose is to keep track of the noise levels in the surrounding area. It uses the serial monitor to display the analog read values from the sound sensor as well as the sound status based on whether the digital read indicates that the noise level is high or low.


Simply follow the instructions and comments scattered throughout the code to understand and use the code, which may be developed and used in more complex projects like a security alarm.


  1. /*
  2.   Voltaat learn (https://www.voltaat.com)
  3.   Link for full tutorial: https://www.voltaat.com/blogs/tutorials/monitoring-noise-levels-in-your-environment-using-sound-sensor
  4.   Link for libraries: There are no libraries for this sketch
  5.  
  6.   Monitoring noise levels in your environment using sound sensor
  7.  
  8.   Connections from the Arduino to the sound sensor:
  9.   • Arduino A0 pin → sound sensor A0 pin
  10.   • Arduino GND pin → sound sensor GND pin (- pin)
  11.   • Arduino VCC pin → sound sensor VCC pin (+ pin)
  12.   • Arduino pin 2 → sound sensor D0 pin
  13.  
  14. */
  15.  
  16. //Define the variable soundSensorRead to Analog Input Pin A0
  17. constint soundSensorRead = A0;
  18.  
  19. //Define the variable soundSensorPin to Digital Input Pin 2
  20. constint soundSensorPin =2;
  21.  
  22. //Define variables
  23. int sensorRead;
  24. boolean sensorStatus;
  25.  
  26. //Commands inside void setup run once
  27. void setup ()
  28. {
  29. //Start the serial monitor at 9600 baud rate (9600 bits per second)
  30. Serial.begin(9600);
  31. //SoundSensorPin is defined as an input
  32. pinMode (soundSensorPin, INPUT);
  33.  
  34. }
  35.  
  36.  
  37. //Commands inside void loop run forever
  38. void loop ()
  39. {
  40. //Read the value of analog input from soundSensorRead and assign it in the variable sensorRead
  41. sensorRead = analogRead(soundSensorRead);
  42. //Read the value of digital input from soundSensorPin and assign it in the variable sensorStatus
  43. sensorStatus = digitalRead(soundSensorPin);
  44.  
  45. //Check noise status
  46. if(sensorStatus == HIGH)
  47. {
  48. //Print to serial monitor
  49. Serial.print("Alert, there is high noise in the surroundings ");
  50. Serial.print("| Sound sensor value: ");
  51. Serial.println(sensorRead);
  52.  
  53. }
  54. else
  55. {
  56. //Print to serial monitor
  57. Serial.print("Everything around you is peaceful ");
  58. Serial.print("| Sound sensor value: ");
  59. Serial.println(sensorRead);
  60.  
  61. }
  62.  
  63. //Delay for 3 seconds
  64. delay(3000);
  65. }
  66.  

Testing it out


You may now access the serial monitor on your Arduino IDE by clicking on it.


The serial monitor is great way that’s enables you to make a communication between your computer and Arduino by sending and receiving different commands and information using the USB cable.


Now, as we can see in in the image below, the serial monitor shows the noise state and the analog read value from the sensor. Because of the delay we added to our code, the value is updated and printed every three seconds. You should also check that you have selected the correct baud rate (9600) as specified in the code.


Resources 


Arduino Code

Fritzing Wiring file

Related Tutorials


How to become very good 

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et 

How to become very good 

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et 

How to become very good 

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et 

Liquid error: Could not find asset snippets/zend_pre_order_theme_snippet.liquid
Liquid error: Could not find asset snippets/uploadkit.liquid