IoT Based Sound Pollution Monitoring System – Measure and Track Decibels (dB) using NodeMCU

IoT Based Sound Pollution Monitoring System using NodeMCU

We surely can’t imagine a world without sound. Sound is one of an integral part of our day to day life, everything just becomes monotonous without the presence of audio. But too much of anything is dangerous, with the advent of automobiles, loudspeakers, etc. sound pollution has become a threat in recent days. So, in this project, we will build an IoT decibel meter to measure sound in a particular place and record the value in a graph using IoT. A device like this will be useful in places like hospitals and schools to track and monitor the sound levels and take action accordingly. Previously we have also built an Air pollution meter to monitor air quality using IoT.

 

A sound level meter is employed for acoustic (sound that travels through the air) measurements. The simplest sort of microphone for sound level meters is the capacitor microphone, which mixes precision with stability and reliability. The diaphragm of the microphone responds to changes in air pressure caused by sound waves. That’s why the instrument is usually mentioned as a sound pressure level (SPL) Meter.

 

Sound level meters are commonly utilized in sound pollution studies for the quantification of various sorts of noise, especially for industrial, environmental, mining, and aircraft noise. The reading from a sound level meter doesn't correlate well to human-perceived loudness, which is best measured by a loudness meter. Specific loudness may be a compressive nonlinearity and varies at certain levels and certain frequencies. These metrics also can be calculated in several other ways.

IoT Decibel Meter

Here we are going to make an IoT based decibel meter that will measure the sound in decibels(dB) using a sound sensor and display it to the LCD display along with that, it will also be pushing the readings to the Blynk IoT platform making it accessible from across the world.

 

Components Required

  • ESP8266 NodeMCU Board
  • Microphone sensor
  • 16*2 LCD Module
  • Breadboard
  • Connecting wires

 

How does Microphone Module Work?

The microphone based sound sensor is used to detect sound. It gives a measurement of how loud a sound is. The sound sensor module is a small board that mixes a microphone (50Hz-10kHz) and a few processing circuitry to convert sound waves into electrical signals. This electrical signal is fed to on-board LM393 High Precision Comparator to digitize it and is made available at the OUT pin.

 

The module features a built-in potentiometer for sensitivity adjustment of the OUT signal. We will set a threshold by employing a potentiometer. So that when the amplitude of the sound exceeds the edge value, the module will output LOW, otherwise, HIGH. Apart from this, the module has two LEDs. The facility LED will illuminate when the module is powered. The Status LED will illuminate when the digital output goes LOW.

Sound Sensor Module

The sound sensor only has three pins: VCC, GND & OUT. VCC pin supplies power for the sensor & works on 3.3V to 5V. OUT pin outputs HIGH when conditions are quiet and goes LOW when sound is detected.

 

Circuit Diagram for IoT Sound Meter

The connections are pretty simple, we just have to connect the sound sensor to one of the Analog pin and the LCD to the I2C pins.

IoT Sound Meter Circuit Diagram

IoT Sound Meter

In the above diagram, we have connected the power pins of the sound sensor and LCD display to 3v3 and GND pin of NodeMCU. Along with that, we have also connected the SCL and SDA pins of the module to D1 and D2 respectively, and the OUT pin of the sound sensor to A0 pin.

 

Setting up Blynk for Remote Monitoring

For the IoT part, we will be using the Blynk IoT platform. We have previously used Blynk with Nodemcu to build many different projects. You can also check out other Blynk projects that we have built earlier. In this application, we will be adding a gauge to display the intensity of sound in decibels. Let us set up the app quickly.

  • First of all, install the Blynk app from PlayStore and create an account.

 

  • Click on the create button and create your new project.

Blynk App

 

  • Give your project a name and choose the board as NodeMCU and connection type as Wi-Fi.

Decibel Meter Using Blynk

 

  • An auth token will be sent to your registered email id. Keep it safe as it will be used later on while programming.

Auth Token in Blynk App

Auth Token is a unique alphanumeric string to identify your project in the Blynk’s server and assigning the correct data through it.

 

  • Now drag and drop a gauge from the list and configure it.

Blynk Projects

 

  • Connect the gauge to virtual pin V0 and set the values to 0 and 90 respectively, also set the reading rate to 1 sec.

IoT Sound Meter using Blynk

And now you’re done with setting up Blynk. Let us jump to the coding part.

 

Program for IoT Decibel Meter

Here, we have to develop a code that takes input from the sound sensor and maps it value to decibels and after comparing the loudness, it should not only print it to the 16*2 LCD display but should also send it to the Blynk server.

 

The complete code for this project can be found at the bottom of this page. You can directly copy-paste it in your IDE and change only three parameters i.e. SSID, pass, and auth token. The explanation of the code is as follows.

 

