Sound Level Meter
- Understand how to use the “serial debug” and “serial inject” nodes correctly.
- Learn how to connect the sound sensor and Arduino/Genuino101 correctly in order to make a sound test meter
- Understand how the sound sensor works.
IoT (Internet of things) literally means connecting everything by the internet. One of the biggest features of IoT is to constantly acquire information from the environment and offer instant feedback. In this passage, we will use the sound sensor in the CurieNeurons Kit to create a sound level meter, allowing you to acquire the noise level of the environment in real time, as shown in Picture 1.
Picture 1: Sound Level Meter
There are two problems when making a sound level meter:
- How to acquire the data from the environment, in this case, sound data in real time?
- How to display the value of the sound data?
The sound sensor in CurieNeurons Kit can acquire the sound values of the environment, and the “serial debug” node can help us display the aquired values. The entire project analysis can be found in Figure 1.
Figure 1: Project Analysis – Sound Level Meter
Sound Level Meter
Aquire the sound value of the environment and display it in real time.
Arduino/Genuino101, Extension board, Sound sensor
A. Sound Sensor
The sound sensor is a simple and practical electronic “listening” device, it can hear the sound volume and convert it into an analog signal. It can aquire the sound volume of the environment from simulating the value of the voltage signal. The sound sensor should be connected into the analog pin and the value range should be between 0-1023. It will output different values depends on the volume of the sound; the higher the volume, the higher the value, and vice versa.
We can use a simple 3-cord-wire to conect it into the “brain”, the Arduino/Genuino101 controller. The Arduino/Genuino101 will then respond in a specific way after “hearing” different volumes of sound. The sound sensor measures the sound and has the capabilities of amplifying the sound 300x. Output analog signals can use 3.3V and 5V as the reference voltage for AD. This sound sensor can do all kinds of interactions based on sound volume, such as making a sound-controlled robot, a sound-controlled switch, a sound alarm, etc.
Picture 2: Sound Sensor
B. Serial Debug
The “Serial Debug” node is widely used in SmartNode. We will use it frequently during program debugging, as shown in Picture 3. The testing data will be displayed in the “debugging” interface. In this case, the value of the sound volume will be displayed.
Picture 3: “Serial Debug” node
C. Serial Input
It is very common to use the “Serial Inject” node to begin the programming in SmartNode, as shown in Picture 4. The “Serial Inject” node can replace a physical switch and become a virtual switch to control the program operation. In this case, we use “Serial Input” node to control the operation of the sound level meter.
Picture 4: “Serial inject” node
Connect the Arduino/Genuino101, extension board, and sound sensor as Picture 5 shows. Connect the sound sensor to analog iput: A0.
Picture 5: Connection diagram of the Sound Level Meter
The Sound Level Meter utilizes data flow that is injected from the “serial inject” node”. You then need to display the real-time data in the “debugging” window. The entire work flow should look like Picture 6.
Picture 6: Programming behind the Sound Level Meter
C. Set Up
Because we need to constantly measure the value from the sound sensor, we need to set up a “serial Inject” node. It is just like a physical switch. We will set 1 to open the sound sensor, and name it “Switch”; the serial port can be set based on your computer’s conditions. See Picture 7 for reference.
Picture 7: Setting up the “Serial Inject” node
In order to acquire the volume of the environment, we need to introduce a “DFsound” node into SmartNode. Set it up as shown in Picture 8.
Picture 8: Setting up the “Serial Inject” node for the sound sensor
The sound sensor can receive the volume of the environment in real time, but how can we read it? To solve this problem, we will use a “Serial Debug” node. Setting up this node is fairly easy. In this case, we will set the “Output” to “message property” and then “to” “debug tab”, as Picture 9 shows.
Picture 9: Setting up the Debug node
By now, you are all set!
Click “Deploy” and you will see if the sound level meter is working as expected. If not, ask your friends or simply post your question on our forums!
Last but not least, don’t forget to share your work and learning process with your friends and colleagues!