A sound meter is a device capable of representing the "noise level" present in a place at a given time. It consists of a microphone and an electronic transducer that translates the pressure of the sound waves into an electrical signal. The level of the electrical signal will then be transformed into a specific standard value, the decibel. In the current standard, 20 dB corresponds to a whisper, 30 dB to background noise in the countryside, 45 dB to a conversation, 60 dB to noise in a busy public place and so on.
Now, our Seeeduino Wio Terminal has a built-in microphone, an analog input, an ADC converter, a display and a compiler as standard: so why not try to build your own sound level meter?
The ProjectThe sound level meter with Seeeduino Wio works perfectly by connecting the Wio to an electrical source with its USB-C cable, but obviously a portable power supply system is required for operation in the field.
The Wio Terminal produced by SeeedStudio has an integrated microphone connected to an analog pin of the board, defined as WIO_MIC. The value present on this pin is accessible through the command
value = analogRead(WIO_MIC);
and gives an integer answer between 0 and 1023.
This response can then be converted into decibels (dB) using the classic command:
dB = map(value, 0, 1023, 0, 100);
Obviously, the microphone supplied with the WIO does not have a high fidelity sensitivity, and before obtaining valid readings we will have to perform an appropriate calibration, described later in the article.
The readings are acquired through the moving average system, which allows to discard the peak values and to make the returned value more homogeneous.
At this point it will be sufficient to pass the calculated value translated into decibels to the graphical representation routine described in the next paragraph.
The softwareThe software is freely downloadable through GitHub, and requires the SPI library to interact with the integrated display.
We first define the constants relative to the window size for the calculation of the moving average, and some variables necessary for the graphics routine.
The program makes extensive use of the TFT_Meters sample code already supplied with the Wio Terminal. We have rotated the image of the instrument by 90 degrees and modified its measurements, then we have eliminated the linear instruments and added a sprite at the bottom representing the float value of the calculated dB.
The setup() section initializes the display, defines the landscape representation, initializes the sprite relating to the calculated sound pressure value, draws the instrument for the first time and updates the timer.
The loop() section just calls the function delegated to update the display.
Instrument calibrationAs mentioned above, the microphone integrated in the Wio Terminal does not have an excellent sensitivity. It was therefore necessary to design and apply a series of corrective tests of the basic program to obtain results closer to reality, The sensitivity was increased by decreasing the range of values present in the map() function from 0..1023 to a narrower range. From subsequent measurements we found that the value read by the ADC was constantly higher than 150, and lower than 850. We therefore used a professional sound level meter, and measured both the noise in dB present in different situations and the level reported by the converter of our Wio. Finally, we created a linear regression line between the data and applied the downstream coefficients of our mapping formula.
The result was exciting: the needle of the instrument reproduced quite faithfully the peak values found by the professional instrument, while the numerical reading expressed the moving average. Due to the interpolation, a lower precision remains below 30 dB and above 70. It should be added that the instrument is also affected by thermal drift problems: the value read by the WIO_MIC port tends to decrease with the time.
Project extensionsSeeeduino Wio Terminal has 3 software programmable buttons. Therefore, if you want to add different data collection systems (for example by widening the window for calculating the moving average, or by acting on the timers that regulate the interval between two successive readings), it will be sufficient to define the following variables in the program:
Once you have assimilated the functions for creating the graphical interface, the project appears quite simple:
- acquisition of an analog value,
- transformation of the value into an appropriate format
- passing the value to the graphics routine.
The video explains the how-tos and shows the software and the use of the sound meter. It is both Italian and English close-captioned.
Comments
Please log in or sign up to comment.