In the very first part of the code, we have included all the necessary libraries and definitions. Also, we have defined the necessary variables and objects for further programming.

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <LiquidCrystal_I2C.h>
#define SENSOR_PIN A0
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
const int sampleWindow = 50;
unsigned int sample;
int db;
char auth[] = "IEu1xT825VDt6hNfrcFgdJ6InJ1QUfsA";
char ssid[] = "YourSSID";
char pass[] = "YourPass";

 

Further ahead, we have created a Blynk function to handle the virtual pin that our gauge is connected to. We are simply sending the values stored in the dB variable to the V0 pin.

BLYNK_READ(V0)
{
  Blynk.virtualWrite(V0, db);
}

 

In the setup part of the code, we are defining the pin mode as input and beginning the LCD display as well as the Blynk function.

void setup() {
  pinMode (SENSOR_PIN, INPUT);
  lcd.begin(16, 2);
  lcd.backlight();
  lcd.clear();
  Blynk.begin(auth, ssid, pass);
}

 

In the loop part, we are doing all the processing tasks like comparison and value assignment along with running the Blynk function.

void loop() {
  Blynk.run();
  unsigned long startMillis = millis(); // Start of sample window
  float peakToPeak = 0; //peak-to-peak level
  unsigned int signalMax = 0; //minimum value
  unsigned int signalMin = 1024; //maximum value
  // collect data for 50 mS
  while (millis() - startMillis < sampleWindow)
  {
    sample = analogRead(SENSOR_PIN); //get reading from microphone
    if (sample < 1024) // toss out spurious readings
    {
      if (sample > signalMax)
      {
        signalMax = sample; // save just the max levels
      }
      else if (sample < signalMin)
      {
        signalMin = sample; // save just the min levels
      }
    }
  }
  peakToPeak = signalMax - signalMin; // max - min = peak-peak amplitude
  Serial.println(peakToPeak);
  db = map(peakToPeak, 20, 900, 49.5, 90); //calibrate for deciBels
  lcd.setCursor(0, 0);
  lcd.print("Loudness: ");
  lcd.print(db);
  lcd.print("dB");
  if (db <= 50)
  {
    lcd.setCursor(0, 1);
    lcd.print("Level: Quite");
  }
  else if (db > 50 && db < 75)
  {
    lcd.setCursor(0, 1);
    lcd.print("Level: Moderate");
  }
  else if (db >= 75)
  {
    lcd.setCursor(0, 1);
    lcd.print("Level: High");
  }
  delay(600);
  lcd.clear();
}

 

Working of the Project

Now that you have understood the code, you can simply upload it to your NodeMCU board and the project should start working.

IoT Based Sound Pollution Meter

To make sure the values are correct, I compared them to an android application on my phone that could measure sound. As you can see from the pictures, the results were quite close.

Sound Level Meter

The complete working of this project is also demonstrated in the video linked below. Hope you enjoyed the project and learned something useful if you have any questions, leave them in the comment section below.

Code

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <LiquidCrystal_I2C.h>
#define SENSOR_PIN A0
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
const int sampleWindow = 50;
unsigned int sample;
int db;
char auth[] = "IEu1xT825VDt6hNfrcFgdJ6InJ1QUfsA";
char ssid[] = "realme 6";
char pass[] = "evil@zeb";
BLYNK_READ(V0)
{
  Blynk.virtualWrite(V0, db);
}
void setup() {
  pinMode (SENSOR_PIN, INPUT);
  lcd.begin(16, 2);
  lcd.backlight();
  lcd.clear();
  Blynk.begin(auth, ssid, pass);
}
void loop() {
  Blynk.run();
  unsigned long startMillis = millis();  // Start of sample window
  float peakToPeak = 0;  // peak-to-peak level
  unsigned int signalMax = 0;  //minimum value
  unsigned int signalMin = 1024;  //maximum value
  // collect data for 50 mS
  while (millis() - startMillis < sampleWindow)
  {
    sample = analogRead(SENSOR_PIN);  //get reading from microphone
    if (sample < 1024)  // toss out spurious readings
    {
      if (sample > signalMax)
      {
        signalMax = sample;  // save just the max levels
      }
      else if (sample < signalMin)
      {
        signalMin = sample;  // save just the min levels
      }
    }
  }
  peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
  Serial.println(peakToPeak);
  db = map(peakToPeak, 20, 900, 49.5, 90);  //calibrate for deciBels
  lcd.setCursor(0, 0);
  lcd.print("Loudness: ");
  lcd.print(db);
  lcd.print("dB");
  if (db <= 50)
  {
    lcd.setCursor(0, 1);
    lcd.print("Level: Quite");
  }
  else if (db > 50 && db < 75)
  {
    lcd.setCursor(0, 1);
    lcd.print("Level: Moderate");
  }
  else if (db >= 75)
  {
    lcd.setCursor(0, 1);
    lcd.print("Level: High");
  }
  delay(600);
  lcd.clear();
}

Video

17 Comments

