@@BasonTech ok, but can you please share some blog or something, because i need it by next week . It will be very helpful. We have project to get amplitude vs frequency from audio/voice
Thank you very much for your clear instructions! I only have one weird outcome, when there is no sound, the value is very high and when there is sound the value gets lower. I just copied the code so i think that can't be the problem, but I use another sound sensor: Robodyn Sound Detector. It has 4 pins instead of 3, I connected the Digital Out with digital 8 on arduino. Do you maybe know what went wrong? Thank you!
Hi, it sounds like the signal is being inverted by your sensor. This is no problem, just change the code so you'll get the inverted value. So 0 needs to become 1024 and 1024 needs to become 0 😃
Wow..just wow! Thanks ...you solved my problem...... I would also like to know whether you are familer with the sound sensor module which has analog pin output too....I expected such a waveform when I connected it to the analog pin but there's no difference at all no matter what sound I make! I thought the mic was damaged but everyone had the same problem!
The digital sampling I use in this tutorial will not work with the analog output. With an analog output it should be a log easier. Just print the value read on the analog port to the serial monitor. You should see a value variation depending on your sound.
Remember, this sensor cant measure noise level (dB). The amplitude on diagrams dont show noise level, it only shows how long sound sensor was triggered on. When it is quieter, the sensor does not detect the quieter sound as a lower noise level, but activates fewer times in a set period of time.
@@BasonTech So the sensor you used is for binary sound detection. Instead, I want to do full multi-channel sound recording so that I can play the recorded sound back? Will I need the same sensor? If no, please suggest alternative. Thanks!
Nope, this sensor can't do that. I am also wondering if the Arduino has enough processing power to record multi channel audio. I think the Sony Spresense would be more suitable since it is fast and has multi mic input out of the box: developer.sony.com/develop/spresense/specifications
you prolly dont care but if you're stoned like me atm you can watch all the latest movies and series on InstaFlixxer. Have been streaming with my gf for the last few weeks xD
Hello sir..I want to make vu meter using ws2812b RGB led and sound sensor..so if I use the statement" if sound value is between x and y then display z leds"..will it be the correct statement.. I want to use if statement ..can I guide me sir. (X,y,z are just examples I have taken)
This sensor is not so suitable for a VU meter since it is binary. Have a look at the KY-037 or KY-038 which has an analog out. The correct state for between 50 and 60 is: if((x > 50) && (x < 60)) {
Hello, it's very helpful video and nice presentation. Thankyou so much. I'am doing a project based on this but instead of aurdino how can we interface sound sensor to FPGA. If you know anything about it kindly reply.
Thank you for the nice explanations. Is there any ways which I can be able to save the plotted audio into WAV or MP4 to an SD Card or by using PySerial?
@@user-dj8et5np4e No worries! The only thing you can mess up is with the hardware. If you connect the wires in a wrong way causing a short circuit of something 😃
Copied from the datasheet at eva.fing.edu.uy/file.php/585/materiales/HD/CZN-15E.pdf Sensitivity: -46±3dB -42±3dB -38±3dB -34±3dB (0dB=1V/pa,1KHz) Impedance: Low impedance Directivity: Omnidirectional Frequency: 20-16,000Hz Voltage range: 1.5V-10V Standard operation voltage:4.5V Current consumption: Max.0.5mA Sensitivity reduction: Within -3dB at 3V S/N ratio: More than 60dB
Hey, great project!! Can we obtain the same output which shows the amplitudes if we connect the out pin to a PWM pin on the Arduino and do an analog read instead of a digital read? Thank you
You can't this sensor is a binary sensor and only tells you of there is sound or not. With this code we are mimicking some kind of detection by using sampling.
Recognising a specific sound with an Arduino is not really possible. You then want to look into a Raspberry PI with a sound recognition software. I have no experience with this.
👉 Don't forget to check arduino-tutorials.net for the code and more Arduino tutorials and projects. If you have questions, don't hesitate to ask them in de comments. Remember: There are no stupid questions 😃 🔔 Want to stay up-to-date with the latest videos? Subscribe to the Bas on Tech channel!
Hello, great video, still havent bought any of arduino. Im wondering if i would desolder Microphone and replaced it with RFID antenna, could i read RFID tags?
Hi, that is not going to work. I had a tutorial about RFID, but I took it down because of an error in the video. I can't promise when I upload the fixed version.
Great demonstration. Is it possible to recognize a sound with arduino. I mean I want to sample a sound like a door bell, then if the doorball rings arduino let say gives 1 for example.
Unfortunately not. The "waveform" you see is not actually a waveform. It is a graphical representation of sampled sound intensity. There is no actual information about the sound in the waveform.
Thanks for you explanation and i need help from you sir, the code to shows only analog value of sound but i like to see in dB value , how to convert Analog sound data to dB ? can you put video on this or any idea?
You can't. This sensor does not detect dB nor the frequency of sound. What I detect is the frequency of the sensor detecting sound. Maybe the text version of the tutorial makes it clearer: arduino-tutorials.net/tutorial/drawing-sound-sensor-data-on-serial-plotter
Yes, you can analyse different frequencies with an Arduino. Unfortunately not with this sensor. This is a "binary" sensor so it tells you if there is sound or not and that's it.
first of all thanks for your video. I and my son trying to make recgognize to speech. if i say for example "yellow" i can see some numbers on serial monitor. if i describe some diffrent patterns can i recognize that word and light the yellow red ? please . thanks from Turkey
Thanks! The datasheet states: Sensitivity: -46±3dB -42±3dB -38±3dB -34±3dB (0dB=1V/pa,1KHz) more info at eva.fing.edu.uy/file.php/585/materiales/HD/CZN-15E.pdf
Hello. Great video sir! I just want to ask something sir if its okay. I want to turn on a LED when it reaches a certain amplitude on the plotter (300 for example). I copied your code and tried a bunch of stuff but it wont work. Sometimes the LED is just steadily on sometimes it wont even turn on. What should i do sir? Thank you in advance
Hi Boss, This is such an amazing video, it worked for me however I have 2 questions: 1. I'm struggling to read the signals from the Audio sensor using a Osciloscope, if I want to create a program that will action something based on some frequency (i.e. a clap light switch) can I use the plotter instead of the osciloscope ? 2. My plotter view is like very big, I would like to zoom out the plotter to have your same view, is there any setting to change to make it ? THANKS !.
Hi, to display the signals on an oscilloscope you have to output them as analog signals. My code sends it to the serial monitor and the IDE makes the graph. So you then have to modify the code that you use an analog pin to set the correct value over time. Further this sensor does not measure frequency, so you can't really detect a certain frequency. To zoom out my guess is that you need to multiply the values by a certain factor which fits your need.
Hi thanks for the video. I have a question: If I have the audio of the SIM800L when a call is outgoing, Can I connect from the speaker outputs of SIM800L to this sound sensor instead of micro inputs in order to detect when someone answer its smartphone for example? thanks
Hi Jesusita, this sensor isn't really the right device for that. I think you need to look into a VU-meter device to which you can connect the speaker out of you SIM800L
1. You can connect as many as you have ports on your Arduino 2. It should be possible to send the data over Bluetooth Keep in mind that this is not audio data but just sampled data on whether there is a sound or not. It is not audio waveform data.
Hi Ismael, great question! I've added the explanation to the website as well: arduino-tutorials.net/tutorial/drawing-sound-sensor-data-on-serial-plotter The x-axis (horizontal) is the time axis. We set SAMPLE_TIME to 10ms. This means that each horizontal point is equal to 10ms. So if we see the number 100 on the x-axis (100x 10ms), 1 second has passed. The y-axis (vertical) is the number of moments within 10ms that the Arduino sensed sound. This is related to how fast the Arduino can go through the loop(). For example, an 8Mhz Arduino will be able to do fewer measurements per second than a 16Mhz Arduino. They are therefore not exact values, but should be viewed more relative to each other.
Can this be used with arduino fft because it looks like analog output but will it behave like analog signal with arduino fft like an analog signal from sound sensor
Hi, unfortunately I have no experience with Arduino FFT. The signal from the sensor is digital with my sampling you kinda get an analogish signal but is not real analog like a soundwave
Hi Dražen, this sensor is a binary sensor, it just tells you if there is sound. By sampling I try to get a bit of an idea of the intensity of the sound. There is no way this can tell you the amount of decibels. If you want to measure that you'll need another sensor.
I am using just an electret condenser microphone but without the module circuit. how can I show the output of the microphone on the serial plotter with intensity?
You then need a component which does convert your mic into an analog signal suitable for your Arduino. E.g. 0-5V for 5V Arduinos of 0-3V for 3V Arduinos. Never did this though, so I don't know which component would work.
I found that it was detecting too much noise and if was looking a mess. If you put the line " delay(1); " below the if statements it delays the feedback just enough to smooth the graph and looks much neater.
Keep in mind that delay(1) actually tells the cpu to wait 1ms. So basically you're telling the Arduino to ignore the sensor values within that 1ms. Another way to smoothen is to widen your measurement window and subtract a base level where the noise is 😃
During the sample period we count if there was sound or not. We keep track of a counter during this sample period. Every time we detect sound we increase the value by 1. So you can see it as the amount of time over the sample period.
I've added the explanation to the website as well: arduino-tutorials.net/tutorial/drawing-sound-sensor-data-on-serial-plotter The x-axis (horizontal) is the time axis. We set SAMPLE_TIME to 10ms. This means that each horizontal point is equal to 10ms. So if we see the number 100 on the x-axis (100x 10ms), 1 second has passed. The y-axis (vertical) is the number of moments within 10ms that the Arduino sensed sound. This is related to how fast the Arduino can go through the loop(). For example, an 8Mhz Arduino will be able to do fewer measurements per second than a 16Mhz Arduino. They are therefore not exact values, but should be viewed more relative to each other.
Great Video, but us there a way to have the serial plotters values as a usable value in an if statement, I am working on a small project for example when the serial plotter hits over 100 I want a led to turn on, and when its below 100 to turn off, but I just dont know what variable to put into the if statement.
Like the serial plotter shows the values up to 1000, but when using an if statement or the sampleBufferValue the statement only works when its being compared to a 1, and nothing over 1
Hi, in my code I use: if (millisElapsed > SAMPLE_TIME) { This if checks if the sample time has passed. You can add an additional if inside this if (or extend the if) for your desired value like: if ((millisElapsed > SAMPLE_TIME) && (sampleBufferValue > 100)) {
Thank you very much sir. Sir I want to analyze multiple sound sensors data. Is it possible to analyze on same serial plotter and detect the sound sensed by a particular sensor.? Thank you in advance 😊
Hi Bas on Tech. I am using a mic and custom op amp circuits to amplify the sound. But when i run part 2 of your code, i am not able to see the same kind of values your are seeing. Using a headphone jack breakout I was able to hear the audio input to the mic. But my arduino is not showing me those waveforms. Would you be able to help me out on this?
You can't. This sensor does not measure loudness. It measures if there is sound or not. So the answer of the sensor is either "yes" or "no". No such thing as volume, decibel, loudness, intensity etc. In this tutorial I sample sound for a certain period. The y-axis only tells you the sound intensity during the measured sampled period of time.
Hey what a coincidence.....I am trying something similar too... I am trying to compare the output of two mics kept on left and right and rotate servo motor to that direction.... Did you find anything more about this?....If so please share...highly appreciated....
@majorchristopherkyle1077 I did a bit nore digging around and found that if your sound sensor has an AO (analog) pin, you can use it to monitor different levels of volume inputs. Hope this helps!
Hi, unfortunately we can't. This sampling calculates the amount of sound the sensor detects in the given sample time. It is unrelated to the frequency of sound. It is more the frequency of the amount of sound detected 😃
@@BasonTech like when you see your serial ploter you can figer that the sound wave had different wave length so I wish I can use all this different to different wave length to different out put like FFT program function.
Not at all. The data is a sampled representation of the sound intensity. It is not a so-called "waveform". So the data you see does not in any way represent the actual audio content.
Hi, not with this sensor. This is a binary sensor: it tells you if there is sound or not. It doesn't measure a frequency at all. In order to do so you need another sound sensor.
@@BasonTech sir, actually I want to make a device to measure different frequency sound waves and find individual wave like in fast forrier transform of quite nice range. If any sensor available, please reply. Thank you.
Hi Bas - I find it very difficult to tune the potentiometer - the same as the one in your link. The "sweet spot" between registers "ON" all the time vs registers "OFF" all the time is a hair's breadth. Literally even touching the pot with a screwdriver is enough to turn it from full on to full off, or vice versa. I bought a different mic board, and got the same result. Any ideas on this?
Hi John, that is weird. The only thing I could think of is that for example you use a 5V sensor on a 3V Arduino or something like that. On a 3V Arduino everything higher than 1.5 is considered to be 1. When having 5V connected that is 80% of the time, instead of 50%.
@@BasonTech Thanks, but no I tried them on 5V and 3.3V. It's either full on or full off, with a hair trigger separating the two states. I've ordered another mic and if that doesn't work I'll give up. When I am able to find the sweet spot, after 10 minutes it's already worked its way out into the full on or full off states, without any external intervention, rendering it useless for the 24/7 ambient noise-level monitoring that I was hoping to use this for...
great.. now what i need to do is somehow transmit the output via wifi then access it remotely ...the ultimate aim is to monitor sound levels remotely...plase guide me on the setup i need cheers
Amazing video man! super dope I just bought this component and your video is exactly what I was looking for. I also make tech footage too check out my projects when you get the time
@@BasonTech I'm making a research in the internet, it is possible to do it with analog microphones, but yet I'm having little success making it working
Then you should add some kind of "debounce" and a threshold. When there is noise the relay turns on. When there is no sound the debounce makes sure the relay doesn't immediately turn off.
I am having trouble trying to run two of these sensors at the same time? No matter how I try to rewrite the code enabling a second sensor the graph will only show one. Any suggestions?
I think it could work if GNU Octave can read the serial port of the Arduino. Another option could be that some middleware intercepts the serial output and send it over to GNU Octave. I personally do not have any experience with this 😃
I don't know what you mean bij infra sound. If you mean ultrasonic sound it can't. According to the datasheet the CZN-15E has a frequency range of 20-16,000Hz. Ultrasound starts at 20,000, so it can't detect this. I don't know about under water but this circuit is not waterproof.
Excuse my simple question, but I have a goal in mind to record this data over time and stream it to a text file. I understand that I would require an SD card module connected to the arduino in order to do so. Therefore I am considering going for a raspberry pi to fulfil this purpose (given the added benefits of using a Pi). My question is: would this sensor module work with a raspberry Pi as well, and would I be able to reproduce this scenario with a modified script? (Using a while loop in any programming language for example, instead of the native arduino loop)?
Hi, the video bis pretty cool, but I was thinking what if i want to manipulate the frequency of the sound and the pitch, how that could be done. I geuss, we need to connect the mic to a digital to analoge converter, that could be done by coding as well but we need to use equations. Anyway, do you have a clue of how that could be done
You can't since this is a binary sensor. The plot is only plotting the amount of sound, not the frequency. If you want to work with the frequency of sound you'll need another sensor 😃
Hi Airel, I honestly have no clue. I guess it will also depend on the intensity of sound. Obviously loud sound will be easier to detect over longer distance. Best to do is probably figure out by trying.
Great videos. The world needs more teachers like you.
Thanks really appreciated! 😃
yes we do
outstanding explanation, to make the sound wave plot alive using millis() was a genius idea. thank you
Thanks! 😃
Simple and Precise 😍
Thank you Brother😃
TH-cam please recommend me these things 😑
Thanks! Unfortunately I can't control the TH-cam algorithms 😉 So liking the videos is probably the only thing that helps 😄
Geweldig! Mijn eerste stap naar de bouw van een lichtorgel.
Great! 😃
Great Video! Would like to see how the next step, showing the frequencies, should look like
That would be a completely different video, since this sensor can't do that 😄 But great suggestion for a future video 😃
Would you please make a video about sound classification using sound sensor.
What do you mean by sound classification?
This works incredibly well!
Hi, great to hear! 😃
thanks LOT FOUND IT.MORE POWER HOPE TO SEE ANOTHER VERSION OF TUTORIALS ABOUT SOUND SENSOR
You're welcome! 😃
Can you please make a video for frequency vs amplitude
I'll write it down as a possible video topic, no guarantees though 😉
@@BasonTech ok, but can you please share some blog or something, because i need it by next week . It will be very helpful. We have project to get amplitude vs frequency from audio/voice
Then you have to search how to use a microphone on an Arduino and get the information you want from its data.
Great code!. THX for sharing with us!
Thanks for letting me know, great to hear! 😃
Thank you very much for your clear instructions! I only have one weird outcome, when there is no sound, the value is very high and when there is sound the value gets lower. I just copied the code so i think that can't be the problem, but I use another sound sensor: Robodyn Sound Detector. It has 4 pins instead of 3, I connected the Digital Out with digital 8 on arduino. Do you maybe know what went wrong? Thank you!
Hi, it sounds like the signal is being inverted by your sensor. This is no problem, just change the code so you'll get the inverted value. So 0 needs to become 1024 and 1024 needs to become 0 😃
@@BasonTech Could you elaborate a little bit more on that. e.g. where exactly to change the code?
@@ACID2BREAKS try changing the digitalRead from LOW to HIGH
ela
thanks this really helped
Great to hear! 😃
Excellent video, very well explained....
Thanks, appreciated! 😃
Nice demo
Thanks! 😃
clear and simple thanks
You're welcome! 😃
Your video is amazing, thank you so much
Hi, great to hear! Thanks! 😃
Thank you so much that helped me a lot
Great to hear! 😃
Great tutorial ! Thank you !
You're welcome! 😃
Wow..just wow!
Thanks ...you solved my problem......
I would also like to know whether you are familer with the sound sensor module which has analog pin output too....I expected such a waveform when I connected it to the analog pin but there's no difference at all no matter what sound I make!
I thought the mic was damaged but everyone had the same problem!
The digital sampling I use in this tutorial will not work with the analog output. With an analog output it should be a log easier. Just print the value read on the analog port to the serial monitor. You should see a value variation depending on your sound.
Remember, this sensor cant measure noise level (dB). The amplitude on diagrams dont show noise level, it only shows how long sound sensor was triggered on. When it is quieter, the sensor does not detect the quieter sound as a lower noise level, but activates fewer times in a set period of time.
exactly this 😃
Exactly what I was looking for.
Great to hear! If you have any questions, just ask 😃
@@BasonTech So the sensor you used is for binary sound detection. Instead, I want to do full multi-channel sound recording so that I can play the recorded sound back? Will I need the same sensor? If no, please suggest alternative. Thanks!
Nope, this sensor can't do that. I am also wondering if the Arduino has enough processing power to record multi channel audio. I think the Sony Spresense would be more suitable since it is fast and has multi mic input out of the box: developer.sony.com/develop/spresense/specifications
Really amazing video, thank you lots.
Glad you liked it! 😃
you prolly dont care but if you're stoned like me atm you can watch all the latest movies and series on InstaFlixxer. Have been streaming with my gf for the last few weeks xD
@Keegan Corey Yea, have been watching on InstaFlixxer for years myself :D
Hello sir..I want to make vu meter using ws2812b RGB led and sound sensor..so if I use the statement" if sound value is between x and y then display z leds"..will it be the correct statement..
I want to use if statement ..can I guide me sir.
(X,y,z are just examples I have taken)
This sensor is not so suitable for a VU meter since it is binary. Have a look at the KY-037 or KY-038 which has an analog out. The correct state for between 50 and 60 is:
if((x > 50) && (x < 60)) {
Hello, it's very helpful video and nice presentation. Thankyou so much. I'am doing a project based on this but instead of aurdino how can we interface sound sensor to FPGA. If you know anything about it kindly reply.
I have no idea, sorry 😃
Thanks for your response
great video. thanks 👏
Thanks, glad you like it! 😃
Thanks for such a clear video. If I want to monitor the absence of sound in 10 seconds, how will I code that?
What have you tried so far, and on what are you stuck?
Thank you for the nice explanations. Is there any ways which I can be able to save the plotted audio into WAV or MP4 to an SD Card or by using PySerial?
Nope, it just tells you if there is sound or not. No frequency, dB or anything else.
Thanks a lot bro ! It's help me for my project :)
Great to hear! 😃
Helo, I might be a little late but does the project really work with his code? I'm thinking of doing one for school. :D
@@user-dj8et5np4e Why shouldn't it work?
@@BasonTech I was just wondering due to my fear of messing up, apologies if it offended you
@@user-dj8et5np4e No worries! The only thing you can mess up is with the hardware. If you connect the wires in a wrong way causing a short circuit of something 😃
how far is the detection range of the sound sensor?
Copied from the datasheet at eva.fing.edu.uy/file.php/585/materiales/HD/CZN-15E.pdf
Sensitivity: -46±3dB -42±3dB -38±3dB -34±3dB (0dB=1V/pa,1KHz)
Impedance: Low impedance
Directivity: Omnidirectional
Frequency: 20-16,000Hz
Voltage range: 1.5V-10V
Standard operation voltage:4.5V
Current consumption: Max.0.5mA
Sensitivity reduction: Within -3dB at 3V
S/N ratio: More than 60dB
Hey, great project!!
Can we obtain the same output which shows the amplitudes if we connect the out pin to a PWM pin on the Arduino and do an analog read instead of a digital read?
Thank you
Thanks! The sensor I am using does not have an analog out. So in this tutorial I basically try to mimic an analog signal by sampling a digital one 😃
@@BasonTech Got it, thank you
thank for the video and do u know how to detect the frequency of acoustic signal using this circuit?
You can't this sensor is a binary sensor and only tells you of there is sound or not. With this code we are mimicking some kind of detection by using sampling.
Hey....can I know how /what position did you set the Screw/Potentiometer
The same as the thumbnail shows. Unfortunately my guess is that the position is not really comparable between devices.
thank you. i ask if we can gets sound of leak water in pipline with arduino
Recognising a specific sound with an Arduino is not really possible. You then want to look into a Raspberry PI with a sound recognition software. I have no experience with this.
👉 Don't forget to check arduino-tutorials.net for the code and more Arduino tutorials and projects.
If you have questions, don't hesitate to ask them in de comments. Remember: There are no stupid questions 😃
🔔 Want to stay up-to-date with the latest videos? Subscribe to the Bas on Tech channel!
hello, sir I want to ask you if ever worked with esp8266 I want to visualise the frequencies and their amplitudes on the serial plotter .
The code should work on an ESP8266 😃
Hello, great video, still havent bought any of arduino. Im wondering if i would desolder Microphone and replaced it with RFID antenna, could i read RFID tags?
Hi, that is not going to work. I had a tutorial about RFID, but I took it down because of an error in the video. I can't promise when I upload the fixed version.
Thanks for helpful video..
Just i have a question how can get the sample on binary form for the sound and saying.... With regards
You can't, the sensor just tells you if there is sound or not. It does not provide you with any waveform audio.
Thanks alot!
You're welcome! 😃
Great demonstration. Is it possible to recognize a sound with arduino. I mean I want to sample a sound like a door bell, then if the doorball rings arduino let say gives 1 for example.
Unfortunately not. The "waveform" you see is not actually a waveform. It is a graphical representation of sampled sound intensity. There is no actual information about the sound in the waveform.
Thanks for you explanation and i need help from you sir, the code to shows only analog value of sound but i like to see in dB value , how to convert Analog sound data to dB ? can you put video on this or any idea?
You can't. This sensor does not detect dB nor the frequency of sound. What I detect is the frequency of the sensor detecting sound. Maybe the text version of the tutorial makes it clearer: arduino-tutorials.net/tutorial/drawing-sound-sensor-data-on-serial-plotter
I have the same mic as you.
Do you think it is possible to analyze different freuqencies wirh the arduino?
Maybe with the Help of the FFT libary?
Yes, you can analyse different frequencies with an Arduino. Unfortunately not with this sensor. This is a "binary" sensor so it tells you if there is sound or not and that's it.
first of all thanks for your video. I and my son trying to make recgognize to speech. if i say for example "yellow" i can see some numbers on serial monitor. if i describe some diffrent patterns can i recognize that word and light the yellow red ? please . thanks from Turkey
Hi, that is not going to work on an Arduino. A Raspberry Pi for example should be more capable of such a task.
Can we make a 3d sound localization system with czn15e mics??? I want exact point where the sounds come from.
Theoretically yes, but you then need a very precise timer and calibrated sensors to do such measurements.
very good video. roughly what sensor is suitable for measuring the number of dB?
Thanks! The datasheet states: Sensitivity: -46±3dB -42±3dB -38±3dB -34±3dB (0dB=1V/pa,1KHz) more info at eva.fing.edu.uy/file.php/585/materiales/HD/CZN-15E.pdf
@@BasonTech thanks
Hello. Great video sir!
I just want to ask something sir if its okay. I want to turn on a LED when it reaches a certain amplitude on the plotter (300 for example).
I copied your code and tried a bunch of stuff but it wont work. Sometimes the LED is just steadily on sometimes it wont even turn on. What should i do sir? Thank you in advance
Hi, could you tell me what exactly you've tried already?
Hi Boss,
This is such an amazing video, it worked for me however I have 2 questions:
1. I'm struggling to read the signals from the Audio sensor using a Osciloscope, if I want to create a program that will action something based on some frequency (i.e. a clap light switch) can I use the plotter instead of the osciloscope ?
2. My plotter view is like very big, I would like to zoom out the plotter to have your same view, is there any setting to change to make it ?
THANKS !.
Hi, to display the signals on an oscilloscope you have to output them as analog signals. My code sends it to the serial monitor and the IDE makes the graph. So you then have to modify the code that you use an analog pin to set the correct value over time.
Further this sensor does not measure frequency, so you can't really detect a certain frequency.
To zoom out my guess is that you need to multiply the values by a certain factor which fits your need.
Hoi Bas, Werkt dit ook met die met een rode printplaat lijken op wat kleine verschillen het zelfde. En wat kun je er later mee??
Heel lastig te zeggen, heb je een linkje naar het component?
Amazing! Can you show us if there is a way in which we can convert this analog read into dB? really useful if you could. thanks in advance
You can't with this sensor. The sensor only detects if there is sound, thats is. There is no way to detect dB, volume, intensity or frequencies.
@@BasonTech Oh, Thanks for the response. I was starting to think that this sensor is not really for the environment.
THANKS THIS HELPED ME A LOT!! may i know like where do i enter the code on
Hi, what do mean exactly?
Hi thanks for the video. I have a question: If I have the audio of the SIM800L when a call is outgoing, Can I connect from the speaker outputs of SIM800L to this sound sensor instead of micro inputs in order to detect when someone answer its smartphone for example? thanks
Hi Jesusita, this sensor isn't really the right device for that. I think you need to look into a VU-meter device to which you can connect the speaker out of you SIM800L
@@BasonTech thanks
Hi ! 1. Can I connect more than one sound sensor at one time?
2. Can the data transfer to a bluetooth serial transreciever?
1. You can connect as many as you have ports on your Arduino
2. It should be possible to send the data over Bluetooth
Keep in mind that this is not audio data but just sampled data on whether there is a sound or not. It is not audio waveform data.
Hi, I have a question, what are you exactly report in the serial plotter? Whats the meaning the numbers in x-asis and y-asis
Hi Ismael, great question! I've added the explanation to the website as well: arduino-tutorials.net/tutorial/drawing-sound-sensor-data-on-serial-plotter The x-axis (horizontal) is the time axis. We set SAMPLE_TIME to 10ms. This means that each horizontal point is equal to 10ms. So if we see the number 100 on the x-axis (100x 10ms), 1 second has passed.
The y-axis (vertical) is the number of moments within 10ms that the Arduino sensed sound. This is related to how fast the Arduino can go through the loop(). For example, an 8Mhz Arduino will be able to do fewer measurements per second than a 16Mhz Arduino. They are therefore not exact values, but should be viewed more relative to each other.
Can this be used with arduino fft because it looks like analog output but will it behave like analog signal with arduino fft like an analog signal from sound sensor
Hi, unfortunately I have no experience with Arduino FFT. The signal from the sensor is digital with my sampling you kinda get an analogish signal but is not real analog like a soundwave
Very clear. 1 question. Is there a formula i can use to show the Sound waves in Db values?
Hi Dražen, this sensor is a binary sensor, it just tells you if there is sound. By sampling I try to get a bit of an idea of the intensity of the sound. There is no way this can tell you the amount of decibels. If you want to measure that you'll need another sensor.
Does it measure if the sound is high or low, or does it measure the dice of the letter that comes out of the mouth?
It does measure if there is sound or not during the giving sample time. It has no sense of frequency, tone, voice etc.
Hello, can it connect to a LED then when it reaches a certain sound level (your desired or assigned level) the LED will turn on or will light up?
Hi, sure you can. Just add an if statement which monitors the current value. When it is larger you turn on the LED.
I am using just an electret condenser microphone but without the module circuit. how can I show the output of the microphone on the serial plotter with intensity?
You then need a component which does convert your mic into an analog signal suitable for your Arduino. E.g. 0-5V for 5V Arduinos of 0-3V for 3V Arduinos. Never did this though, so I don't know which component would work.
I found that it was detecting too much noise and if was looking a mess. If you put the line " delay(1); " below the if statements it delays the feedback just enough to smooth the graph and looks much neater.
Keep in mind that delay(1) actually tells the cpu to wait 1ms. So basically you're telling the Arduino to ignore the sensor values within that 1ms. Another way to smoothen is to widen your measurement window and subtract a base level where the noise is 😃
@@BasonTech I find that it sends an unwanted peak. It's one way of removing it :)
btw didn't the peak go away by adjusting the sensitivity?
what do the values represent on the Y-axis? I cant seem to still understand what those values mean on the chart?
During the sample period we count if there was sound or not. We keep track of a counter during this sample period. Every time we detect sound we increase the value by 1. So you can see it as the amount of time over the sample period.
May I know what is the unit reading of the output in serial plotter
I've added the explanation to the website as well: arduino-tutorials.net/tutorial/drawing-sound-sensor-data-on-serial-plotter The x-axis (horizontal) is the time axis. We set SAMPLE_TIME to 10ms. This means that each horizontal point is equal to 10ms. So if we see the number 100 on the x-axis (100x 10ms), 1 second has passed.
The y-axis (vertical) is the number of moments within 10ms that the Arduino sensed sound. This is related to how fast the Arduino can go through the loop(). For example, an 8Mhz Arduino will be able to do fewer measurements per second than a 16Mhz Arduino. They are therefore not exact values, but should be viewed more relative to each other.
Can you do the same thing with a Piezo Sensor?
What kind of sensor are you referring to? I only now a piezo speaker, not a sensor 😃
Great Video, but us there a way to have the serial plotters values as a usable value in an if statement, I am working on a small project for example when the serial plotter hits over 100 I want a led to turn on, and when its below 100 to turn off, but I just dont know what variable to put into the if statement.
Like the serial plotter shows the values up to 1000, but when using an if statement or the sampleBufferValue the statement only works when its being compared to a 1, and nothing over 1
Hi, in my code I use:
if (millisElapsed > SAMPLE_TIME) {
This if checks if the sample time has passed. You can add an additional if inside this if (or extend the if) for your desired value like:
if ((millisElapsed > SAMPLE_TIME) && (sampleBufferValue > 100)) {
@@BasonTech Perfect, that works great, thanks for the help!
Great to hear! 😃
Thank you very much sir. Sir I want to analyze multiple sound sensors data. Is it possible to analyze on same serial plotter and detect the sound sensed by a particular sensor.? Thank you in advance 😊
Hi, you want multiple lines plotted on the same screen?
Hi Bas on Tech. I am using a mic and custom op amp circuits to amplify the sound. But when i run part 2 of your code, i am not able to see the same kind of values your are seeing. Using a headphone jack breakout I was able to hear the audio input to the mic. But my arduino is not showing me those waveforms. Would you be able to help me out on this?
Kinda hard to say, I've made this tutorial specific for this kind of sensor who is a binary sensor. A mic and amp does not work this way.
Can we compare 2 different microphones (sound sensors) to see which one is louder and send an output on one? If yes, please tell me how
You can't. This sensor does not measure loudness. It measures if there is sound or not. So the answer of the sensor is either "yes" or "no". No such thing as volume, decibel, loudness, intensity etc. In this tutorial I sample sound for a certain period. The y-axis only tells you the sound intensity during the measured sampled period of time.
@@BasonTech Thanks for the reply! Is there any sensor that can measure the volume, decibel level and etc... mentioned above?
Hey what a coincidence.....I am trying something similar too...
I am trying to compare the output of two mics kept on left and right and rotate servo motor to that direction....
Did you find anything more about this?....If so please share...highly appreciated....
@@delux37playsyt30 I was planning to use a amplifer + Mic module like a MAX4466 and get the audio input and compare them etc etc....
@majorchristopherkyle1077 I did a bit nore digging around and found that if your sound sensor has an AO (analog) pin, you can use it to monitor different levels of volume inputs. Hope this helps!
Congratulations was cool, but have you ever thought about making a spectrum analyzer using WS2818 led strip and the sound sensor?
Hi Luiz, yes I did! Unfortunately time is currently not on my side, but it is definitely something I want to look into 😃
@@BasonTech do you have the code ready?
Nope, I have the parts laying around, but not yet build anything
Sir, Thank you . It's a great tutorial. sir, is there a way to try this code for this sound sensor with an ATmega32 microcontroller ?
I can't think of anything why that wouldn't work 😃
@@BasonTech ok thank you sir
..😊
interesting video! i guess we can figured out the frequency of the sound based of the sampling?
i hope u answer my question
Hi, unfortunately we can't. This sampling calculates the amount of sound the sensor detects in the given sample time. It is unrelated to the frequency of sound. It is more the frequency of the amount of sound detected 😃
Can i use diffirent output for a different amplitude ? can you show me how please?
What do you mean with "different amplitude"?
@@BasonTech like when you see your serial ploter you can figer that the sound wave had different wave length so I wish I can use all this different to different wave length to different out put like FFT program function.
Can i use audio signal with RCA cables without microphone?
No you can't. For that you need a different circuit this is just a binary sound sensor.
How can I reflect this kind of graph to the 5110 lcd.
I've never worked with the 5110. But if you manage to get te screen working you should be able to convert the chart values into lines on your screen.
Is it possible to save the audio files as .wave? Using this sensor
Not at all. The data is a sampled representation of the sound intensity. It is not a so-called "waveform". So the data you see does not in any way represent the actual audio content.
Sir so how to do make a combination for this sound sensor and LED light? As I want to know about it. Could you plz make a video about it?
Hi, what do you want to achieve with the LED?
Hi there! Absolutely informative video. one question, how can we use this sensor to detect a specific audios like cry, laugh and trigger a relay?
Hi, this is not possible. The sensor just detects if there is sound or not. The highest achievable would be "clap detection".
@@BasonTech so can this be achieved using KY-037 or 038?
@@BasonTech I am trying to turn on the camera when the cry is detected using sound module..help me out please 😅
It could be, the biggest issue is to detect the characteristics of the waveform what we see as "cry" of "laugh".
Is it possible to measure the exact decibel. Like if the intensity of sound is more than a specified limit one can get warning or something like that?
The sensor just measures if there is sound or not. So there is no measurement of the intensity, decibel, frequency or whatsoever.
@@BasonTech so what's the solution for this?
Probably use a "real" decibel sensor. Unfortunately I have no experience with these
@@BasonTech no problem..
Thanks for replying
Hi dear sir, can we use two sounds and then differentiate their frequencies and display?
Hi, not with this sensor. This is a binary sensor: it tells you if there is sound or not. It doesn't measure a frequency at all. In order to do so you need another sound sensor.
@@BasonTech sir, actually I want to make a device to measure different frequency sound waves and find individual wave like in fast forrier transform of quite nice range. If any sensor available, please reply. Thank you.
Can you please make a video for frequency vs amplitude
Hi Bas - I find it very difficult to tune the potentiometer - the same as the one in your link. The "sweet spot" between registers "ON" all the time vs registers "OFF" all the time is a hair's breadth. Literally even touching the pot with a screwdriver is enough to turn it from full on to full off, or vice versa. I bought a different mic board, and got the same result. Any ideas on this?
Hi John, that is weird. The only thing I could think of is that for example you use a 5V sensor on a 3V Arduino or something like that. On a 3V Arduino everything higher than 1.5 is considered to be 1. When having 5V connected that is 80% of the time, instead of 50%.
@@BasonTech Thanks, but no I tried them on 5V and 3.3V. It's either full on or full off, with a hair trigger separating the two states. I've ordered another mic and if that doesn't work I'll give up. When I am able to find the sweet spot, after 10 minutes it's already worked its way out into the full on or full off states, without any external intervention, rendering it useless for the 24/7 ambient noise-level monitoring that I was hoping to use this for...
Keep in mind that sometimes it takes me multiple tries as well to get things figured 😄
great.. now what i need to do is somehow transmit the output via wifi then access it remotely ...the ultimate aim is to monitor sound levels remotely...plase guide me on the setup i need cheers
On what part are you getting stuck?
Whats the lowest db this sensor can detect? and what distance can it detect?
The datasheet on eva.fing.edu.uy/file.php/585/materiales/HD/CZN-15E.pdf only says: Sensitivity: -46±3dB -42±3dB -38±3dB -34±3dB (0dB=1V/pa,1KH
Amazing video man! super dope I just bought this component and your video is exactly what I was looking for. I also make tech footage too check out my projects when you get the time
Glad I could help! 😃
@@BasonTech When I make my project using it I am going to shout you out !
Hello I shouted you out in my most recent footage! thanks for all the help! I recently posted it.
Thanks! :)
@@BasonTech welcome
Thaaank you
My pleasure! 😃
can i ask if you know how to show the decibel equivalent of the sound?
I've having a hard time with it .
You can't with this sensor. It does not measure decibel at all.
Is it possible using same approach to convert this into dB?
Hi, unfortunately not. The sensor is binary and can only tell you if there is sound or not. There is no way to measure the amount of dB with.
@@BasonTech I'm making a research in the internet, it is possible to do it with analog microphones, but yet I'm having little success making it working
This is nog an analog microphone, it is a binary sound sensor
Hello, I want the relay to be on all the time when there is voice. and then turn off the relay when the voice is finished.
Then you should add some kind of "debounce" and a threshold. When there is noise the relay turns on. When there is no sound the debounce makes sure the relay doesn't immediately turn off.
I am having trouble trying to run two of these sensors at the same time? No matter how I try to rewrite the code enabling a second sensor the graph will only show one. Any suggestions?
What have you tried so far and didn't work out?
Can I forge the code in GNU Octave?
I think it could work if GNU Octave can read the serial port of the Arduino. Another option could be that some middleware intercepts the serial output and send it over to GNU Octave. I personally do not have any experience with this 😃
Well, if the sound is below 100, I want to do an action
if(sampleBufferValue
This should be correct. Are you using it in the loop() function?
sir!! can you code the program to display the same wave on OLED display ?
If you combine my OLED tutorial from th-cam.com/video/SuSqalI90G0/w-d-xo.html with this tutorial, you should be able to write it yourself 😃
How to display these types of spectrum anysis on a P10 led module
Then you have to translate the chart values to bar lengths, and show this on the P10 module
i have a question , this sound detector can detect infra sound ? also the sound detector can detect sound under water ?
I don't know what you mean bij infra sound. If you mean ultrasonic sound it can't. According to the datasheet the CZN-15E has a frequency range of 20-16,000Hz. Ultrasound starts at 20,000, so it can't detect this. I don't know about under water but this circuit is not waterproof.
@@BasonTech Sounds with a frequency of 20 Hz and lower are called infrasound
Never knew! But still, it has the range of 20-16,000Hz so infrasound will nog be detected
@@BasonTech i understand thank you !
Excuse my simple question, but I have a goal in mind to record this data over time and stream it to a text file. I understand that I would require an SD card module connected to the arduino in order to do so. Therefore I am considering going for a raspberry pi to fulfil this purpose (given the added benefits of using a Pi).
My question is: would this sensor module work with a raspberry Pi as well, and would I be able to reproduce this scenario with a modified script? (Using a while loop in any programming language for example, instead of the native arduino loop)?
Hi, this sensor should probably work on a RPI as well. Keep in kind that this is not audio waveform data. You are not able to play this data as audio.
How to use arduino, 16bit adc and Bluetooth module to transmit digital audio to bluetooth earphone?
Sorry I have no experience with these components. Maybe you can ask on the Arduino Reddit of on the Arduino forum?
Can you help me to build a circuit for my University project?
Hi, I am sorry I don't have time for helping with individual projects 😐
Hi, the video bis pretty cool, but I was thinking what if i want to manipulate the frequency of the sound and the pitch, how that could be done.
I geuss, we need to connect the mic to a digital to analoge converter, that could be done by coding as well but we need to use equations. Anyway, do you have a clue of how that could be done
You can't since this is a binary sensor. The plot is only plotting the amount of sound, not the frequency. If you want to work with the frequency of sound you'll need another sensor 😃
@@BasonTech you please make a video for frequency vs amplitude
Which software you use to write code
Kinda depends, mostly in the Arduino IDE. Sometimes I use vscode with the Arduino extension 😃
hey can I know the maximum distance this sound sensor can pick up sound?
Hi Airel, I honestly have no clue. I guess it will also depend on the intensity of sound. Obviously loud sound will be easier to detect over longer distance. Best to do is probably figure out by trying.
@@BasonTech oh okay thanks!
You're welcome! 😃
Hi any tips how to send this data over Bluetooth? I'm making a Bluetooth headset
I want to send it to my pc
this is no audio data, so there is no way to transmit this as audio. It purely sampled data from the sensor
Sir i want detect particular sound only. It can do Or not?
Unfortunately this sensor can't. You might want to look into a Raspberry Pi or Sony Spresense
@@BasonTech thank you bro
How to know the sound values in terms of decibels?
You can't with this sensor. It just gives you an prediction of the sound intensity.