The added weight iamazonsurmountwayweightedvest_2021 is a sure-fire way to make whatever workout you're doing infinitely more difficult. And if you've been sticking with bodyweight exercises, it can be an incredible tool to help push you.You can wear them during hikes, cardio workouts, and even CrossFit's iconic Murph workout. (CrossFitter Chris Holt did two back-to-back Murphs wearing a 30-pound weighted vest.) Or you can try one out during this weighted vest home workout designed by Scott Britton that will challenge you with a descending ladder of running and reps of press-ups.Weighted vests will take any home workout to the next level and transform just about any activity into a resistance exercise.

Thanks so much for giving everyone remarkably wonderful opportunity to read critical reviews from this web site. It really is so beneficial and as well , full of a great time for me personally and my office colleagues to visit your site at the least three times in 7 days to learn the latest issues you have. And definitely, I am actually contented with the unbelievable secrets you give. Selected 3 ideas in this post are indeed the very best we have had.

Thanks so much for providing individuals with an extraordinarily splendid possiblity to read critical reviews from this site. It can be so lovely and jam-packed with a great time for me personally and my office fellow workers to visit the blog on the least 3 times in 7 days to see the fresh items you have. And lastly, I am just at all times impressed with all the excellent strategies you give. Selected 4 tips in this post are unquestionably the most effective we have ever had.

Thanks so much for giving everyone such a breathtaking possiblity to check tips from this web site. It can be so pleasurable and as well , full of a great time for me personally and my office mates to search your site at least three times per week to study the fresh things you will have. Not to mention, I'm just certainly happy for the stunning tips you serve. Some two tips in this posting are really the very best we've had.

I wish to voice my gratitude for your kindness supporting individuals that have the need for help with that concern. Your very own commitment to passing the solution up and down came to be wonderfully good and have regularly made guys and women like me to reach their goals. Your own warm and friendly tips and hints means a whole lot a person like me and even more to my fellow workers. Many thanks; from everyone of us.

I simply desired to say thanks once more. I do not know the things I would have achieved in the absence of those suggestions documented by you on my industry. It was actually a very fearsome concern for me, however , observing a expert avenue you processed it took me to leap for fulfillment. Now i'm grateful for your support and in addition hope you comprehend what a great job that you're undertaking teaching other individuals thru your webblog. Probably you haven't met all of us.

A lot of thanks for every one of your effort on this blog. Debby really loves setting aside time for internet research and it's really easy to understand why. My partner and i notice all regarding the powerful method you offer vital ideas through this blog and as well as recommend contribution from some other people about this theme while our simple princess is without question starting to learn a great deal. Have fun with the rest of the new year. You're the one doing a remarkable job.

I actually wanted to compose a brief remark to appreciate you for all of the magnificent tips and hints you are showing here. My particularly long internet research has finally been rewarded with good quality details to share with my family. I would express that we website visitors are extremely endowed to dwell in a fabulous site with very many wonderful professionals with great plans. I feel really happy to have discovered your website and look forward to plenty of more cool minutes reading here. Thanks a lot once again for all the details.

Thanks so much for giving everyone remarkably breathtaking possiblity to read in detail from this site. It really is so pleasing and full of fun for me personally and my office acquaintances to search your web site really 3 times in one week to read through the newest stuff you have got. And of course, we are certainly amazed for the excellent secrets you give. Certain 3 areas on this page are essentially the most impressive we've had.

My husband and i have been very thrilled Jordan could deal with his web research using the ideas he received from your site. It's not at all simplistic to just always be freely giving guidance which usually men and women may have been making money from. Therefore we already know we need the blog owner to be grateful to for this. The type of illustrations you have made, the straightforward blog menu, the relationships your site make it easier to instill - it's got most terrific, and it's really facilitating our son in addition to us do think that idea is brilliant, which is particularly pressing. Many thanks for all!

Thank you a lot for giving everyone an exceptionally spectacular possiblity to read from this blog. It is usually very good and stuffed with a good time for me and my office mates to search your website at the very least 3 times every week to see the newest guidance you will have. And lastly, I am actually fascinated considering the special hints served by you. Some 4 ideas on this page are certainly the simplest we've ever had.

I needed to write you the bit of note to give thanks as before relating to the breathtaking opinions you have discussed in this article. This is simply particularly generous of people like you to present unreservedly just what a lot of people would have distributed for an electronic book to help make some money on their own, notably considering that you could have done it if you ever decided. These strategies likewise worked like the fantastic way to fully grasp many people have the identical zeal similar to my very own to grasp a lot more in terms of this problem. I'm sure there are many more fun opportunities up front for people who browse through your blog.

I would like to get across my passion for your generosity in support of women who need help on in this area of interest. Your special commitment to getting the solution up and down came to be wonderfully insightful and have helped ladies like me to achieve their desired goals. Your personal useful report indicates this much a person like me and somewhat more to my fellow workers. Best wishes; from each one of us.

Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.